Nokogiri blocking the GVL #3017
Unanswered
jacobat
asked this question in
General Q&A
Replies: 1 comment 1 reply
-
@jacobat Thanks for opening this discussion. I was on holiday for the past week and I have to catch up on OSS notifications. I'll respond more thoughtfully as soon as I can! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been talking to @flavorjones on Slack and he requested that I start a discussion here about our uses of Nokogiri.
We're doing some XML munging as part of regular HTTP requests. And we suspect it's causing some latency issues with Puma as Nokogiri is blocking the entire Ruby runtime for periods of time and so concurrent requests are impacted by the XML munging.
In one example we're loading 300+ XML documents and doing a small manipulation on them and then serializing them back out to XML. Most of our XML documents are in the order of kilobytes with a long tail going into many MBs.
To exemplify the blocking here's a small script:
Point it at an XML file (for instance this 1MB xml file) and the results running a single thread for 40 iterations will be something like:
If we instead run 4 thread with 10 iterations:
In both cases the program only manages to print a small number of dots - so the "dot printer" thread is mostly blocked throughout the program. My interpretation of this result is that Nokogiri is the reason the printer is not printing a dot every 10ms.
I suspect that doing this kind of XML munging as part of a web request is a bad idea, and we're trying to move most of our XML processing offline.
Beta Was this translation helpful? Give feedback.
All reactions