Articles tagged 'performance'
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...
January 27, 2016
If you’ve worked with relational databases and any ORMs like Java’s Hibernate, .NET’s NHibernate or Rails’
ActiveRecordin the past, you might be familiar with SELECT N+1 issues. It is a common performance problem in database-dependent applications and, because of this, these ORMs provide a built-in solution to this problem.
eager_loadcome to the rescue. Therefore, it is not unusual to find these keywords scattered in different places where your application accesses the database. Hopefully this isn’t a lot of places though - you are using Query Objects, right?
An example application
Let’s imagine for a second that we have an application where you can browse restaurants, which in turn have many reviews...
July 28, 2012
This post was originally published in the Rambling Labs Blog on July 28, 2012.
As done with the jQuery Rambling Slider previously on this week, and as I promised on that post as well, the Rambling Trie now has its own homepage on ramblinglabs.com! Here’s the link:
It features installation and usage steps as well as a contributing page, and includes the badges from various cool GitHub services (more on that later). It also has a brand new logo, inspired on the trie data structure (and other tree data structures) concept.
Go ahead and check it out!
- Examples page for jQuery Rambling Slider
- Examples page for Rambling Trie
- Examples page for Rambling Slider...
July 21, 2012
This post was originally published in the Rambling Labs Blog on July 21, 2012.
Version 0.4.1 of the Rambling Trie is here. It has some minor performance improvements over previous versions, changes in file/directoy structure, as well as a new API entry point, other API methods and more documentation.
You can now instance a new trie like this:
trie = Rambling::Trie.create
The old API entry point
Rambling::Trie.newis now marked as deprecated and will be removed soon. Use the new
Also, you can add words to the trie using
trie << 'word'
And check if a word is contained in the trie with
You can see more documentation available on the project’s...
February 13, 2012
This post was originally published in the Rambling Labs Blog on February 13, 2012.
The new version of the
rambling-triegem is out! As I said on my previous post, the
rambling-trieis an implementation of the Trie data structure in Ruby.
Version 0.3.3 has several performance improvements, and I also added the code’s documentation via Yard. Also, since the previous version (0.3.2), the methods
is_word?have been fixed for the compressed trie.
For the uncompressed trie, the
is_word?methods work very fast. The compressed trie’s
is_word?method is as fast as it’s uncompressed counterpart, but the
has_branch_for?is a bit slower.
I’ve also added some benchmarking reports for each version of the...