Commit Graph

30 Commits

Author SHA1 Message Date
Pierce Lopez 49bd7f489c
64-bit DeterministicRandom() seed and getRandomSeed() (#13136)
DeterministicRandom() can use a boost::random::mt19937_64
to take a 64-bit seed and return 64-bit random values,
and this simplifies things because fdb always wants 64 bits.
Performance should be slightly better because the 32-bit
mt19937 was always called twice to get 64 bits.
2026-05-07 19:28:19 -04:00
Jingyu Zhou a21537e779
Bug probability graph (#12646)
* Add --reseed-time option to reset random seed during simulation

Adds a new command line option --reseed-time that allows resetting the
deterministic random seed at a random time during simulation. When
provided with a time value (e.g., 100), the simulator will reset the
random seed to a truly random value at a random time between [0, time].

This feature enables testing different execution paths from the same
initial simulation state while maintaining determinism up to the reset
point.

Changes:
- Add resetSeed() method to IRandom interface with default no-op implementation
- Implement resetSeed() in DeterministicRandom class to reinitialize RNG
- Add --reseed-time command line option to fdbserver
- Add reseedTime parameter to simulationSetupAndRun()
- Add reseedRandomAtTime() actor to schedule seed reset
- Use platform::getRandomSeed() for truly random new seed value

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* TestHarness2: Add support for running tests from argument file

This commit adds the ability to run specific tests with predefined
parameters by passing an argument file to TestHarness2. This is useful
for reproducing specific test failures or running tests with exact
configurations.

Changes:
- Added --test-args-file option to config.py
- Implemented parse_test_args_file() to parse argument files containing
  test parameters in the format:
  '-f fast/CycleTest.toml -s 315315 -b off --reseed-time 100'
- Modified TestRun to accept and forward extra_args to fdbserver
- Modified TestRunner.run_tests() to:
  * Accept extra_args and override_buggify parameters
  * Skip test statistics tracking when running from args file
  * Forward all unrecognized arguments to fdbserver command line
- Added example_test_args.txt demonstrating the format

The track_stats parameter prevents assertion failures when the specified
test is not in the test_picker's dictionary (which happens when running
a specific test that may not match the configured filters).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Joshua: Support test_args.txt file for reproducing specific test runs

Modified correctnessTest.sh to automatically detect and use test_args.txt
file if present in the working directory. This enables easy reproduction of
specific test failures in Joshua by simply including a test_args.txt file
with the test parameters.

When test_args.txt exists, the script passes --test-args-file option to
TestHarness2, which will run the specific test with the exact parameters
specified in the file instead of randomly selecting a test.

Example test_args.txt content:
-f tests/fast/CycleTest.toml -s 315315 -b off --reseed-time 100

This allows developers to reproduce simulation test failures by copying
the exact test parameters from Joshua logs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* CMake: Optionally include test_args.txt in correctness package

Modified create_correctness_package() to automatically include test_args.txt
in the correctness tarball if it exists in the source directory at CMake
configuration time.

This allows developers to create reproducible test packages by:
1. Creating test_args.txt in the source root with specific test parameters
   (e.g., '-f tests/fast/CycleTest.toml -s 315315 -b off --reseed-time 100')
2. Running cmake to reconfigure
3. Running ninja package_tests to build the package

When the package is extracted and run in Joshua, correctnessTest.sh will
automatically detect test_args.txt and run the specific test instead of
randomly selecting one.

If test_args.txt doesn't exist, the package is built normally without it,
maintaining backward compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* TestHarness2: Disable determinism check when using test_args_file

Modified run_tests() to skip the unseed mismatch (determinism) check when
running tests from test_args.txt file. The determinism check now requires
track_stats=True, which means it only runs during normal random test
selection, not when running specific tests via --test-args-file.

Rationale:
- When reproducing a specific test failure via test_args.txt, users want to
  run that exact test configuration once, not have it randomly run twice
- The determinism check adds overhead and complexity that isn't needed for
  reproduction scenarios
- The check uses config.random which would make reproduction less predictable

This change makes test_args.txt behavior more focused and predictable for
debugging and reproduction workflows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* TestHarness2: Include ResettingRandomSeed events in test output

Added a handler for ResettingRandomSeed trace events to include them in
the test summary output. This makes random seed reset operations visible
in Joshua logs and test results.

The handler captures:
- NewSeed: The new random seed value
- Time: Simulation time when the reset occurred

This is particularly useful when debugging tests that use --reseed-time
option, as it provides visibility into when and how the random seed was
changed during the test run.

Example output:
<ResettingRandomSeed NewSeed="67890" Time="100.5"/>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Use non-deterministic random for reseed time

To truly randomize the seed reset time.

* clang-format fix

* Address review comments

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 14:53:38 -08:00
Jingyu Zhou 2d2a2144f4
Update copyright years to 2013-2026 (#12653)
No functional changes.
2026-01-22 10:49:41 -08:00
Syed Paymaan Raza a149a509c7
Add comment to /flow/DeterministicRandom/truePercent explaining the stats/math behind the test (#12462) 2025-10-14 20:04:22 -07:00
Syed Paymaan Raza d29d623e3e
Fix failure in unit test /flow/DeterministicRandom/truePercent (#12458) 2025-10-14 13:23:13 -07:00
Syed Paymaan Raza 05d36e167d
5s: fuzz read knob value in simulation (#12440) 2025-10-13 10:35:12 -07:00
gxglass a3a352ca0c
Increase determinism in DeterministicRandom::gen64() (#12266)
* Increase determinism in DeterministicRandom::gen64() by not making output
dependent on unspecified order of execution of arguments to the ^ operator.

Also, rename the member previously known as `random` to `rng`, as `random` is a
C library function.

* DeterministicRandom: use `boost::random::mt19937` for rng repeatability
2025-07-23 01:05:28 -07:00
Syed Paymaan Raza c3e7542cda Update end year in copyright header 2024-08-02 09:40:11 -07:00
A.J. Beamon 3e9b6ce937 Don't disallow a seed value of 0 2022-12-02 15:32:34 -08:00
Xiaoxi Wang e8e6f47e09 format code 2022-10-15 22:52:43 -07:00
Xiaoxi Wang 737350cc47 setShardStatus (not tested yet) 2022-10-15 22:52:42 -07:00
Junhyun Shim 3cf0914ce0 Fix incorrect parenthesis 2022-08-12 13:52:50 +02:00
Junhyun Shim 312d3da040 Merge remote-tracking branch 'origin/main' into fix-skewed-u32-out-of-range 2022-08-12 13:01:43 +02:00
Junhyun Shim e57d3a6f9b Address review comments 2022-08-12 10:24:23 +02:00
Junhyun Shim 742b73028c Fix incorrect range in randomSkewedUInt32()
Currently it invokes pow(10, uniform_rand(log_e(range_begin), log_e(range_end))),
which may overflow beyond UINT32_MAX.
Fix it by preventing log_e(0) case and change pow base to M_E
2022-07-24 23:02:48 +02:00
Junhyun Shim 0874e553cd Place generateRandomData() under {I|Deterministic}Random 2022-07-20 13:21:11 +02:00
Markus Pilman d35445a868 enforce include modularization in cmake 2022-06-23 14:37:35 -06:00
sfc-gh-tclinkenbeard a71099471b Update copyright header dates 2022-03-21 13:36:23 -07:00
Jingyu Zhou 1a5bf25b5c Update code base to use fmt 8.1.1 2022-03-04 15:52:06 -08:00
sfc-gh-tclinkenbeard ec64890ac1 Remove some usages of PRId64 by using fmt library 2021-11-30 23:35:36 -08:00
Steve Atherton 507c1f11e3 Add .log() to bare TraceEvent() invocations without any .detail()s to avoid clang-tidy warning about immediate destruction of object without use. 2021-07-26 19:55:10 -07:00
sfc-gh-tclinkenbeard a33a0a7fff Add include to DeterministicRandom.cpp 2021-06-28 14:50:35 -07:00
FDB Formatster df90cc89de apply clang-format to *.c, *.cpp, *.h, *.hpp files 2021-03-10 10:18:07 -08:00
Lukas Joswiak 3669615e4b Refactor and clean up 2020-12-03 14:06:11 -08:00
sfc-gh-tclinkenbeard bcda617b80 Benchmark hashing algorithms in flowbench 2020-11-17 23:14:55 -08:00
Andrew Noyes 78b202f3a4 Apply A.J.'s suggestion to randomInt as well 2019-12-05 11:01:41 -08:00
Andrew Noyes cf5cdc4e93
Update flow/DeterministicRandom.cpp
Include equality now that we've adjusted the value by 1.

Co-Authored-By: A.J. Beamon <ajbeamon@users.noreply.github.com>
2019-12-05 11:01:03 -08:00
Andrew Noyes b09f0b334b Take A.J.'s suggestion, which fixes A.J.s counterexample 2019-12-05 10:27:35 -08:00
Andrew Noyes 89a093e035 Accept UBSAN's suggestion
/home/anoyes/workspace/foundationdb/flow/DeterministicRandom.cpp:72:29: runtime error: negation of -9223372036854775808 cannot be represented in type 'long int'; cast to an unsigned type to negate this value to itself
2019-12-04 16:45:45 -08:00
Andrew Noyes 4f943be21d Move DeterministicRandom impl to its own translation unit
This will allow me to recompile faster after making changes, and should
(slightly) speed up overall compilation.

I manually verified that the unseed matched for one test before and
after this change, so I probably didn't screw up the refactor
2019-12-04 16:45:32 -08:00