Hacker News new | ask | show | jobs
by peterohler 526 days ago
The strict mode benchmarks for Oj are in the test/perf_strict.rb. Others are are in perf_*.rb.

If callback parsing is not supported that's fine. Oj does support callback parsing as it allows elements in a JSON to be ignored. That save memory, GC, and performance. Your choice of course just as including callback parsers is a choice for Oj.

Ok, so you picked options that you knew would fail. Again you choice but there are certainly others that would trade a slight improvement in performance to not have 16+ significant digits. It's a choice. You are certainly entitled to you opinion but that doesn't mean everyone will share them.

I'm not sure what platform you are testing on but i'm sure there will be variations depending on the OS and the hardware. I tested on MacOS M1.

1 comments

> If callback parsing is not supported that's fine.

Yes, as mentioned in part 1 of the series, my goal for ruby/json, given it is part of Ruby's stdlib, is to be good enough so that the vast majority of users don't need to look elsewhere, but it isn't to support every possible use case or to make a specific gem obsolete. For the minority of users that need things like event parsing, they can reach to Oj.

> but that doesn't mean everyone will share them.

Of course. When I was a fairly junior developer, I heard someone say: "Performance should take a backseat to correctness", and that still resonate with me. That's why I wouldn't consider such truncation as a default.

> i'm sure there will be variations depending on the OS and the hardware. I tested on MacOS M1.

I suspect so too. I'd like to get my hands on a x86_64/Linux machine to make sure performance is comparable there, but I haven't come to it yet. All my comparisons for now have been on M3/macOS.

> It looks like a lot of time and effort went into the analysis.

It was roughly two weeks full time, minus some bug fixes and such. I think in the end I'll have spent more time writing the blog series than on the actual project, but that probably says more about my writing skill :p

Anyway, thanks for the pointers, I'll have a look to see if there's some more performance that need to be squeezed.

If you would like to discuss separately on a call or chats I'd be up for that. Maybe kick around a few ideas.