Skip to content

Fix signal fences #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix signal fences #217

wants to merge 1 commit into from

Conversation

szegedi
Copy link

@szegedi szegedi commented Jun 10, 2025

Fixes signal fences to consistently have acquire after load and release before store.

@szegedi szegedi requested a review from nsavoire as a code owner June 10, 2025 12:59
@szegedi szegedi added the semver-patch Bug or security fixes, mainly label Jun 10, 2025
Copy link

Overall package size

Self size: 1.58 MB
Deduped: 1.95 MB
No deduping: 1.95 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | source-map | 0.7.4 | 226 kB | 226 kB | | pprof-format | 2.1.0 | 111.69 kB | 111.69 kB | | p-limit | 3.1.0 | 7.75 kB | 13.78 kB | | delay | 5.0.0 | 11.17 kB | 11.17 kB | | node-gyp-build | 3.9.0 | 8.81 kB | 8.81 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@pr-commenter
Copy link

pr-commenter bot commented Jun 10, 2025

Benchmarks

Benchmark execution time: 2025-06-10 13:03:43

Comparing candidate commit c0cf28a in PR branch szegedi/fix-fencing with baseline commit 2f6f2f8 in branch main.

Found 3 performance improvements and 0 performance regressions! Performance is the same for 91 metrics, 26 unstable metrics.

scenario:profiler-light-load-no-wall-profiler-22

  • 🟩 cpu_user_time [-8.681ms; -3.639ms] or [-11.520%; -4.828%]

scenario:profiler-light-load-no-wall-profiler-24

  • 🟩 cpu_user_time [-9.933ms; -2.673ms] or [-12.459%; -3.353%]

scenario:profiler-light-load-with-wall-profiler-22

  • 🟩 cpu_user_time [-6.794ms; -1.889ms] or [-6.026%; -1.676%]

@szegedi szegedi changed the title Fixes signal fences Fix signal fences Jun 10, 2025
}

void WallProfiler::OnGCEnd() {
auto newCount = gcCount.load(std::memory_order_relaxed) - 1;
std::atomic_signal_fence(std::memory_order_acquire);
std::atomic_signal_fence(std::memory_order_acq_rel);
gcCount.store(newCount, std::memory_order_relaxed);
Copy link

@nsavoire nsavoire Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me wonder what prevents compiler from reordering gAsyncId = -1 before gcCount.store(newCount, std::memory_order_relaxed); ?
In the previous code, I believe std::atomic_signal_fence(std::memory_order_release); was preventing it.
This questions again my whole understanding of atomic_signal_fence...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch Bug or security fixes, mainly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants