| ▲ | rrr_oh_man 3 hours ago | ||||||||||||||||
> I did a microbenchmark recently and found that on node 24, awaiting a sync function is about 90 times slower than just calling it. If the function is trivial, which can often be the case. I dabble in JS and… what?! Any idea why? | |||||||||||||||||
| ▲ | hinkley 3 hours ago | parent [-] | ||||||||||||||||
Any await runs the logic that attempts to release the main message pump to check for other tasks or incoming IO events. And it looks like that takes around 90 instructions to loop back around to running the next line of the code, when the process is running nothing else. If you’re doing real work, 90 instructions ain’t much but it’s not free either. If you’ve got an async accumulator (eg, otel, Prometheus) that could be a cost you care about. | |||||||||||||||||
| |||||||||||||||||