Get the latest tech news

Don't Block the Event Loop (Or the Worker Pool) in JavaScript


Node.js uses the Event-Driven Architecture: it has an Event Loop for orchestration and a Worker Pool for expensive tasks. - rowsana/Not-blocking-event-loop

Whether or not your regular expression pattern is vulnerable (i.e. the regexp engine might take exponential time on it) is actually a difficult question to answer, and varies depending on whether you're using Perl, Python, Ruby, Java, JavaScript, etc., but here are some rules of thumb that apply across all of these languages: If your computation is more complex, offloading is a better approach: the communication costs, i.e. the overhead of passing serialized objects between the Event Loop and the Worker Pool, are offset by the benefit of using multiple cores. The Event Loop is responsible for JavaScript callbacks and non-blocking I/O, and a Worker executes tasks corresponding to C++ code that completes an asynchronous request, including blocking I/O and CPU-intensive work.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of javascript

javascript

Photo of event loop

event loop

Photo of worker pool

worker pool

Related news:

News photo

My son (9 yrs old) used plain JavaScript to make a game, and wants your feedback

News photo

EstyJS 2.0 (emulator for the Atari ST, written in 100% pure JavaScript)

News photo

Why am I writing a JavaScript toolchain in Zig?