Skip to content

properly initialize seed for RandomEviction cache#4936

Merged
SirTyson merged 1 commit intostellar:masterfrom
SirTyson:eviction-cache-seed-fix
Sep 23, 2025
Merged

properly initialize seed for RandomEviction cache#4936
SirTyson merged 1 commit intostellar:masterfrom
SirTyson:eviction-cache-seed-fix

Conversation

@SirTyson
Copy link
Contributor

Description

Fixes a bug where the RandomEvictionCache seed was not properly set.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

@SirTyson SirTyson requested review from Copilot and graydon September 23, 2025 00:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the RandomEvictionCache where the seed for random number generation was not properly initialized. The fix ensures thread-safe random number generation by providing each cache instance with its own seeded random number generator.

  • Introduces a static global seed variable randomEvictionCacheSeed for thread-safe PRNG initialization
  • Updates the cache constructor to initialize the random engine with the global seed
  • Ensures the seed is properly reset in the global state reinitialization function

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/util/RandomEvictionCache.h Adds static seed variable and updates constructor to initialize random engine with seed
src/util/Math.cpp Updates global state reinitialization to properly set the RandomEvictionCache seed

@SirTyson SirTyson enabled auto-merge September 23, 2025 00:34
@SirTyson SirTyson added this pull request to the merge queue Sep 23, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 23, 2025
@SirTyson SirTyson added this pull request to the merge queue Sep 23, 2025
Merged via the queue into stellar:master with commit 43e511c Sep 23, 2025
18 checks passed
@SirTyson SirTyson deleted the eviction-cache-seed-fix branch September 23, 2025 18:23
Sign up for free to 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.

3 participants