Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Benchmark Oj::Parser in a thread safe way #703

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

casperisfine
Copy link

The documentation state Oj::Parser.usual isn't thread safe: https://github.com/ohler55/oj/blob/c70bf4125b546bc7146840b15de36460d42b4dff/ext/oj/parser.c#L1507-L1513

As such we shouldn't benchark it this way, but instantiate a new parser every time. Technically in real world scenarios you could create a pool of parsers and re-use them, but if it's not provided by the gem, I'm not sure we should go out of our way to do it.

@tenderlove

The documentation state `Oj::Parser.usual` isn't thread safe:
https://github.com/ohler55/oj/blob/c70bf4125b546bc7146840b15de36460d42b4dff/ext/oj/parser.c#L1507-L1513

As such we shouldn't benchark it this way, but instantiate a new
parser every time. Technically in real world scenarios you could
create a pool of parsers and re-use them, but if it's not provided
by the gem, I'm not sure we should go out of our way to do it.
@casperisfine casperisfine force-pushed the oj-parser-thread-safe branch from 7952782 to 855563f Compare November 8, 2024 16:05
@byroot byroot merged commit 821b92e into ruby:master Nov 8, 2024
35 of 36 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants