[ruby-core:64943] [ruby-trunk - Feature #10096] [PATCH] use khash for fstring and id_str tables

From: normalperson@...
Date: 2014-09-11 02:38:48 UTC
List: ruby-core #64943
Issue #10096 has been updated by Eric Wong.


 normalperson@yhbt.net wrote:
 > File khash-fstring-v3.patch added
 
 OK to commit before 9/14?  I think khash is the best for fstring
 as we only store one VALUE (no extra allocation)
 
 > * covert smaller internal hashes where ordering is not exposed to Ruby users
 > * (hopefully) other hashes (methods/constants/ivars) hashes [Feature #9614]
 
 Maybe ihash is better for method entries and constant entries because
 they require a struct allocation.
 
 I'm refreshing that series for methods + constants with ordering as a
 split-out patch.  We may keep ordering (at memory cost) since ccan/list
 makes it easy and we still save memory from avoiding st_table_entry
 allocations.
 
 I'm not going to change ivars for now.

----------------------------------------
Feature #10096: [PATCH] use khash for fstring and id_str tables
https://bugs.ruby-lang.org/issues/10096#change-48832

* Author: Eric Wong
* Status: Assigned
* Priority: Normal
* Assignee: Koichi Sasada
* Category: core
* Target version: current: 2.2.0
----------------------------------------
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-fstring-v3.patch (28.4 KB)


-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next