gentoobro on Nostr: I use spinlocks implemented with atomics for nearly everything except controlling the ...
I use spinlocks implemented with atomics for nearly everything except controlling the threads themselves. Spinlocks are way faster than other options in my tests on desktops, even in contrived, highly contested test scenarios.
Remember, the kernel essentially has to use atomics to implement all its synchronization syscalls, and spinning on a lock for a few hundred cycles is still way faster than a syscall's overhead.
Published at
2025-01-01 04:48:49Event JSON
{
"id": "e372d6d82a6430fcc3ba753bb8b6cb1cf37f0007e1f63712c9b79bfc3eb9d87d",
"pubkey": "eac65d264cf2fd2965f59a4c1057bb8a94422059ce30cd2ebdab77c8b4b02911",
"created_at": 1735706929,
"kind": 1,
"tags": [
[
"p",
"f5048832375723e1da26ec07b4d72ac654e79267f13e67189bb19088dcfb8246",
"wss://relay.mostr.pub"
],
[
"p",
"ff479c63a264a52994dec047cff0c7fdff88ccba2ffb152705d7dba3e31266bc",
"wss://relay.mostr.pub"
],
[
"p",
"abdc700d488930e4d3179549442b52f594d4d7da0b365c3cefc6cfd9895c2635",
"wss://relay.mostr.pub"
],
[
"e",
"cb1391e59730a9e3b7750b0801ace310588ca7a8a0e209b7b6ff857ff3b7ec50",
"wss://relay.mostr.pub",
"reply"
],
[
"proxy",
"https://shitpost.cloud/objects/f503363b-9129-4d6d-8652-1fdb2090ed80",
"activitypub"
]
],
"content": "I use spinlocks implemented with atomics for nearly everything except controlling the threads themselves. Spinlocks are way faster than other options in my tests on desktops, even in contrived, highly contested test scenarios.\n\nRemember, the kernel essentially has to use atomics to implement all its synchronization syscalls, and spinning on a lock for a few hundred cycles is still way faster than a syscall's overhead.",
"sig": "d8cb91194ddd012e21fdfa55ff2938e81bc48d8f9ad14668f7ed19204074feb2e848f0993df78fa3d5ccbc835a521c0d737f863168572e847a4f8bb16f5b4e14"
}