Skip to content
Home » News » revolution 4.60 230126

revolution 4.60 230126

revolution 4.60 230126

Motivation

  • Prevent non-deterministic PGO binaries caused by invocation-dependent std::hash and ad-hoc name formatting, by replacing salted/implementation-defined string hashing and std::to_string based name construction with a stable hashing and formatting approach.
  • Ensure shared memory names, sentinels and NUMA discriminators are stable across runs so identical inputs produce identical identifiers and PGO profiles.

Description

  • Add a stable string hash helper hash_string(std::string_view) (FNV-1a 64-bit) in src/misc.h and use it for raw-data hashing via get_raw_data_hash and for FixedString hashing by updating std::hash<Stockfish::FixedString<N>> to call Stockfish::hash_string.
  • Replace uses of std::hash<std::string> for shared-memory name/sentinel generation with hash_string and switch the shared-memory name assembly to snprintf for deterministic formatting in src/shm.h and src/shm_linux.h.
  • Switch the NUMA discriminator hash to use hash_string instead of std::hash<std::string> in src/numa.h so NUMA-related discriminators are stable.
  • Add necessary #include "misc.h" where the helper is consumed and avoid runtime-dependent formatting by producing the shm name via a bounded snprintf buffer; modified files are src/misc.hsrc/shm.hsrc/shm_linux.h, and src/numa.h.

Testing

  • No automated tests were executed for this change.
  • No functional behavior was intentionally changed; changes are limited to hashing/formatting implementation to stabilize identifiers and PGO behavior.

Leave a Reply

Your email address will not be published. Required fields are marked *