Duel Threads
Concurrency techniques duel it out for the championship (and bragging rights)
Phases:
- Argue over rules, challenges and the grand prize
- Settle rules and challenges, decide beer is a great grand prize
- Code solutions to agreed upon challenges
- Crown Java as victorious, because we already know how this plays out
- Profit?
Rules:
- Final submissions will be executed on cloud vm's hosted by Vultr
- Linux or Windows may be used (extra brownie points awarded for portable, OS agnostic code)
- Testing will be conducted on both the least and most spec'ed AMD EPYC High Performance Cloud Compute nodes
- 1 vCPU, 1GB RAM (laughs in Linux)
- 12 vCPU, 24GB RAM
- The OS must not be "tuned" to enhance threading performance, ie. it must be "out of the box"
- Initial configuration scripts to setup the runtime environment are permitted once approved by all challengers
- The language runtime must not be "tuned" to enhance threading performance, ie. it must be "out of the box"
- Preview/Experimental builds are permitted, but custom non-standard builds are forbidden.
- Example, "Joes increadible runtime built with a hot tub of secret sauce" is not permitted
- No user enhancements or configuration changes are permitted.
- Preview/Experimental builds are permitted, but custom non-standard builds are forbidden.
- A profiling/diagnostic utility may be used during runtime to collect challenge statistics
- These tools often reduce performance - is there another way?
- A startup script must be used to invoke program code for each challenge
- Any shell script type that is relevant may be used
- Startup scripts must not alter/boost program performance
- Startup scripts are allowed to start/stop/cleanup programsi
- Startup scripts are not part of the challenge themselves, but will aid in scripting a mostly automated challenge
- A runtime "warmup" is permitted but must not be included in the challenge portion of your code
- No external libraries are permitted, only language built-in features
- X days/weeks will be permitted to complete the challenge?
Challenges
Produce one solution for each of the following threading schemes:
-
Pure/bare self-managed language threads
-
Pure/bare pool-managed language threads
-
Async threads
-
Lightweight threads
- Using a shallow call stack, spawn and execute 10,000,000 threads
- Each thread must calculate the product of two random integer values
- Each thread must print to the console it's thread number and calculated value
- Each thread must execute in the order created, and be held until program termination
- When a fatal error occurs, the last printed thread number is counted as the max concurrent thread count
- Best overall statistics (concurrent thread count, memory usage, cpu usage, runtime, etc) wins this challenge
- Using a deep(ish) call stack (see below), spawn and execute 10,000,000 threads
- Deep is defined as 100 recursive calls
- A base random integer value must be produced
- Each recursive call must multiply or divide (alternating) a random integer value and return this value
- The returned value is then multiplied or divided (alternating) at each level as the recursion unwraps
- Overflow is permitted - cast the final value as an integer at recursion return
- Each thread must print to the console it's thread number and calculated value
- Each thread must execute in the order created, and be held until program termination
- When a fatal error occurs, the last printed thread number is counted as the max concurrent thread count
- Best overall statistics (concurrent thread count, memory usage, cpu usage, runtime, etc) wins this challenge
- Serve a provided html template to as many concurrent web socket requests as possible
- The html template will be provided in advance, but will remain simple
- The template will contain two basic variables which must be replaced by your program before serving every request
- The template variables will be the thread number and UNIX Epoch timestamp in milliseconds
- The socket and all handling code must be user written
- Only GET requests will be submitted and required to be handled
- Template, content and final html must be rendered entirely on the server
- No URL parameters, etc. will be expected
- Endpoint path must be: /async-socket-test
- Threads may be released at will
- Maximum concurrent successfully handled web requests will be counted
- An external webserver load stress tester will be used (TBD) to conduct this test
- Using a shallow call stack, spawn and execute 10,000,000 threads