') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Remove rand_chacha by dhardy · Pull Request #1658 · rust-random/rand · GitHub
Skip to content

Remove rand_chacha - #1658

Merged
dhardy merged 2 commits into
masterfrom
push-pxkturstssxs
Jan 23, 2026
Merged

Remove rand_chacha#1658
dhardy merged 2 commits into
masterfrom
push-pxkturstssxs

Conversation

@dhardy

Copy link
Copy Markdown
Member

Summary

Source moved: rust-random/rngs#68

@dhardy

Copy link
Copy Markdown
MemberAuthor

A quick benchmark run shows no very significant changes (the bar of "significant" being fairly high due to unpinned CPU freq.).

Benchmark
$ cargo bench -- chacha
Compiling rand_pcg v0.9.0 (/home/dhardy/projects/rand/rand/rand_pcg)
Compiling rand v0.9.2 (/home/dhardy/projects/rand/rand)
Compiling benches v0.1.0 (/home/dhardy/projects/rand/rand/benches)
Finished `bench` profile [optimized] target(s) in 5.97s
Running benches/array.rs (/home/dhardy-extra/.cache/cargo-build/release/deps/array-af84aee0fd253b08)
Running benches/bool.rs (/home/dhardy-extra/.cache/cargo-build/release/deps/bool-0b6ead89b6d1c550)
Running benches/generators.rs (/home/dhardy-extra/.cache/cargo-build/release/deps/generators-827c3b4b67548787)
random_bytes/chacha8 time: [245.77 ns 246.39 ns 246.93 ns]
thrpt: [3.8622 GiB/s 3.8706 GiB/s 3.8804 GiB/s]
change:
time: [-0.2241% +0.6495% +1.5004%] (p = 0.14 > 0.05)
thrpt: [-1.4782% -0.6453% +0.2246%]
No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) high mild
1 (1.00%) high severe
random_bytes/chacha12 time: [332.48 ns 332.90 ns 333.31 ns]
thrpt: [2.8612 GiB/s 2.8648 GiB/s 2.8683 GiB/s]
change:
time: [+8.0156% +8.6076% +9.1503%] (p = 0.00 < 0.05)
thrpt: [-8.3832% -7.9254% -7.4208%]
Performance has regressed.
Found 9 outliers among 100 measurements (9.00%)
3 (3.00%) low mild
3 (3.00%) high mild
3 (3.00%) high severe
random_bytes/chacha20 time: [444.71 ns 446.35 ns 448.80 ns]
thrpt: [2.1250 GiB/s 2.1366 GiB/s 2.1445 GiB/s]
change:
time: [-1.7830% -1.1872% -0.5086%] (p = 0.00 < 0.05)
thrpt: [+0.5112% +1.2015% +1.8154%]
Change within noise threshold.
Found 11 outliers among 100 measurements (11.00%)
2 (2.00%) low mild
5 (5.00%) high mild
4 (4.00%) high severe
random_u32/chacha8 time: [957.66 ps 960.68 ps 963.89 ps]
thrpt: [3.8649 GiB/s 3.8778 GiB/s 3.8900 GiB/s]
change:
time: [+1.4652% +1.9002% +2.3720%] (p = 0.00 < 0.05)
thrpt: [-2.3170% -1.8648% -1.4441%]
Performance has regressed.
Found 130 outliers among 1000 measurements (13.00%)
22 (2.20%) high mild
108 (10.80%) high severe
random_u32/chacha12 time: [1.2200 ns 1.2247 ns 1.2297 ns]
thrpt: [3.0295 GiB/s 3.0417 GiB/s 3.0534 GiB/s]
change:
time: [-2.5279% -2.0627% -1.5850%] (p = 0.00 < 0.05)
thrpt: [+1.6106% +2.1062% +2.5934%]
Performance has improved.
Found 148 outliers among 1000 measurements (14.80%)
67 (6.70%) high mild
81 (8.10%) high severe
random_u32/chacha20 time: [1.6805 ns 1.6823 ns 1.6842 ns]
thrpt: [2.2119 GiB/s 2.2144 GiB/s 2.2168 GiB/s]
change:
time: [-5.2598% -4.9730% -4.6967%] (p = 0.00 < 0.05)
thrpt: [+4.9281% +5.2333% +5.5518%]
Performance has improved.
Found 59 outliers among 1000 measurements (5.90%)
23 (2.30%) high mild
36 (3.60%) high severe
random_u64/chacha8 time: [1.3738 ns 1.3767 ns 1.3798 ns]
thrpt: [5.3998 GiB/s 5.4119 GiB/s 5.4234 GiB/s]
change:
time: [-5.2813% -4.8917% -4.5020%] (p = 0.00 < 0.05)
thrpt: [+4.7143% +5.1433% +5.5758%]
Performance has improved.
Found 118 outliers among 1000 measurements (11.80%)
4 (0.40%) low mild
49 (4.90%) high mild
65 (6.50%) high severe
random_u64/chacha12 time: [1.9632 ns 1.9750 ns 1.9872 ns]
thrpt: [3.7494 GiB/s 3.7725 GiB/s 3.7951 GiB/s]
change:
time: [-2.9714% -2.3478% -1.7632%] (p = 0.00 < 0.05)
thrpt: [+1.7949% +2.4042% +3.0624%]
Performance has improved.
Found 130 outliers among 1000 measurements (13.00%)
1 (0.10%) low mild
19 (1.90%) high mild
110 (11.00%) high severe
random_u64/chacha20 time: [2.8760 ns 2.8866 ns 2.8979 ns]
thrpt: [2.5711 GiB/s 2.5811 GiB/s 2.5906 GiB/s]
change:
time: [-8.6350% -8.1851% -7.7253%] (p = 0.00 < 0.05)
thrpt: [+8.3720% +8.9148% +9.4511%]
Performance has improved.
Found 140 outliers among 1000 measurements (14.00%)
45 (4.50%) high mild
95 (9.50%) high severe
init_gen/chacha8 time: [32.132 ns 32.186 ns 32.247 ns]
change: [+0.6341% +1.2175% +1.8555%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
3 (3.00%) high mild
2 (2.00%) high severe
init_gen/chacha12 time: [31.814 ns 32.010 ns 32.260 ns]
change: [-0.8760% +0.0020% +0.7705%] (p = 1.00 > 0.05)
No change in performance detected.
Found 11 outliers among 100 measurements (11.00%)
4 (4.00%) high mild
7 (7.00%) high severe
init_gen/chacha20 time: [32.064 ns 32.110 ns 32.161 ns]
change: [-3.6865% -2.5900% -1.5765%] (p = 0.00 < 0.05)
Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
5 (5.00%) low mild
2 (2.00%) high mild
3 (3.00%) high severe
init_from_u64/chacha8 time: [41.519 ns 41.628 ns 41.731 ns]
change: [-4.8846% -4.5025% -4.0995%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild
init_from_u64/chacha12 time: [41.760 ns 41.833 ns 41.911 ns]
change: [-5.0056% -4.5781% -4.1155%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) high mild
2 (2.00%) high severe
init_from_u64/chacha20 time: [40.997 ns 41.045 ns 41.101 ns]
change: [-9.1845% -8.4379% -7.7492%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
6 (6.00%) high mild
init_from_seed/chacha8 time: [32.865 ns 32.930 ns 33.009 ns]
change: [+7.3252% +7.8271% +8.3239%] (p = 0.00 < 0.05)
Performance has regressed.
init_from_seed/chacha12 time: [33.311 ns 33.357 ns 33.401 ns]
change: [+6.7469% +7.5707% +8.3332%] (p = 0.00 < 0.05)
Performance has regressed.
Found 6 outliers among 100 measurements (6.00%)
3 (3.00%) low mild
2 (2.00%) high mild
1 (1.00%) high severe
init_from_seed/chacha20 time: [33.337 ns 33.615 ns 33.924 ns]
change: [+6.3530% +7.5427% +8.6519%] (p = 0.00 < 0.05)
Performance has regressed.
Found 8 outliers among 100 measurements (8.00%)
3 (3.00%) high mild
5 (5.00%) high severe
reseeding_bytes/chacha20_4k
time: [395.08 µs 396.10 µs 397.30 µs]
thrpt: [2.4580 GiB/s 2.4654 GiB/s 2.4718 GiB/s]
change:
time: [-5.1210% -4.2470% -3.3999%] (p = 0.00 < 0.05)
thrpt: [+3.5195% +4.4353% +5.3975%]
Performance has improved.
Found 19 outliers among 100 measurements (19.00%)
3 (3.00%) low severe
7 (7.00%) low mild
3 (3.00%) high mild
6 (6.00%) high severe
reseeding_bytes/chacha20_16k
time: [380.01 µs 380.82 µs 381.78 µs]
thrpt: [2.5579 GiB/s 2.5644 GiB/s 2.5698 GiB/s]
change:
time: [-0.3435% +0.0662% +0.5591%] (p = 0.77 > 0.05)
thrpt: [-0.5560% -0.0661% +0.3447%]
No change in performance detected.
Found 12 outliers among 100 measurements (12.00%)
1 (1.00%) low mild
6 (6.00%) high mild
5 (5.00%) high severe
reseeding_bytes/chacha20_32k
time: [377.20 µs 377.86 µs 378.63 µs]
thrpt: [2.5792 GiB/s 2.5844 GiB/s 2.5890 GiB/s]
change:
time: [-1.9226% -1.2419% -0.4789%] (p = 0.00 < 0.05)
thrpt: [+0.4812% +1.2575% +1.9603%]
Change within noise threshold.
Found 23 outliers among 100 measurements (23.00%)
1 (1.00%) low severe
1 (1.00%) low mild
9 (9.00%) high mild
12 (12.00%) high severe
reseeding_bytes/chacha20_64k
time: [377.04 µs 378.48 µs 379.98 µs]
thrpt: [2.5700 GiB/s 2.5803 GiB/s 2.5901 GiB/s]
change:
time: [-0.3950% +0.1281% +0.6287%] (p = 0.62 > 0.05)
thrpt: [-0.6248% -0.1279% +0.3965%]
No change in performance detected.
Found 12 outliers among 100 measurements (12.00%)
8 (8.00%) high mild
4 (4.00%) high severe
reseeding_bytes/chacha20_256k
time: [373.82 µs 375.39 µs 376.93 µs]
thrpt: [2.5908 GiB/s 2.6014 GiB/s 2.6124 GiB/s]
change:
time: [-2.3042% -1.5835% -0.7933%] (p = 0.00 < 0.05)
thrpt: [+0.7996% +1.6090% +2.3585%]
Change within noise threshold.
Found 13 outliers among 100 measurements (13.00%)
8 (8.00%) high mild
5 (5.00%) high severe
reseeding_bytes/chacha20_1024k
time: [376.31 µs 377.46 µs 378.89 µs]
thrpt: [2.5774 GiB/s 2.5872 GiB/s 2.5951 GiB/s]
change:
time: [-1.3651% -0.8050% -0.2695%] (p = 0.00 < 0.05)
thrpt: [+0.2702% +0.8116% +1.3840%]
Change within noise threshold.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild

@dhardy

Copy link
Copy Markdown
MemberAuthor

It may make sense to hold off merging this for a while. It conflicts with #1659.

@newpavlov

Copy link
Copy Markdown
Member

5-10% of performance drop is a bit too much for noise even with unpinned frequency considering that criterion does a proper CPU warm-up. I will try to take a closer look at the RNG implementation later.

@dhardy

Copy link
Copy Markdown
MemberAuthor

Time

0.65%
8.61%
−1.19%
1.90%
−2.06%
−4.97%
−4.89%
−2.35%
−8.19%
1.22%
0.00%
−2.59%
−4.50%
−4.58%
−8.44%
7.83%
7.54%
−4.25%
0.07%
0.13%
−1.58%
−0.80%
Average
−1.02%

@dhardy

Copy link
Copy Markdown
MemberAuthor

@hpennereported the new ChaCha impls have doubled perf. on Apple M1.

@newpavlovnewpavlov mentioned this pull request Nov 19, 2025
@dhardy

Copy link
Copy Markdown
MemberAuthor

Updated.

We've been depending on chacha20 for a while now; I no longer see a reason to maintain rand_chacha.

@vks

vks commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

Before removing it, should we make a final release updating the README to say it's deprecated?

@dhardy

Copy link
Copy Markdown
MemberAuthor

Should we mark it as deprecated? Certainly not now (no final release of chacha20 yet).

Later? I don't see much point since it won't be compatible with the next rand_core version. Also, I don't see any need to force people to migrate (no known security issues or other major problems).

So I feel that we shouldn't.

@tarcieri

Copy link
Copy Markdown
Contributor

So it's just being migrated to a different repo then, right?

@newpavlov

Copy link
Copy Markdown
Member

I think we can move rand_chacha to the rngs repo and release v0.10 with the new rand_core. Next, after chacha20 is released and assuming there are no problems with it, we can release empty rand_chacha v0.11 with suggestion to migrate to chacha20, thus effectively deprecating rand_chacha. Those who track outdated dependencies will migrate, those who don't care will stay on v0.10.

@dhardydhardy mentioned this pull request Jan 23, 2026
@dhardy
dhardy merged commit 8ee82f4 into masterJan 23, 2026
16 checks passed
@dhardy
dhardy deleted the push-pxkturstssxs branch January 23, 2026 08:16
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@dhardy@newpavlov@vks@tarcieri