jsonapi-rb / jsonapi-renderer

Efficiently render JSON API documents.
http://jsonapi-rb.org
MIT License
27 stars 11 forks source link

resources_processor: speed up rendering by using Hash instead of Set #40

Closed alchimere closed 4 years ago

alchimere commented 5 years ago

According to a conference I just watched the Set class is very slow compared to simple Hash because of optimizations in the MRI for Hash accesses.

So here is a PR that replaces Set with Hash. It results with a speed increase (can be up to 30%)

Here is the code of the benchmark and it's results before/after the patch: https://gist.github.com/alchimere/323a4803981e48fed2ce86ac5027693a

beauby commented 5 years ago

That looks promising – what do you think @dawidof?