Skip to content

Commit ef6fbe7

Browse files
pdillingerfacebook-github-bot
authored andcommitted
Attempt fix initialization order dep on kPageSize (#13973)
Summary: If there's a static initialization of Options() this could now instantiate an AutoHyperClockTable before kPageSize is initialized. Break the dependency because it's a very minor optimization. Pull Request resolved: #13973 Test Plan: internal CI (not able to reproduce locally) Reviewed By: hx235 Differential Revision: D82789849 Pulled By: pdillinger fbshipit-source-id: 3f32b5779a4f56d2071be5aadacda2bf0f4b895d
1 parent 94e65a2 commit ef6fbe7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cache/clock_cache.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,9 +1727,11 @@ inline uint64_t UsedLengthToLengthInfo(size_t used_length) {
17271727
}
17281728

17291729
inline size_t GetStartingLength(size_t capacity) {
1730-
if (capacity > port::kPageSize) {
1730+
// Avoid potential initialization order race with port::kPageSize
1731+
constexpr size_t kPresumedPageSize = 4096;
1732+
if (capacity > kPresumedPageSize) {
17311733
// Start with one memory page
1732-
return port::kPageSize / sizeof(AutoHyperClockTable::HandleImpl);
1734+
return kPresumedPageSize / sizeof(AutoHyperClockTable::HandleImpl);
17331735
} else {
17341736
// Mostly to make unit tests happy
17351737
return 4;

0 commit comments

Comments
 (0)