Proposal: Allow std::hardware_(destructive|constructive)_interference_size

412 views
Skip to first unread message

Anton Bikineev

unread,
Sep 16, 2022, 7:00:09 AM9/16/22
to cxx
The constants (cppreference) are useful to avoid false sharing. They're easier to use than relying on platform-specific cacheline-size macros or sysconf or whatnot. Should be safe to use.

(The story: after profiling false sharing hits with 'perf c2c' I found some places in Chromium where the constants could be useful).

Jeremy Roman

unread,
Sep 16, 2022, 11:28:58 AM9/16/22
to Anton Bikineev, cxx
Makes sense to me. I would expect usage to be extremely niche, but I don't think risk of misuse is particularly high.

On Fri, Sep 16, 2022 at 4:00 AM 'Anton Bikineev' via cxx <c...@chromium.org> wrote:
The constants (cppreference) are useful to avoid false sharing. They're easier to use than relying on platform-specific cacheline-size macros or sysconf or whatnot. Should be safe to use.

(The story: after profiling false sharing hits with 'perf c2c' I found some places in Chromium where the constants could be useful).

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAFd1ZwcJkRUt40gn%3DVm-Ud%2B3G1bWvuhw-3hxsRh8Yddg--j8Jw%40mail.gmail.com.

Peter Kasting

unread,
Sep 16, 2022, 5:19:53 PM9/16/22
to Anton Bikineev, cxx
Lgtm

On Fri, Sep 16, 2022, 4:00 AM 'Anton Bikineev' via cxx <c...@chromium.org> wrote:
The constants (cppreference) are useful to avoid false sharing. They're easier to use than relying on platform-specific cacheline-size macros or sysconf or whatnot. Should be safe to use.

(The story: after profiling false sharing hits with 'perf c2c' I found some places in Chromium where the constants could be useful).

--

K. Moon

unread,
Sep 17, 2022, 7:28:47 AM9/17/22
to Peter Kasting, Anton Bikineev, cxx
Have we gotten to the point yet where we should be default-allowing C++17 features? Or no?

Peter Kasting

unread,
Sep 17, 2022, 10:39:05 AM9/17/22
to K. Moon, Anton Bikineev, cxx
No, that's still a year out.

PK

Peter Kasting

unread,
Jan 20, 2023, 3:00:21 PM1/20/23
to cxx, biki...@google.com
Update: I discovered today that libc++ does not implement these for clang, only for gcc. I will be moving these to the banned list for now. Best workaround I know of is ABSL_CACHELINE_SIZE in third_party/abseil-cpp/absl/base/optimization.h.

PK

Reply all
Reply to author
Forward
0 new messages