mirror of
https://github.com/deepseek-ai/3FS.git
synced 2026-11-05 00:47:47 +00:00
[GH-ISSUE #368] Non-deterministic chain shuffling across different libstdc++ versions #223
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/3FS#223
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yiyuanliu on GitHub (Dec 26, 2025).
Original GitHub issue: https://github.com/deepseek-ai/3FS/issues/368
When creating files, 3FS allocates chains for the file based on stripe size and stores data chunks on these chains. 3FS selects a contiguous range of chains from the chain table, then shuffles them for more even data distribution. File metadata stores the chain table id/version, the chain range for the file, and the random seed used for shuffling. Clients need to perform the shuffle themselves to obtain the final chain list.
Currently, 3FS directly uses
std::shuffle, which depends on the specific implementation of the standard library (libstdc++). There were some changes in random number generation starting fromg++11link, so given the same random seed,g++10andg++11(or later versions) may produce different results.Whether
g++10andg++11+produce the same result for a given array length and shuffle seed is probabilistic, and the probability of difference increases with array length (stripe size):stripe_size=50: almost always identical (tested 900 billion seeds, all results matched betweeng++10andg++11)stripe_size=100: 12 mismatches out of 900 billion seeds testedstripe_size=200: approximately 1 in 2.8 billion chance of mismatchstripe_size=20000: nearly every seed produces different results between g++10 and g++11+Impact: If binaries compiled with different
g++/libstdc++versions are mixed in the same cluster, data corruption may occur. The probability of this issue increases with stripe size.Required fixes:
std::shuffleand implement a fixed shuffle algorithm that is not affected byg++versiong++10org++11selectable at compile time.g++10andg++11g++10andg++11, for users who have unfortunately mixedg++10andg++11+binaries in their deployment@yiyuanliu commented on GitHub (Dec 26, 2025):
Fixed in #369
Changes:
Added compile option
SHUFFLE_METHODwith possible values:g++10,g++11, orstdshuffle(not recommended). Theg++11option is compatible withg++11and later versions. You need to manually specifycmake -DSHUFFLE_METHOD='...'when compiling.g++10org++11based on the compiler version used when deploying that cluster.g++10org++11, but please note that you need to keep using the same configuration afterwards.When creating files, 3FS meta now searches for a random seed that produces the same result on both
g++10andg++11. Since file stripe sizes are generally small, it is very easy to find a qualifying random seed.Checking for affected files in mixed-version deployments:
If you have mixed
g++10andg++11binaries in a cluster, you can check whether any files have shuffle seeds that produce different results under different compilers: