Project

General

Profile

Actions

Feature #10096

closed

[PATCH] use khash for fstring and id_str tables

Added by normalperson (Eric Wong) over 10 years ago. Updated almost 7 years ago.

Status:
Rejected
Target version:
-
[ruby-core:64041]

Description

frozen_strings and global_symbols.id_str hashes are two of the bigger
hashes in Ruby. They are needlessly ordered and incurs malloc overhead
in every st_table_entry.

Use an unordered open-addressing table which incurs no additional malloc
overhead besides the (larger) table itself.

Reduces "ruby -e exit" (w/RubyGems) by ~200K on eglibc malloc on
amd64 Debian stable due to having fewer allocations

global_symbols.str_id is left unchanged (for now) because it is used for
Symbol.all_symbols where ordering is expected

This introduces no user-visible changes or incompatibility
(unless I added a bug :x).

I chose khash because it is flexible and has (IMHO) a good API.
The API should also be familiar to mruby hackers, as mruby uses
a version of khash.

Future changes:

  • covert smaller internal hashes where ordering is not exposed to Ruby users
  • (hopefully) other hashes (methods/constants/ivars) hashes [Feature #9614]

(Note: tried a few times in lynx with 503 errors, never had this problem before
in lynx, trying clunky browser now)


Files

khash.patch (35.5 KB) khash.patch normalperson (Eric Wong), 07/26/2014 07:52 AM
khash-fstring-v3.patch (28.4 KB) khash-fstring-v3.patch normalperson (Eric Wong), 09/04/2014 09:28 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0