4 ms·
Thanks for putting the time and extensive effort into this book. I am deeply interested in concurrency, asynchrony and parallelism I even journal about it every
by samsquire 4y ago
Thanks for putting the time and extensive effort into this book. I am deeply interested in concurrency, asynchrony and parallelism I even journal about it everyday on my GitHub journal ideas repository (see my profile)
I've been talking on the r/programminglanguages discord about syntax for async/await. I am writing a programming language that has parallelism as a first class citizen. I use this actor2.java lock free algorithm below for sending messages between threads.
I want my async/await tasks to be eager and run in their own threads.
So if I do this
handle1 = async task1();
handle2 = async task2();
handle3 = async task3();
// at this point in time, the token ring thread pool shall be running 3 tasks in parallel
return1 = await handle1;
return2 = await handle2;
return3 = await handle3;
I believe other languages do not run CPU bound async/await computations on a thread except for IO.
I wrote an unrolled state machine for my async/await in Java. This models a simple async/await program and runs tasks on other threads - without locks. I use a design I call token ring parallelism, where threads take turns and are linked together in a ring structure. A semaphore communicates write status along the ring. The plan is to write a transpiler to generate the switch statements automatically. Then any language with threading can have async await support even if it is not native.
https://github.com/samsquire/multiversion-concurrency-control/blob/main/src/main/java/main/TokenRingTimer2AsyncAwait3.java https://github.com/samsquire/multiversion-concurrency-contro...
I wrote a own lock free algorithm here that I use to do message passing between actor threads. My goal is high throughput performance and low latency.
https://github.com/samsquire/multiversion-concurrency-control/blob/main/src/main/java/main/Actor2.java https://github.com/samsquire/multiversion-concurrency-contro...
With 11 threads (on a 12 core processor, deliberately left one core for Windows)
I get
This code with 100 threads, gets
114657500 total requests
22079241.286347 requests per second
Time taken: 5.193000
166512180 total requests
33249237.220447 requests per second
Time taken: 5.008000
For a lock based benchmark with 100 threads, I get:
16307090 total requests
3246484.172805 requests per second
With 11 threads, the lock benchmark gets
178770160 total requests
35732592.444533 requests per second
Time taken: 5.003000
Each request is a synchronization event that sends 10 messages in a loop or adds 10 to a counter to represent the synchronization event.
There's probably problems with my measuring methodology, I am doing the simplest possible thing that shall work. I am trying to show that my lock free algorithm scales even with heavy contention.
- Dopameaner 4y agoOut of curiosity, How do you benchmark your algorithms. > e.g, This is another parallel multithreaded actor model. Run Actor2.java to run it. I get around 1.1 billion requests per second with this model.