From: Eric Wong Date: 2015-12-12T03:21:44+00:00 Subject: [ruby-core:72073] Re: [Ruby trunk - Feature #11405] [PATCH] hash.c: minor speedups to int/fixnum keys mame@ruby-lang.org wrote: > Eric Wong wrote: > > Perhaps teach developers to rehash explicitly. Maybe Hash#freeze > > can imply rehash, too. But yes, I worry about memory increase more > > than speed nowadays. > > I'm not sure if explicit/implicit rehasing will solve any issue. > > The problem is that the linked lists are too(?) long. Long linked > lists decrease the average access speed, and also makes per-element > access speed non-uniform. Rehasing will not improve the average > speed, nor eliminate/relax the inequality. But wasn't the goal of adding rehash in r53031 to improve speed and relax the inequality? > It will just make us > impossible to predict which element is fast to access and which is > slow. Will this make us happy? I mean we may take freeze as a hint from the user to optimize the hash. Perhaps we may rearrange data in contiguous memory for improved locality (like "git repack" or defragmenting a filesystem). I doubt we can have a compacting GC at this point, but small-scale, explicit compaction might still work.