From 577da30fc32e98c05edd5883099c6cdcedd7f34f Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 16 May 2024 14:39:17 -0700 Subject: [PATCH 01/10] add custom target for didc --- rust/candid_parser/src/bindings/rust.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rust/candid_parser/src/bindings/rust.rs b/rust/candid_parser/src/bindings/rust.rs index d136b631..3e66a2f0 100644 --- a/rust/candid_parser/src/bindings/rust.rs +++ b/rust/candid_parser/src/bindings/rust.rs @@ -8,6 +8,7 @@ use candid::types::{Field, Function, Label, SharedLabel, Type, TypeEnv, TypeInne use convert_case::{Case, Casing}; use pretty::RcDoc; use serde::Serialize; +use std::borrow::Cow; use std::collections::{BTreeMap, BTreeSet}; #[derive(Default, Deserialize, Clone, Debug)] @@ -572,16 +573,23 @@ pub fn compile( external: ExternalConfig, ) -> String { let source = match external.0.get("target").map(|s| s.as_str()) { - Some("canister_call") | None => include_str!("rust_call.hbs"), - Some("agent") => include_str!("rust_agent.hbs"), - Some("stub") => include_str!("rust_stub.hbs"), + Some("canister_call") | None => Cow::Borrowed(include_str!("rust_call.hbs")), + Some("agent") => Cow::Borrowed(include_str!("rust_agent.hbs")), + Some("stub") => Cow::Borrowed(include_str!("rust_stub.hbs")), + Some("custom") => { + let template = external + .0 + .get("template") + .expect("template field expected for custom target"); + Cow::Owned(std::fs::read_to_string(template).unwrap()) + } _ => unimplemented!(), }; let (output, unused) = emit_bindgen(tree, env, actor); for e in unused { eprintln!("WARNING: path {e} is unused"); } - output_handlebar(output, external, source) + output_handlebar(output, external, &source) } pub enum TypePath { From 82ce2c80daba944ee15fdd6e29dfe4685e9159fc Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 16 May 2024 16:18:26 -0700 Subject: [PATCH 02/10] readme --- tools/didc/README.md | 30 +++++++++++++++++++++++------- tools/didc/src/main.rs | 2 +- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/tools/didc/README.md b/tools/didc/README.md index 49326198..0140f272 100644 --- a/tools/didc/README.md +++ b/tools/didc/README.md @@ -15,7 +15,27 @@ SUBCOMMANDS: encode Encode Candid value decode Decode Candid binary data random Generate random Candid values - diff Diff two Candid values +``` + +## TOML config + +`didc bind -t rs` and `didc random` can take a TOML file to configure how `didc` generate Rust binding or random values. + +Rust bindgen can take an external Handlebar template with the following TOML file, + +```toml +[didc.rust] +target = "custom" # Other targets: canister_call, agent, stub +template = "template.hbs" # required for custom target +# any tags mentioned from hbs +candid_crate = "candid" +service_name = "service" + +[rust] +visibility = "pub(crate)" +attributes = "#[derive(CandidType, Deserialize, Debug)]" +GetBlocksResponse.attributes = "#[derive(CandidType, Deserialize, Debug, Clone, Serialize)]" +GetBlocksResponseArchivedBlocksItem.name = "ABetterName" ``` ## Examples @@ -41,10 +61,6 @@ $ didc decode '4449444c016d7c027c002a0301027d' $ didc decode '4449444c016d7c027c002a0301027d' -t '(int)' (42) -$ didc diff '(record{1;2;3}, 42)' '(record{1;5;9}, 42)' -record { edit { 1 put { 5 } }; edit { 2 put { 9 } }; } -skip - $ didc bind hello.did -t js export const idlFactory = ({ IDL }) => { return IDL.Service({ 'greet' : IDL.Func([IDL.Text], [IDL.Text], []) }); @@ -53,9 +69,9 @@ export const idlFactory = ({ IDL }) => { $ didc random -t '(int, text)' (-72_594_379_354_493_140_610_202_928_640_651_761_468, "_J`:t7^>") -$ didc random -t '(int, text)' -c '{ range = Some [-10, +10], text = "name" }' +$ didc random -t '(int, text)' -c 'random = { range = [-10, +10], text = "name" }' (-6, "Cindy Klocko") -$ didc random -d service.did -m method -f random.dhall -a '("seed argument")' -l js +$ didc random -d service.did -m method -c random.toml -a '("seed argument")' -l js [new BigNumber('-4'), 'Marcus Kris'] ``` diff --git a/tools/didc/src/main.rs b/tools/didc/src/main.rs index c0b59198..ee59bbff 100644 --- a/tools/didc/src/main.rs +++ b/tools/didc/src/main.rs @@ -218,7 +218,7 @@ fn main() -> Result<()> { "rs" => { use candid_parser::bindings::rust::{compile, Config, ExternalConfig}; let external = configs - .get_subtable(&["external".to_string(), "rust".to_string()]) + .get_subtable(&["didc".to_string(), "rust".to_string()]) .map(|x| x.clone().try_into().unwrap()) .unwrap_or(ExternalConfig::default()); let config = Config::new(configs); From 00e8e13deec023eb193dbbc0bbe92eb6c319ab23 Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 23 May 2024 10:17:51 +0200 Subject: [PATCH 03/10] bump canbench --- .github/workflows/bench.yml | 2 +- rust/bench/Cargo.lock | 363 +++++++++++++++++++++++++----------- 2 files changed, 256 insertions(+), 109 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index e5f84308..19393119 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -35,7 +35,7 @@ jobs: ~/.cargo target rust/bench/target - key: ${{ runner.os }}-bench-0.1.3-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-bench-0.1.4-${{ hashFiles('**/Cargo.lock') }} - name: Install canbench run: cargo install canbench - name: Run perf for base branch diff --git a/rust/bench/Cargo.lock b/rust/bench/Cargo.lock index 9d3c9add..50edc5f5 100644 --- a/rust/bench/Cargo.lock +++ b/rust/bench/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.81" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arbitrary" @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "beef" @@ -101,12 +101,6 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.5.0" @@ -130,9 +124,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "canbench-rs" -version = "0.1.1" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5d551419a1547b5064111df7bfa6e87818750e7f6df611067a02e63a9cbb31" +checksum = "53574f268dbe23dc83f891a4751b118a6ba927c8bc92e839ff108f3aaf151aa9" dependencies = [ "canbench-rs-macros", "candid", @@ -142,9 +136,9 @@ dependencies = [ [[package]] name = "canbench-rs-macros" -version = "0.1.0" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5acd4a41fd2e7018508f7442d7ae90957a913c6fa0e4b767e5be9a8cc5848c8" +checksum = "d454906c77138a3802a7a680259cca7c006e9b268ba6905f7f4f2b8b74293fa4" dependencies = [ "proc-macro2", "quote", @@ -153,7 +147,7 @@ dependencies = [ [[package]] name = "candid" -version = "0.10.6" +version = "0.10.8" dependencies = [ "anyhow", "binread", @@ -179,31 +173,34 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.65", ] [[package]] name = "candid_parser" -version = "0.1.4" +version = "0.2.0-beta.1" dependencies = [ "anyhow", "candid", "codespan-reporting", "convert_case", + "handlebars", "hex", "lalrpop", "lalrpop-util", "logos", "num-bigint", "pretty", + "serde", "thiserror", + "toml", ] [[package]] name = "cc" -version = "1.0.92" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2678b2e3449475e95b0aa6f9b506a28e61b3dc8996592b983695e8ebb58a8b41" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cfg-if" @@ -241,9 +238,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -266,9 +263,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "digest" @@ -303,15 +300,15 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "ena" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" dependencies = [ "log", ] @@ -346,20 +343,34 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", "wasi", ] +[[package]] +name = "handlebars" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hex" @@ -431,6 +442,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + [[package]] name = "lalrpop" version = "0.20.2" @@ -445,7 +462,7 @@ dependencies = [ "petgraph", "pico-args", "regex", - "regex-syntax 0.8.3", + "regex-syntax", "string_cache", "term", "tiny-keccak", @@ -476,9 +493,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libredox" @@ -486,15 +503,15 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags", "libc", ] [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -508,32 +525,33 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "logos" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1" +checksum = "161971eb88a0da7ae0c333e1063467c5b5727e7fb6b710b8db4814eade3a42e8" dependencies = [ "logos-derive", ] [[package]] name = "logos-codegen" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc487311295e0002e452025d6b580b77bb17286de87b57138f3b5db711cded68" +checksum = "8e31badd9de5131fdf4921f6473d457e3dd85b11b7f091ceb50e4df7c3eeb12a" dependencies = [ "beef", "fnv", + "lazy_static", "proc-macro2", "quote", - "regex-syntax 0.6.29", - "syn 2.0.58", + "regex-syntax", + "syn 2.0.65", ] [[package]] name = "logos-derive" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbfc0d229f1f42d790440136d941afd806bc9e949e2bcb8faa813b0f00d1267e" +checksum = "1c2a69b3eb68d5bd595107c9ee58d7e07fe2bb5e360cc85b0f084dedac80de0a" dependencies = [ "logos-codegen", ] @@ -552,11 +570,10 @@ checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", "serde", @@ -573,9 +590,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -588,9 +605,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", "parking_lot_core", @@ -598,9 +615,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", @@ -611,15 +628,60 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pest" +version = "2.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.65", +] + +[[package]] +name = "pest_meta" +version = "2.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" +dependencies = [ + "once_cell", + "pest", + "sha2", +] [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", "indexmap", @@ -659,9 +721,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" dependencies = [ "unicode-ident", ] @@ -677,20 +739,20 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] @@ -713,7 +775,7 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.8.3", + "regex-syntax", ] [[package]] @@ -724,15 +786,9 @@ checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax", ] -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - [[package]] name = "regex-syntax" version = "0.8.3" @@ -741,9 +797,15 @@ checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + +[[package]] +name = "ryu" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -762,9 +824,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] @@ -780,13 +842,33 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.65", +] + +[[package]] +name = "serde_json" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", ] [[package]] @@ -862,9 +944,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.58" +version = "2.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687" +checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" dependencies = [ "proc-macro2", "quote", @@ -893,22 +975,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.58", + "syn 2.0.65", ] [[package]] @@ -920,6 +1002,40 @@ dependencies = [ "crunchy", ] +[[package]] +name = "toml" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "typed-arena" version = "2.0.2" @@ -932,6 +1048,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + [[package]] name = "unicode-ident" version = "1.0.12" @@ -946,9 +1068,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" @@ -996,11 +1118,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys", ] [[package]] @@ -1009,15 +1131,25 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -1026,42 +1158,57 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +dependencies = [ + "memchr", +] From 48b63b78c9a9dc583010cfa446167edece4064a9 Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 23 May 2024 10:29:46 +0200 Subject: [PATCH 04/10] try --- .github/workflows/bench.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 19393119..fb89c936 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -38,12 +38,12 @@ jobs: key: ${{ runner.os }}-bench-0.1.4-${{ hashFiles('**/Cargo.lock') }} - name: Install canbench run: cargo install canbench - - name: Run perf for base branch - run: | - pushd main/rust/bench - canbench --persist - popd - cp main/rust/bench/canbench_results.yml rust/bench/ +# - name: Run perf for base branch +# run: | +# pushd main/rust/bench +# canbench --persist +# popd +# cp main/rust/bench/canbench_results.yml rust/bench/ - name: Run perf for PR beanch run: | pushd rust/bench From 02b1003e40f77bb6508ce2c8a7a3e0a04ea4043b Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 23 May 2024 10:51:57 +0200 Subject: [PATCH 05/10] gzip --- rust/bench/canbench.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rust/bench/canbench.yml b/rust/bench/canbench.yml index fc3ca40f..fe64dec9 100644 --- a/rust/bench/canbench.yml +++ b/rust/bench/canbench.yml @@ -1,5 +1,6 @@ build_cmd: - cargo build --release --target wasm32-unknown-unknown + cargo build --release --target wasm32-unknown-unknown && + gzip ./target/wasm32-unknown-unknown/release/bench.wasm wasm_path: - ./target/wasm32-unknown-unknown/release/bench.wasm + ./target/wasm32-unknown-unknown/release/bench.wasm.gz From e91fdefeae5e33641478657f5b3a067ed125f46d Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 23 May 2024 10:59:18 +0200 Subject: [PATCH 06/10] fix --- rust/bench/canbench.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/bench/canbench.yml b/rust/bench/canbench.yml index fe64dec9..f96cbe42 100644 --- a/rust/bench/canbench.yml +++ b/rust/bench/canbench.yml @@ -1,6 +1,6 @@ build_cmd: cargo build --release --target wasm32-unknown-unknown && - gzip ./target/wasm32-unknown-unknown/release/bench.wasm + gzip -f ./target/wasm32-unknown-unknown/release/bench.wasm wasm_path: ./target/wasm32-unknown-unknown/release/bench.wasm.gz From 9ee5c3b007841ab926fbd9665d84ea90da239e07 Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 23 May 2024 11:05:19 +0200 Subject: [PATCH 07/10] try --- .github/workflows/bench.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index fb89c936..19393119 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -38,12 +38,12 @@ jobs: key: ${{ runner.os }}-bench-0.1.4-${{ hashFiles('**/Cargo.lock') }} - name: Install canbench run: cargo install canbench -# - name: Run perf for base branch -# run: | -# pushd main/rust/bench -# canbench --persist -# popd -# cp main/rust/bench/canbench_results.yml rust/bench/ + - name: Run perf for base branch + run: | + pushd main/rust/bench + canbench --persist + popd + cp main/rust/bench/canbench_results.yml rust/bench/ - name: Run perf for PR beanch run: | pushd rust/bench From e98c992b6baae313c87201046622919446616b3f Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 23 May 2024 11:10:45 +0200 Subject: [PATCH 08/10] try --- .github/workflows/bench.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index 19393119..ff3638b2 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -38,16 +38,17 @@ jobs: key: ${{ runner.os }}-bench-0.1.4-${{ hashFiles('**/Cargo.lock') }} - name: Install canbench run: cargo install canbench - - name: Run perf for base branch - run: | - pushd main/rust/bench - canbench --persist - popd - cp main/rust/bench/canbench_results.yml rust/bench/ +# - name: Run perf for base branch +# run: | +# pushd main/rust/bench +# canbench --persist +# popd +# cp main/rust/bench/canbench_results.yml rust/bench/ - name: Run perf for PR beanch run: | pushd rust/bench - canbench --less-verbose --persist > /tmp/perf.txt + #canbench --less-verbose --persist > /tmp/perf.txt + canbench --persist python diff.py canbench_results.yml ../../main/rust/bench/canbench_results.yml > /tmp/table.md { cat /tmp/table.md From 4a0b5295b50470e003c9cca9cbd1edf561189ff8 Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 23 May 2024 11:15:54 +0200 Subject: [PATCH 09/10] fix --- .github/workflows/bench.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index ff3638b2..efc90bea 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -38,12 +38,12 @@ jobs: key: ${{ runner.os }}-bench-0.1.4-${{ hashFiles('**/Cargo.lock') }} - name: Install canbench run: cargo install canbench -# - name: Run perf for base branch -# run: | -# pushd main/rust/bench -# canbench --persist -# popd -# cp main/rust/bench/canbench_results.yml rust/bench/ + - name: Run perf for base branch + run: | + pushd main/rust/bench + canbench --persist + popd + cp main/rust/bench/canbench_results.yml rust/bench/ - name: Run perf for PR beanch run: | pushd rust/bench From e8be803fc0aa412707ef9d4419b90ddc8e8f0c27 Mon Sep 17 00:00:00 2001 From: Yan Chen <48968912+chenyan-dfinity@users.noreply.github.com> Date: Thu, 23 May 2024 11:18:43 +0200 Subject: [PATCH 10/10] fix --- .github/workflows/bench.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index efc90bea..19393119 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -47,8 +47,7 @@ jobs: - name: Run perf for PR beanch run: | pushd rust/bench - #canbench --less-verbose --persist > /tmp/perf.txt - canbench --persist + canbench --less-verbose --persist > /tmp/perf.txt python diff.py canbench_results.yml ../../main/rust/bench/canbench_results.yml > /tmp/table.md { cat /tmp/table.md