Skip to content

feat(sync): add read-write lock primitive - #1877

Merged
jpnurmi merged 2 commits into
masterfrom
jpnurmi/perf/rwlock
Sep 9, 2026
Merged

feat(sync): add read-write lock primitive#1877
jpnurmi merged 2 commits into
masterfrom
jpnurmi/perf/rwlock

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Add sentry_rwlock_t, backed by platform-native RW locks. Will be used for scope data in #2042.

#skip-changelog (internal)

@jpnurmi jpnurmi changed the title perf: use recursive rwlock for global scope [WIP] perf: use recursive rwlock for global scope Jul 16, 2026
Comment thread src/sentry_sync.h Outdated
Comment thread src/sentry_sync.h Outdated
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.31%. Comparing base (98631e6) to head (8e38214).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1877      +/-   ##
==========================================
+ Coverage   74.29%   74.31%   +0.02%     
==========================================
  Files         103      103              
  Lines       26811    26817       +6     
  Branches     4887     4881       -6     
==========================================
+ Hits        19918    19928      +10     
- Misses       5554     5555       +1     
+ Partials     1339     1334       -5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/sentry_sync.h Outdated
Comment thread src/sentry_scope.c
Comment thread src/sentry_sync.h Outdated
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from 495cd85 to 05fe336 Compare August 7, 2026 14:42
@jpnurmi jpnurmi changed the title [WIP] perf: use recursive rwlock for global scope [WIP] perf: use rwlock for scope data access Aug 7, 2026
Comment thread src/sentry_scope.c Outdated
Comment thread src/sentry_options.h Outdated
Comment thread src/sentry_attachment.c
Comment thread src/backends/sentry_backend_breakpad.cpp Outdated
Comment thread src/sentry_scope.c Outdated
Comment thread src/sentry_scope.c Outdated
Comment thread src/sentry_attachment.c Outdated
Comment thread src/sentry_scope.c Outdated
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from 3c7c966 to 4948141 Compare August 12, 2026 04:55
@jpnurmi
jpnurmi changed the base branch from master to jpnurmi/ref/attachments August 12, 2026 04:56
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch from 7cfebae to ed216c7 Compare August 12, 2026 06:33
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from 4948141 to 0b0e77c Compare August 12, 2026 06:33
Comment thread src/sentry_scope.c Outdated
Comment thread src/sentry_scope.c Outdated
Comment thread src/sentry_scope.c Outdated
Comment thread src/sentry_scope.c Outdated
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch 3 times, most recently from c7f80db to b901758 Compare August 17, 2026 10:37
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from dab304d to b899738 Compare August 17, 2026 17:52
Comment thread src/sentry_scope.c Outdated
Comment thread src/integrations/sentry_integration_wer.c Outdated
Comment thread src/sentry_core.c Outdated
Comment thread src/sentry_scope.c Outdated
Comment thread src/sentry_scope.c Outdated
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from 853172c to dcbac0c Compare August 18, 2026 12:37
Comment thread src/sentry_scope.c
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from 8891408 to f197136 Compare August 19, 2026 10:05
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch 2 times, most recently from c5ebf17 to b4d7fb8 Compare September 1, 2026 14:29
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from fd41b34 to 219277a Compare September 1, 2026 14:41
Comment thread src/sentry_sync.h
@jpnurmi jpnurmi changed the title [0.17] perf: use rwlock for scope data access [0.17] feat(sync): add read-write lock primitive Sep 1, 2026
@jpnurmi jpnurmi mentioned this pull request Sep 2, 2026
20 tasks
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachments branch 6 times, most recently from ed71879 to 12cec9b Compare September 9, 2026 10:31
@jpnurmi
jpnurmi removed this pull request from stack #2010 September 9, 2026 10:32
@jpnurmi
jpnurmi added this pull request to stack #2080 September 9, 2026 10:32
@jpnurmi
jpnurmi removed this pull request from stack #2080 September 9, 2026 11:37
@jpnurmi
jpnurmi changed the base branch from jpnurmi/ref/attachments to master September 9, 2026 11:37
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from 219277a to b5546d7 Compare September 9, 2026 11:38
@jpnurmi jpnurmi changed the title [0.17] feat(sync): add read-write lock primitive feat(sync): add read-write lock primitive Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 8e38214

Add `sentry_rwlock_t` backed by platform native RW locks.
@jpnurmi
jpnurmi force-pushed the jpnurmi/perf/rwlock branch from b5546d7 to cf2aa1a Compare September 9, 2026 12:11
Comment thread src/sentry_sync.h
Comment thread src/sentry_sync.h
Comment on lines +206 to +209
# define sentry__rwlock_read_lock(Lock) AcquireSRWLockShared(Lock)
# define sentry__rwlock_read_unlock(Lock) ReleaseSRWLockShared(Lock)
# define sentry__rwlock_write_lock(Lock) AcquireSRWLockExclusive(Lock)
# define sentry__rwlock_write_unlock(Lock) ReleaseSRWLockExclusive(Lock)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Will sentry_rwlock_t be potentially used recursively? It shouldn't because MS documents it as "should not be acquired recursively". Recursive access (same thread) can deadlock. We should acknowledge that in a comment at least.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This won't be used recursively, no. We will no longer lock across function calls that might need the same lock recursively, but only for the duration of reading or writing a piece of (scope) data.

How's this description?

A non-recursive read-write lock for short critical sections around protected variable access. Allows multiple concurrent readers, or a single exclusive writer.

Based on SRWLOCK on Windows, and pthread_rwlock_t on POSIX.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great description 👍

Comment thread src/sentry_sync.h
@jpnurmi
jpnurmi merged commit 0a31c85 into master Sep 9, 2026
71 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/perf/rwlock branch September 9, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants