Hi everyone. I'm experimenting with an Actor Model framework, and have the runtime compiled for OSX, Win10, and Haiku_x64. I've got platform specific semaphores (Grand Dispatch semaphores, Win32 semaphores, and Haiku Benaphores). Here are some benchmarks on same laptop (MacBookPro 11.3)
Win10 => 4.05s release, 68s debug => CreateSemaphore(NULL, initial, LONG_MAX, NULL);
OSX => 8.9s release, 10.5s debug = > dispatch_sempahore_create(initial);
Haiku_x64 => 34s (-O3) = > create_semaphore(initial, "name");
The benchmark spawns 8 thread pool threads, + timer thread, + load balancing thread (11 threads total). The actors are creating and dispatching messages (adding to locked queue), and the worker threads process the actor messages. The benchmark tests 10 million messages. In essence, it stresses semaphore locking/unlocking and thread rescheduling (as new messages unlock a thread). A semaphore unlock would typically force an OS reschedule while it pops the next waiting thread from the semaphore wait queue.
Haiku performance wasn't exactly thrilling in this benchmark. The Benaphore implementation (vs raw Haiku sempahores) is 4s faster (34s vs 38s). OSX initially behaved poorly with native mach semaphores (38s), but improved with Grand Central Dispatch semaphores (almost 300% improvement).
Seeing the improvement with OSX semaphores, I wonder if there is a lighter version of semaphores I can use for Haiku? I understand that each alternative implementation has different compromises (ie. less sanity checking, less aggressive rescheduling, limited queue functionality, limited debug facilities etc. -
nothing is free in this world). Having said that, I'm quite impressed with Win10 performance, almost double OSX performance on same hardware.