mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
set.c: Store set_table->bins
at the end of set_table->entries
This saves one pointer in `struct set_table`, which would allow
`Set` objects to still fit in 80B TypedData slots even if RTypedData
goes from 32B to 40B large.
The existing set benchmark seem to show this doesn't have a very
significant impact. Smaller sets are a bit faster, larger sets
a bit slower.
It seem consistent over multiple runs, but it's unclear how much
of that is just error margin.
```
compare-ruby: ruby 3.5.0dev (2025-08-12T02:14:57Z master 428937a536
) +YJIT +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-12T07:22:26Z set-entries-bounds da30024fdc) +YJIT +PRISM [arm64-darwin24]
warming up........
| |compare-ruby|built-ruby|
|:------------------------|-----------:|---------:|
|new_0 | 15.459M| 15.823M|
| | -| 1.02x|
|new_10 | 3.484M| 3.574M|
| | -| 1.03x|
|new_100 | 546.992k| 564.679k|
| | -| 1.03x|
|new_1000 | 49.391k| 48.169k|
| | 1.03x| -|
|aref_0 | 18.643M| 19.350M|
| | -| 1.04x|
|aref_10 | 5.941M| 6.006M|
| | -| 1.01x|
|aref_100 | 822.197k| 814.219k|
| | 1.01x| -|
|aref_1000 | 83.230k| 79.411k|
| | 1.05x| -|
```
This commit is contained in:
parent
507b1e4bde
commit
85c52079aa
4 changed files with 73 additions and 45 deletions
|
@ -924,6 +924,18 @@ class TC_Set < Test::Unit::TestCase
|
|||
end
|
||||
end;
|
||||
end
|
||||
|
||||
def test_larger_sets
|
||||
set = Set.new
|
||||
10_000.times do |i|
|
||||
set << i
|
||||
end
|
||||
set = set.dup
|
||||
|
||||
10_000.times do |i|
|
||||
assert_includes set, i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TC_Enumerable < Test::Unit::TestCase
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue