-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
excise thread_local guard in SingletonRelaxedCounter fast-path
Summary: Somehow, the compiler hallucinates the need for a tls guard variable to guard the `thread_local` variable of type `CounterAndCache`. In the past, this type was expected to be trivial. But, with the change to `std::atomic` in C++20 to make it no longer trivial, the compiler is giving this `thread_local` variable a tls guard variable which it manifestly does not need. This affects the inline fast path. The immediate solution is to change the counter types from `std::atomic<Int>` to `Int` and to use `std::atomic_ref` backported as `folly::atomic_ref` to access the counters. This is unsatisfactory because this removes the type-safety provided by `std::atomic`; but we must have the optimal inline fast path. Differential Revision: D59144047 fbshipit-source-id: f1bd0746d7bd8ae8963c2a67bb62a3608c9e09fc
- Loading branch information
1 parent
ea265a8
commit 8885811
Showing
2 changed files
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters