|
|
|
|
|
by chipdart
700 days ago
|
|
> What is the virtual thread / event loop pattern seeking to optimize? Is it context switching? Throughput. Some workloads are not CPU-bound or memory-bound, and spend the bulk of their time waiting for external processes to make data available. If your workloads are expected to stay idle while waiting for external events, you can switch to other tasks while you wait for those external events to trigger. This is particularly convenient if the other tasks you're hoping to run are also tasks that are bound to stay idle while waiting for external events. One of the textbook scenarios that suits this pattern well is making HTTP requests. Another one is request handlers, such as the controller pattern used so often in HTTP servers. Perhaps the poster child of this pattern is Node.js. It might not be the performance king and might be single-threaded, but it features in the top spots in performance benchmarks such as TechEmpower's. Node.js is also highly favoured in function-as-a-service applications, as it's event-driven architecture is well suited for applications involving a hefty dose of network calls running on memory- and CPU-constrained systems. |
|