Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #315: JTest uses a flawed RNG setup #347

Merged
merged 5 commits into from
Sep 11, 2024

Conversation

RaiqaRasool
Copy link
Collaborator

Summary:
This PR addresses issue #315 by replacing JPerfUtils with JBenchUtils, transitioning from standalone functions to a class-based format. The seed for the RNG is now set inside the JBenchUtils constructor using the event number and caller name passed to the constructor.

Changes:

  • Replaced all instances of JPerfUtils with JBenchUtils.
  • JBenchUtils is now a class that encapsulates the RNG.
  • The RNG seed is initialized in the JBenchUtils constructor, ensuring it is set based on the event number and caller name, enhancing reproducibility and eliminating the need for the previous thread-local workaround.

Benefits:

  • Resolves ASAN errors that were caused by the thread-local pointer to RNG in JPerfUtils.
  • Simplifies the RNG initialization process, making the codebase cleaner and more maintainable.
  • Ensures compatibility with the Alma9 migration, removing the outdated workaround for gcc 4.8.5.

Related Issue:

Testing:

  • Verified that the RNG behaves as expected in all test cases

… and caller name based seed inside constructor (Fixes #315)
@RaiqaRasool RaiqaRasool force-pushed the rasool_issue315SeedRNGFix branch from 67719cc to 002aeae Compare August 22, 2024 13:47
@@ -26,8 +26,9 @@ class GroupedEventProcessor : public JEventProcessor {

void Process(const std::shared_ptr<const JEvent>& event) override {

std::unique_ptr<JBenchUtils> bench_utils = std::make_unique<JBenchUtils>(event->GetEventNumber(), NAME_OF_THIS);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The constructor for JBenchUtils might be expensive, so I'd consider adding a method to reset the seed rather than recreating the object on every event. If you make bench_utils be a member variable, you can construct it exactly once and then reset the seed on every event. Also, you don't need the unique_ptr here because ownership stays with the component and there's no inheritance hierarchy to watch out for.

@nathanwbrei nathanwbrei merged commit e1d4745 into master Sep 11, 2024
9 checks passed
@nathanwbrei nathanwbrei deleted the rasool_issue315SeedRNGFix branch September 11, 2024 19:01
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.

JTest uses a flawed RNG setup
2 participants