diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2025-08-07 13:30:53 +0200 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2025-08-12 21:56:57 +0200 |
| commit | 85c52079aa35a1d2e063a5b40eebe91701c8cb9e (patch) | |
| tree | 62b467b1e8bbc11f4535c6a88cee777374340685 /internal | |
| parent | 507b1e4bde074bdda3083df6b4c2190a385f84bf (diff) | |
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| -|
```
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/set_table.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/internal/set_table.h b/internal/set_table.h index 3cb9c64349..6242e979c6 100644 --- a/internal/set_table.h +++ b/internal/set_table.h @@ -15,13 +15,16 @@ struct set_table { const struct st_hash_type *type; /* Number of entries currently in the table. */ st_index_t num_entries; - /* Array of bins used for access by keys. */ - st_index_t *bins; + /* Start and bound index of entries in array entries. entries_starts and entries_bound are in interval [0,allocated_entries]. */ st_index_t entries_start, entries_bound; - /* Array of size 2^entry_power. */ + + /** + * Array of size 2^entry_power. + * Followed by st_index_t *bins, Array of bins used for access by keys. + */ set_table_entry *entries; }; |
