Skip to content

v3.1: accounts-db: Use SmallRng for LRU eviction sampling (backport of #10640)#10644

Merged
steviez merged 2 commits intov3.1from
mergify/bp/v3.1/pr-10640
Feb 19, 2026
Merged

v3.1: accounts-db: Use SmallRng for LRU eviction sampling (backport of #10640)#10644
steviez merged 2 commits intov3.1from
mergify/bp/v3.1/pr-10640

Conversation

@mergify
Copy link

@mergify mergify bot commented Feb 17, 2026

Problem

Sampling is the biggest bottleneck in the eviction mechanism, which with the default Rng takes 82% of the whole eviction process and causes the overall eviction process to take over 20s.

eviction_before_2 eviction_before

Summary of Changes

Optimize it by using SmallRng.

eviction_small_rng eviction_small_rng_2

☝️ The new profiles are still not ideal - the lock contention, previously taking 11% of time, now is the biggest bottleneck taking 91%. But that's going away in #10641.


This is an automatic backport of pull request #10640 done by Mergify.

Sampling is the biggest bottleneck in the eviction mechanism, which
with the default `Rng` takes 82% of the whole eviction process and
causes the overall eviction process to take over 20s.

Optimize it by using `SmallRng`.

(cherry picked from commit 1ffcdcc)

# Conflicts:
#	accounts-db/src/read_only_accounts_cache.rs
@mergify mergify bot requested a review from a team as a code owner February 17, 2026 19:10
@mergify mergify bot added the conflicts label Feb 17, 2026
@mergify
Copy link
Author

mergify bot commented Feb 17, 2026

Cherry-pick of 1ffcdcc has failed:

On branch mergify/bp/v3.1/pr-10640
Your branch is up to date with 'origin/v3.1'.

You are currently cherry-picking commit 1ffcdcc60.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   accounts-db/src/read_only_accounts_cache.rs

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@t-nelson
Copy link

@vadorovsky mind resolving merge conflicts here?

@vadorovsky vadorovsky force-pushed the mergify/bp/v3.1/pr-10640 branch from bb4800e to 645b8f3 Compare February 18, 2026 17:44
@vadorovsky
Copy link
Member

vadorovsky commented Feb 18, 2026

@vadorovsky mind resolving merge conflicts here?

Done. To elaborate on what I had to fix, the ctor for an RNG seeded from getrandom has different names in different rand_core versions.

In rand_core-0.6.4 it's called SeedableRng::from_entropy and looks like:

https://github.com/rust-random/rand_core/blob/89a1336b934c68ddce548127c6f8afd910b35a18/rand_core/src/lib.rs#L410-L418Th

In rand_core-0.9.3 it's called SeedableRng::from_os_rng with the following definition:

https://github.com/rust-random/rand_core/blob/2d84d25c45a68c1424e4fa775d8a527dc16cec65/src/lib.rs#L554-L577

I don't want that info to get lost - is it fine if after approval, before merging the PR, I squash the commits and add the info on the bottom of the commit message?

The constructor for an RNG seeded from `getrandom` has different names
in different `rand_core` versions.

In `rand_core-0.6.4` it's called SeedableRng::from_entropy`.[0][1]
In `rand_core-0.9.3` it's called `SeedableRng::from_os_rng`.[2][3]

Furthermore, `SmallRng` in `rand-0.8.5` is hidden behind `small_rng`
feature.

[0] https://docs.rs/rand_core/0.6.4/rand_core/trait.SeedableRng.html#method.from_entropy
[1] https://github.com/rust-random/rand_core/blob/89a1336b934c68ddce548127c6f8afd910b35a18/rand_core/src/lib.rs#L410-L418Th
[2] https://docs.rs/rand_core/0.9.3/rand_core/trait.SeedableRng.html#method.from_os_rng
[3] https://github.com/rust-random/rand_core/blob/2d84d25c45a68c1424e4fa775d8a527dc16cec65/src/lib.rs#L554-L577
@vadorovsky vadorovsky force-pushed the mergify/bp/v3.1/pr-10640 branch from 645b8f3 to cc69c00 Compare February 18, 2026 17:48
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.2%. Comparing base (01a77c7) to head (cc69c00).

Additional details and impacted files
@@            Coverage Diff            @@
##             v3.1   #10644     +/-   ##
=========================================
- Coverage    83.2%    83.2%   -0.1%     
=========================================
  Files         865      865             
  Lines      376601   376601             
=========================================
- Hits       313609   313550     -59     
- Misses      62992    63051     +59     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@steviez
Copy link

steviez commented Feb 19, 2026

I don't want that info to get lost - is it fine if after approval, before merging the PR, I squash the commits and add the info on the bottom of the commit message?

I'm going to merge this but will ensure this information is retained; looks like your additional commit had good information that will leave us a nice papertrail

@steviez steviez merged commit 7018f4a into v3.1 Feb 19, 2026
44 checks passed
@steviez steviez deleted the mergify/bp/v3.1/pr-10640 branch February 19, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants