wireguard-vanity-address: allow running forever, pin to physical cores

This commit is contained in:
psykose 2022-04-29 11:16:42 +00:00
parent 0ccbff29b0
commit 136c459800
Signed by: psykose
SSH key fingerprint: SHA256:HwlGVJNLZqHoOvMtkshyGaXLkcdbEJahYMlepHFL+Uk
2 changed files with 33 additions and 1 deletions

View file

@ -3,7 +3,7 @@
pkgname=wireguard-vanity-address pkgname=wireguard-vanity-address
pkgver=0.4.0_git20200327 pkgver=0.4.0_git20200327
_gitrev=d36eeac325ba3f27111ef4b17d171e695ff75552 _gitrev=d36eeac325ba3f27111ef4b17d171e695ff75552
pkgrel=2 pkgrel=3
pkgdesc="generate Wireguard keypairs with a given prefix string" pkgdesc="generate Wireguard keypairs with a given prefix string"
url="https://github.com/warner/wireguard-vanity-address" url="https://github.com/warner/wireguard-vanity-address"
arch="all" arch="all"
@ -15,6 +15,7 @@ source="https://github.com/warner/wireguard-vanity-address/archive/$_gitrev/wire
0003-update-benchmarks-to-new-scheme.patch 0003-update-benchmarks-to-new-scheme.patch
0004-lowercase-lol.patch 0004-lowercase-lol.patch
0005-sync-deps.patch 0005-sync-deps.patch
infinite.patch
" "
builddir="$srcdir/$pkgname-$_gitrev" builddir="$srcdir/$pkgname-$_gitrev"
options="!check" # no tests options="!check" # no tests
@ -46,4 +47,5 @@ a00d7241819bda4adb0c2233f26908798a7087171a975dcc442e7b090a3d038564bf3ec9629312f5
d81318fa5810223601d72923bc251bea08c13b850add03483cd09910eadbd2a89c0cdf48eef6e4c68c41d8ab2e3d8ad22ca6e695ed54f08cf63eccc2d5ee64d4 0003-update-benchmarks-to-new-scheme.patch d81318fa5810223601d72923bc251bea08c13b850add03483cd09910eadbd2a89c0cdf48eef6e4c68c41d8ab2e3d8ad22ca6e695ed54f08cf63eccc2d5ee64d4 0003-update-benchmarks-to-new-scheme.patch
359f7ff6a90882aea8f4fc08f9e4d13c73b1e1ee927dfa5d0ffd4189c9b365887ca4582082b94036582a04037ea92dd36d12886001f224428b262d462427af75 0004-lowercase-lol.patch 359f7ff6a90882aea8f4fc08f9e4d13c73b1e1ee927dfa5d0ffd4189c9b365887ca4582082b94036582a04037ea92dd36d12886001f224428b262d462427af75 0004-lowercase-lol.patch
de0629aa7fb5bee82ef1da4fe0e7e6f2eaa8bb932f793cb72199531c09fdc5536d7bc5a16fe1210b7e1e03206dd51176621cdb1e27866c7afe59b8b05eb68651 0005-sync-deps.patch de0629aa7fb5bee82ef1da4fe0e7e6f2eaa8bb932f793cb72199531c09fdc5536d7bc5a16fe1210b7e1e03206dd51176621cdb1e27866c7afe59b8b05eb68651 0005-sync-deps.patch
5567019ad52fb87ba7136f62c97a6345cd496513d5b19dc10c37ad7d7d095a1457f44a9a5d39d38a68d23c8fe0e70b6ac4d6cc691b001f56874238faa6209b61 infinite.patch
" "

View file

@ -0,0 +1,30 @@
--- a/src/bin.rs
+++ b/src/bin.rs
@@ -121,13 +121,15 @@
// get_physical() appears to be more accurate: hyperthreading doesn't
// help us much
+ let cpus = num_cpus::get_physical();
+ rayon::ThreadPoolBuilder::new().num_threads(cpus).build_global().unwrap();
if trials_per_key < 2u64.pow(32) {
let raw_rate = measure_rate();
println!(
"one core runs at {}, CPU cores available: {}",
format_rate(raw_rate),
- num_cpus::get_physical(),
+ cpus,
);
let total_rate = raw_rate * (num_cpus::get_physical() as f64) / (trials_per_key as f64);
let seconds_per_key = 1.0 / total_rate;
@@ -140,9 +142,7 @@
println!("hit Ctrl-C to stop");
- // 1M trials takes about 10s on my laptop, so let it run for 1000s
- (0..100_000_000)
- .into_par_iter()
+ rayon::iter::repeat(0)
.map(|_| search_for_prefix(&prefix, 0, end))
.try_for_each(print)?;
Ok(())