perf: 高速化対応#3
Open
HappyOnigiri wants to merge 5 commits into
Open
Conversation
rust-crypto 0.2 は新しい Rust ツールチェインでビルドできないため sha1 crate 0.10 へ移行。これに伴い Cargo.lock を最新フォーマット (v4) で再生成した。 seahorse は Cargo.toml では ^1.0.0 のまま、Cargo.lock で 1.0.0 に ピン留めする。1.1.2 で Flag::usage() が削除されており、^1.0.0 が 1.1.2 に解決されるとビルドできないため。
prefix("commit N\0...committer ")を一度だけフィードしたハッシャーを クローンして再利用することで、毎イテレーションのハッシュ計算を削減。
マッチ発見時に found フラグを立て、同ブロックの他スレッドが 内側ループの先頭でチェックして即リターンするようにした。
Apple M1 の ARMv8 Crypto Extensions を利用する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
7桁以上の指定したハッシュを生成しようとすると少し待ち時間があります。
本 PR でハッシュ計算を高速化したことで git hook に組み込んで常に美しいハッシュにする運用が可能になります。
これでチームから一目置かれる存在になれます!
Implements
rust-crypto 0.2が新しい Rust ツールチェインでビルドできないため、sha1crate 0.10 へ移行しました。あわせて Cargo.lock を最新フォーマット(v4)で再生成し、Flag::usage()が削除された seahorse 1.1.2 を避けるため Cargo.lock で seahorse を 1.0.0 にピン留めしています--benchフラグを追加しましたprefix_hasher()/suffix_bytes())で内側ループの固定部分を事前にフィードし、毎回のフル計算コストを削減しましたAtomicBoolによる早期終了シグナルで、マッチ発見後に他スレッドの無駄なループを抑制するようにしましたsha1crate のasmフィーチャーで ARMv8 Crypto Extensions(ARM ハードウェア SHA1)を有効化しましたBenchmark(Apple M4 Pro、13 スレッド)
※ いずれも
commit_artist --bench -j 13の実測値です。Test plan
cargo build --releaseがエラーなしでビルドできること--bench --jobs Nでハッシュレートが表示されること