This is a comment for blog post about improved Ruby 2.4 performance http://blog.redpanthers.co/behind-scenes-hash-table-performance-ruby-2-4/ The post describes improvements in Ruby 2.4 hash implementation and suggests 3x performance improvements.
The article proves that the benchmark presented at the beginning is misleading and suggests invalid conclusions. Since in 2.4 Hash stores list of its entries in sequential array, so the hash.values
operation is immediate -- just need to copy the array. So there is significant performance gain comparing to 2.3, but it has nothing to do with performance of usual hash operations: insert, find, delete. Results of the presented benchmark cannot be used to predict performance gain of the other hash operations.
I repeated the experiment (like good physicists did in good old times recalled by Dijkstra) and added some more to test performance of the other operations. The benchmark and results can be found here: https://gist.github.com/wrzasa/6b456f73012ce98ae6feb6aaa4ba933e You can check if it's representative and verify results yourself.
Conclusions are that:
- there is noticeable performance gain for
keys
andvalues
method, but nowhere near 3 times; more like 1.8 to 2 times; - there is noticeable performance gain for find and insert operations, but nowhere near 3 times; more like 1.2 to 1.3 times;
- delete operation in 2.4 is actually slower then it was in 2.3 (about 1.1 times).