Actions
Feature #9196
closedModule#constants(false) should not use a hashtable internally
Status:
Closed
Assignee:
-
Target version:
-
Description
Module#constants always uses a hashtable to ensure that only unique constant names are returned - even when called with the inherit
argument set to false.
Rails calls constants(false) heavily during boot and the use of a hashtable causes this method to show up as a hotspot (6% of boot time is spent in Module#constants).
Our app currently takes about 6.3 seconds to boot on trunk:
6.33 real 5.20 user 1.10 sys
6.27 real 5.17 user 1.07 sys
6.27 real 5.17 user 1.07 sys
6.35 real 5.25 user 1.07 sys
6.29 real 5.18 user 1.08 sys
After applying the patch at https://github.com/charliesome/ruby/compare/optimized-constants-false, boot time drops to about 6 seconds:
6.01 real 4.90 user 1.08 sys
6.02 real 4.90 user 1.09 sys
5.95 real 4.86 user 1.07 sys
5.97 real 4.86 user 1.07 sys
6.00 real 4.88 user 1.09 sys
Actions
Like0
Like0