Archive for 2018
February 15, 2018
During my time last year developing performance improvements for Rambling Trie, I stumbled into something quite interesting that happens with Ruby’s
A commonly used method from the
#has_key?which tells you if the
Hashin question contains a particular key. Rambling Trie’s underlying data structure is an n-ary tree backed by a
Hashwhere each key is the letter corresponding to a child and each value is the
Nodethat corresponds to that letter. As you might imagine,
#has_key?is a common operation called throughout the gem implementation.
To my surprise, while running some Ruby benchmarks I noticed that accessing the key with
#and verifying if it was
nilinstead of calling
#has_key?lowered the time it took...
February 11, 2018
While working on some of the performance improvements for version 1.0.0 of Rambling Trie late in 2016 and early in 2017, I upgraded from Ruby 2.3.3 to Ruby 2.4.0 imagining that the newer version would help me on my mission to make all operations execute a bit faster. To my surprise, I ran into a significant performance degradation after upgrading - specifically, there was a ~25% increase in the time it took to execute a script using a trie with a big-ish word dictionary. This intrigued me enough that I decided to take a closer look.
Benchmarking with Ruby
After some investigation with the help of Ruby’s own
Benchmark, I realized that while most operations were a bit slower, the main problem was a lot more visible during intensive operations...