I'm facing a performance issue with my application where latency seems to increase significantly when I run multiple instances of a script. I've set up a simple example that uses roaring bitmaps to demonstrate the problem, but I observe similar results even with basic array calculations. Each additional instance of the script adds approximately 5% latency to the calculations. For instance, one instance runs the operation in about 5.4ms, but running five instances increases the time to around 6.7ms. In the actual application, where the bitmaps are larger and more sparse, I see the operation time balloon from roughly 400ms to 900ms, which is pretty concerning.
A few key points:
- It's not involving any network, disk I/O, or shared memory.
- The processes aren't communicating with each other.
- It doesn't seem to be a scheduling issue based on my tests (I included a screenshot).
- Disabling SMT (AMD multithreading) made no difference.
- This is a Node.js script, but I've tested something similar in PHP and got the same results.
- My OS is Rocky 9, and I'm using Node version 20.15.
4 Answers
I had a similar problem. Have you tried pinning your processes to specific CPUs using taskset? I found that to help a bit, though it may not solve the whole issue.
I think one thing to consider is that as you run more programs in parallel, the CPU's cache hit ratio can get worse. This could be a factor in the increased latency!
You didn't mention what kind of CPU you're using. Is it multi-core? Linux has some tools that can help you manage CPU core assignments, which might help with your scheduling issues. Just because the processes aren't sharing resources doesn't mean they're not limited by CPU cores and RAM.
Have you checked the overall CPU and memory usage on your host machine? Running multiple instances does consume more resources, and that might be contributing to the increased latency you're seeing.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String