Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
DRegexp creates too many transient objects #302
DRegexp, like DStr and DSymbol (see #301) is creating too many transient objects on the way to generating its regexp. This is due in part to the complexity of the logic for building regular expressions dynamically and negotiating encodings across all parts (RubyRegexp.preprocessDRegexp()).
For the following benchmark...
The interpreter creates 7 ByteList, 5 RubyString, 4 Encoding, 1 RubyString, 1 RegexpOptions, and 1 RubyRegexp, not counting byte used inside the ByteList instances. In the ideal case, I would expect this to create perhaps two ByteList, one RegexpOptions, and one RubyRegexp. There's an intermediate RubyString for the DNode portion that might be hard to eliminate as well.
We are many times faster than 1.9.3 here, but the excessive number of transient objects really needs to be fixed.
referenced this issue
Sep 18, 2012
There's more improvement possible, but my commit reduces the objects created in the following ways:
See the commit for perf improvement.