mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Remove lock for dynamic symbol
Benchmark: ARGV[0].to_i.times.map do Ractor.new do 1_000_000.times do |i| "hello#{i}".to_sym end end end.map(&:value) Results: | Ractor count | Branch (s) | Master (s) | |--------------|------------|------------| | 1 | 0.364 | 0.401 | | 2 | 0.555 | 1.149 | | 3 | 0.583 | 3.890 | | 4 | 0.680 | 3.288 | | 5 | 0.789 | 5.107 |
This commit is contained in:
parent
efc232241e
commit
061224f3cb
1 changed files with 4 additions and 9 deletions
13
symbol.c
13
symbol.c
|
@ -262,8 +262,6 @@ set_id_entry(rb_symbols_t *symbols, rb_id_serial_t num, VALUE str, VALUE sym)
|
|||
static VALUE
|
||||
sym_set_create(VALUE sym, void *data)
|
||||
{
|
||||
ASSERT_vm_locking();
|
||||
|
||||
bool create_dynamic_symbol = (bool)data;
|
||||
|
||||
struct sym_set_static_sym_entry *static_sym_entry = sym_set_static_sym_untag(sym);
|
||||
|
@ -309,7 +307,9 @@ sym_set_create(VALUE sym, void *data)
|
|||
}
|
||||
new_static_sym_entry->sym = static_sym;
|
||||
|
||||
set_id_entry(&ruby_global_symbols, rb_id_to_serial(STATIC_SYM2ID(static_sym)), str, static_sym);
|
||||
RB_VM_LOCKING() {
|
||||
set_id_entry(&ruby_global_symbols, rb_id_to_serial(STATIC_SYM2ID(static_sym)), str, static_sym);
|
||||
}
|
||||
|
||||
return sym_set_static_sym_tag(new_static_sym_entry);
|
||||
}
|
||||
|
@ -979,12 +979,7 @@ rb_gc_free_dsymbol(VALUE sym)
|
|||
VALUE
|
||||
rb_str_intern(VALUE str)
|
||||
{
|
||||
VALUE sym = 0;
|
||||
|
||||
GLOBAL_SYMBOLS_LOCKING(symbols) {
|
||||
sym = sym_find_or_insert_dynamic_symbol(symbols, str);
|
||||
}
|
||||
return sym;
|
||||
return sym_find_or_insert_dynamic_symbol(&ruby_global_symbols, str);
|
||||
}
|
||||
|
||||
ID
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue