I did some tests on the performance of Node in different multi-threaded scenarios and I thought I'd share my results with you.Background: I've been developing a library for "easily threading off classes while keeping their typings" for some time. Feel free to check it out: https://github.com/nytamin/threadedClassWhen I was working on support for using worker_threads the other day, I was curious to see which performance benefits can be expected, compared to the old way of using child-processes.These results come from measuring the round-trip time of calling a method in a child-process (so basically sending some data to, and then back from the child process/thread).PlatformAPI usedAvg. time per callNodeJS 8.9.xSingle-thread mode0.000200 ms per callNodeJS 8.9.xChild process0.117000 ms per callNodeJS 10.15.xSingle-thread mode0.000080 ms per callNodeJS 10.15.xChild process0.090000 ms per callNodeJS 10.15.xWorker-threads0.045000 ms per callNodeJS 11.14.xSingle-thread mode0.000085 ms per callNodeJS 11.14.xWorker-threads0.047000 ms per callBrowser (Chrome)Single-thread mode0.001500 ms per callBrowser (Chrome)Web-workers0.140000 ms per callMy conclusion is that it's fairly clear that it's only worth thinking about multi-threading if you have a workload that takes more than a millisecond to complete.
Submitted April 14, 2019 at 08:08AM by nytamin
No comments:
Post a Comment