Skip to content
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

Atomic single linked list (pj_atomic_slist) #4330

Open
wants to merge 42 commits into
base: master
Choose a base branch
from

Conversation

LeonidGoltsblat
Copy link
Contributor

This is the second reincarnation of the #4116.

With the introduction of alignment-aware memory allocation, things have become much simpler and no longer require global changes to the library.

Implemented in 2 versions:
PJ_ATOMIC_SLIST_WIN32 using Windows's single linked list and
PJ_ATOMIC_SLIST_GENERIC - os independent "cross-platform" implementation.
Project build system automatically compliles the first for Windows platform and the second for others.

Performance comparison.
Tested under Windows 10, AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx 2.50 GHz, 4 cores.
Single-threaded test - performance without contention, 100,000 push/pop pairs.
Multi-threaded test - performance with maximum possible contention, 4 threads, 100,000 push/pop pairs each.
3 passes for each implementation variant (see atomic_slist_mt_test()).

PJ_ATOMIC_SLIST_WIN32

02:13:30.282 ...slist (single thread) time: 14 ms (total), 141 nanosec/op
02:14:37.407 ...slist (single thread) time: 17 ms (total), 171 nanosec/op
02:15:34.514 ...slist (single thread) time: 16 ms (total), 168 nanosec/op

02:13:30.352 ...slist (multi threads) time: 57 ms (total), 144 nanosec/op
02:14:37.476 ...slist (multi threads) time: 51 ms (total), 129 nanosec/op
02:15:34.570 ...slist (multi threads) time: 47 ms (total), 118 nanosec/op

PJ_ATOMIC_SLIST_GENERIC

02:20:58.810 ...slist (single thread) time: 18 ms (total), 183 nanosec/op
02:22:35.733 ...slist (single thread) time: 18 ms (total), 189 nanosec/op
02:23:55.236 ...slist (single thread) time: 14 ms (total), 143 nanosec/op

02:20:58.971 ...slist (multi threads) time: 151 ms (total), 378 nanosec/op
02:22:35.921 ...slist (multi threads) time: 174 ms (total), 436 nanosec/op
02:23:55.425 ...slist (multi threads) time: 177 ms (total), 444 nanosec/op

single thread: slists is a little faster
multi threads: slists does not show performance degradation with contention (this is the main measurement result) and works more than 3 times faster, each operation is faster by more than 250-300 nanoseconds

LeonidGoltsblat and others added 30 commits October 26, 2024 00:16
- some changes in sln to build with v143 build tools (VS 2022)
- 2 new pjsystest project configuration to build as Debug-Dynamic and Release-Dynamic
- stack implementation and testing incorporated into pjlib and pjlib-test projects
decreased the repeat counter increased the number of threads
@LeonidGoltsblat
Copy link
Contributor Author

bug fixed in generic implementation of pj_atomic_slist_size()
added tests for the pj_atomic_slist_size()
please review (and merge!)

@LeonidGoltsblat LeonidGoltsblat requested a review from sauwming March 5, 2025 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants