mirror of
https://github.com/circify/circ.git
synced 2026-05-14 03:00:33 -04:00
I split the hash-consing implementation into its own crate and re-implemented it. In the new implementation, the table is thread-local. Terms are not Send, but linear terms are. Decreased used of atomics gives a non-trivial speed-up. I tested on Z#'s sha2 round function, with an exit after IR optimization: Benchmark #1: ./circ-old third_party/ZoKrates/zokrates_stdlib/stdlib/hashes/sha256/shaRound.zok r1cs Time (mean ± σ): 236.2 ms ± 16.1 ms [User: 223.3 ms, System: 12.4 ms] Range (min … max): 221.1 ms … 264.1 ms 11 runs Benchmark #2: ./circ-new third_party/ZoKrates/zokrates_stdlib/stdlib/hashes/sha256/shaRound.zok r1cs Time (mean ± σ): 141.8 ms ± 13.1 ms [User: 131.3 ms, System: 10.0 ms] Range (min … max): 125.4 ms … 160.4 ms 18 runs Summary './circ-new third_party/ZoKrates/zokrates_stdlib/stdlib/hashes/sha256/shaRound.zok r1cs' ran 1.67 ± 0.19 times faster than './circ-old third_party/ZoKrates/zokrates_stdlib/stdlib/hashes/sha256/shaRound.zok r1cs'
21 lines
400 B
Bash
Executable File
21 lines
400 B
Bash
Executable File
#!/usr/bin/env zsh
|
|
|
|
template=$1
|
|
dest=$2
|
|
macro_name=$3
|
|
body=$(cat $template \
|
|
| sed '/SocketAddrV6/d' \
|
|
| sed 's/crate::/$crate::/' \
|
|
| sed 's/TemplateOp/$Op/g')
|
|
|
|
echo "
|
|
// Warning: this file is generated from $template and generate_macro.zsh
|
|
#[macro_export]
|
|
macro_rules! $macro_name {
|
|
(\$Op:ty) => {
|
|
$body
|
|
};
|
|
}
|
|
pub use crate::$macro_name as generate_hashcons;
|
|
" | rustfmt > $dest
|