Oj – Optimized JSON in Ruby
ohler.com
ohler.com
I did some impromptu benchmarking now, and couldn't find a case where Oj performed worse than yajl. Impressive!
>Taking an arbitrary String from a user and evaluating it is never a good idea from an unsecure source
In that case, how it is possible to implement JSON post on that for example?
Submission of same project by OP (project author) yesterday got one vote: https://news.ycombinator.com/item?id=14178676
There's a lot of luck that goes into who is viewing and voting.
If the boxing/unboxing matters, don't use a language with objects. Use one that gives you value types to manipulate and serialize into. For some things, like Regexp, the language has almost zero overhead-- because it's done in C/bare metal.
Additionally you could provide which languages/runtimes one should use.
Maybe your code is performing acceptably well, but if someone comes up to you and says "Hey, would you like some free performance with this drop-in replacement?" you'd be stupid to say no.
There's a difference between performance being critical and performance being important.
It would be awesome if Ruby could eventually become useful in every context. I think it'll eventually get there, but on the way there will need a mountain of performance improvements.
http://chrisseaton.com/rubytruffle/deoptimizing/
A few critical C extensions are missing (OpenSSL):
https://github.com/graalvm/truffleruby
A recent benchmark (FWIW):
https://pragtob.wordpress.com/2017/01/24/benchmarking-a-go-a...
The downside is most Ruby code bases are reluctant to take advantage of it, or even be thread-safe or fiber-aware, which can make writing apps more challenging than an environment like Node.js where there's established standards and expectations.
http://olivierlacan.com/posts/concurrency-in-ruby-3-with-gui...
In my work I have found Ruby often more than makes up for its poor performance record with an excellent ecosystem, mature testing tools, and outstanding string processing APIs. It also offers a high fun factor, which is just as important IMHO.
The application was fast enough but the data transfer started to dominate response time when the queries were large. We did several optimizations to reduce the size of the JSON (gzip among them, obviously) and sometimes building the JSON manually instead of using the jbuilder provided a speedup.
The cron jobs were OK. Using oj made a noticeable difference over the default parser. Batch inserts in the db made a big difference too (the activerecord-import gem). With those optimizations there was no need to write everything else in a more performant language. After all, oj and batch inserts already moved most of our performance critical code from Ruby to C.