From 99a1d495397e64500fcc175c606307fddd059c7f Mon Sep 17 00:00:00 2001 From: shenjack-5600u <3695888@qq.com> Date: Thu, 25 Apr 2024 22:54:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=B8=80=E4=BA=9B=E8=BE=B9?= =?UTF-8?q?=E7=95=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 2 +- bench/tswn.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ miner/Cargo.toml | 2 +- miner/src/name.rs | 35 +++++++++++++++++++++++++++-------- news.md | 13 +++++++++++++ 5 files changed, 88 insertions(+), 10 deletions(-) create mode 100644 bench/tswn.md create mode 100644 news.md diff --git a/Cargo.lock b/Cargo.lock index 354a419..8990716 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1831,7 +1831,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tswn" -version = "0.1.1" +version = "0.1.2" dependencies = [ "base16384", "chrono", diff --git a/bench/tswn.md b/bench/tswn.md new file mode 100644 index 0000000..2116712 --- /dev/null +++ b/bench/tswn.md @@ -0,0 +1,46 @@ +# tswn 效率记录 + +## 0.1.1 + +```text +2024-04-25T14:38:37.928073Z INFO tswn: 输出文件: "./namerena/namerena-shenjacks-2024-04-25_22-38-37.txt" +2024-04-25T14:38:37.928448Z INFO tswn: 开始: 0 结尾: 100000000 +2024-04-25T14:38:37.928527Z INFO tswn: 线程数: 1 +2024-04-25T14:38:37.928582Z INFO tswn: 八围预期: 640 +2024-04-25T14:38:37.928633Z INFO tswn: 队伍名: shenjacks +2024-04-25T14:38:37.928689Z INFO tswn: 输出文件名: "./namerena/namerena-shenjacks-2024-04-25_22-38-37.txt" +2024-04-25T14:38:37.928773Z INFO tswn: 开始计算 +2024-04-25T14:38:37.928857Z INFO tswn: 线程 thread_0 开始计算 +2024-04-25T14:38:37.947371Z INFO tswn::cacluate: | 1|Id: 10000|542408.18/s 468.641E/d 0.02⬆️|0 |预计:0:3:4| +2024-04-25T14:38:48.111355Z INFO tswn::cacluate: | 1|Id: 5434080|533663.84/s 461.086E/d 10.16⬇️|0 |预计:0:2:57| +2024-04-25T14:38:58.566294Z INFO tswn::cacluate: | 1|Id: 10770710|510448.33/s 441.027E/d 10.45⬇️|0 |预计:0:2:54| +2024-04-25T14:39:08.419676Z INFO tswn::cacluate: | 1|Id: 15875190|518062.38/s 447.606E/d 9.85⬆️|0 |预计:0:2:42| +2024-04-25T14:39:18.371574Z INFO tswn::cacluate: | 1|Id: 21055810|520575.43/s 449.777E/d 9.95⬆️|0 |预计:0:2:31| +2024-04-25T14:39:28.277127Z INFO tswn::cacluate: | 1|Id: 26261560|525550.00/s 454.075E/d 9.91⬆️|0 |预计:0:2:20| +2024-04-25T14:39:38.073338Z INFO tswn::cacluate: | 1|Id: 31517060|536495.12/s 463.532E/d 9.80⬆️|0 |预计:0:2:7| +2024-04-25T14:39:48.224642Z INFO tswn::cacluate: | 1|Id: 36882010|528507.78/s 456.631E/d 10.15⬇️|0 |预计:0:1:59| +``` + +## 0.1.2 + +```text +2024-04-25T14:49:18.046424Z INFO tswn: 输出文件: "./namerena/namerena-shenjacks-2024-04-25_22-49-18.txt" +2024-04-25T14:49:18.046647Z INFO tswn: 开始: 0 结尾: 100000000 +2024-04-25T14:49:18.046739Z INFO tswn: 线程数: 1 +2024-04-25T14:49:18.046814Z INFO tswn: 八围预期: 640 +2024-04-25T14:49:18.046888Z INFO tswn: 队伍名: shenjacks +2024-04-25T14:49:18.046961Z INFO tswn: 输出文件名: "./namerena/namerena-shenjacks-2024-04-25_22-49-18.txt" +2024-04-25T14:49:18.047072Z INFO tswn: 开始计算 +2024-04-25T14:49:18.047205Z INFO tswn: 线程 thread_0 开始计算 +2024-04-25T14:49:18.067274Z INFO tswn::cacluate: | 1|Id: 10000|500668.39/s 432.577E/d 0.02⬆️|0 |预计:0:3:19| +2024-04-25T14:49:26.959820Z INFO tswn::cacluate: | 1|Id: 5016680|563031.98/s 486.460E/d 8.89⬆️|0 |预计:0:2:48| +2024-04-25T14:49:37.050652Z INFO tswn::cacluate: | 1|Id: 10646990|557974.03/s 482.090E/d 10.09⬇️|0 |预计:0:2:40| +2024-04-25T14:49:47.117235Z INFO tswn::cacluate: | 1|Id: 16226730|554294.40/s 478.910E/d 10.07⬇️|0 |预计:0:2:31| +2024-04-25T14:49:57.134571Z INFO tswn::cacluate: | 1|Id: 21769670|553354.55/s 478.098E/d 10.02⬇️|0 |预计:0:2:21| +2024-04-25T14:50:07.084869Z INFO tswn::cacluate: | 1|Id: 27303210|556126.12/s 480.493E/d 9.95⬆️|0 |预计:0:2:10| +2024-04-25T14:50:17.165308Z INFO tswn::cacluate: | 1|Id: 32864470|551717.27/s 476.684E/d 10.08⬇️|0 |预计:0:2:1| +2024-04-25T14:50:27.177012Z INFO tswn::cacluate: | 1|Id: 38381640|551097.33/s 476.148E/d 10.01⬇️|0 |预计:0:1:51| +2024-04-25T14:50:37.102177Z INFO tswn::cacluate: | 1|Id: 43892610|555281.37/s 479.763E/d 9.92⬆️|0 |预计:0:1:41| +2024-04-25T14:50:47.147717Z INFO tswn::cacluate: | 1|Id: 49445420|552772.98/s 477.596E/d 10.05⬇️|0 |预计:0:1:31| +2024-04-25T14:50:57.108934Z INFO tswn::cacluate: | 1|Id: 54973140|554932.97/s 479.462E/d 9.96⬆️|0 |预计:0:1:21| +``` diff --git a/miner/Cargo.toml b/miner/Cargo.toml index c61065e..e8bd139 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tswn" description = "tool shenjack work shop namerena" -version = "0.1.1" +version = "0.1.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/miner/src/name.rs b/miner/src/name.rs index a6a41bd..cb9c0e4 100644 --- a/miner/src/name.rs +++ b/miner/src/name.rs @@ -141,7 +141,12 @@ impl Namer { unsafe { val.swap_unchecked(s as usize, 0) }; let mut k = 0; for i in 0..256 { - s = s.wrapping_add(if k == 0 { 0 } else { name_bytes[k - 1] }); + // s = s.wrapping_add(if k == 0 { 0 } else { name_bytes[k - 1] }); + s = s.wrapping_add(if k == 0 { + 0 + } else { + *unsafe { name_bytes.get_unchecked(k - 1) } + }); s = s.wrapping_add(val[i]); unsafe { val.swap_unchecked(i, s as usize) } k = if k == b_name_len - 1 { 0 } else { k + 1 }; @@ -158,25 +163,39 @@ impl Namer { for i in (0..256).step_by(64) { // 一次性加载64个数字 - let mut x = u8x64::from_slice(&simd_val[i..]); + // let mut x = u8x64::from_slice(&simd_val[i..]); + let mut x = u8x64::from_slice(unsafe { simd_val.get_unchecked(i..) }); x = x * simd_181 + simd_160; // 写入到 simd_val - x.copy_to_slice(&mut simd_val[i..]); + // x.copy_to_slice(&mut simd_val[i..]); + unsafe { + x.copy_to_slice(simd_val.get_unchecked_mut(i..)); + } let y = x & simd_63; - y.copy_to_slice(&mut simd_val_b[i..]); + // y.copy_to_slice(&mut simd_val_b[i..]); + unsafe { + y.copy_to_slice(simd_val_b.get_unchecked_mut(i..)); + } } let mut mod_count = 0; for i in 0..96 { - if simd_val[i] > 88 && simd_val[i] < 217 { - // name_base[mod_count as usize] = simd_val_b[i]; - unsafe { + // if simd_val[i] > 88 && simd_val[i] < 217 { + // // name_base[mod_count as usize] = simd_val_b[i]; + // unsafe { + // *name_base.get_unchecked_mut(mod_count as usize) = + // *simd_val_b.get_unchecked(i); + // } + // mod_count += 1; + // } + unsafe { + if simd_val.get_unchecked(i) > &88 && simd_val.get_unchecked(i) < &217 { *name_base.get_unchecked_mut(mod_count as usize) = *simd_val_b.get_unchecked(i); + mod_count += 1; } - mod_count += 1; } if mod_count > 30 { break; diff --git a/news.md b/news.md new file mode 100644 index 0000000..afbf308 --- /dev/null +++ b/news.md @@ -0,0 +1,13 @@ +# 各种"新闻" + +## tswn + +### 0.1.2 + +优化了一些边界检查, 反正就是没用 +`445E/d -> 478E/d` +参考 bench/tswn.md + +### 0.1.1 + +随手发一版