Issue #10585 has been updated by Yura Sokolov.


> [1/4] struct.c: speedup struct.name = v for small structs
> I agree this makes a noticeable improvement, but I am also not
> in favor of more specialized C code. One day, I hope we
> can remove the current optimizations for <10 getters with JIT.

But till JIT is implemented it will be useful to have fast structs.
I was really disappointed when I discovered that `struct.name= v`
is much slower than `object.name= v` when `name` defined with `attr_accessor`.

> [4/4] struct.c: speedup for big structs
> Oops, I totally missed some of these in [Feature #10575]
> I'm unsure about having a custom hash table in there
> is best, perhaps it can be extracted and reused for
> other things (fstring).

It is very simplified cause members count doesn't change. So it is unusable for fstring.
And it uses Array as a storage for simplicity.

Is using st_table for fstring a bottleneck? if so, i could implement lighter hash structure for.

----------------------------------------
Feature #10585: struct: speedup struct.attr = v for first 10 attributes and struct[:attr] for big structs
https://bugs.ruby-lang.org/issues/10585#change-50376

* Author: Yura Sokolov
* Status: Open
* Priority: Normal
* Assignee: 
* Category: core
* Target version: current: 2.2.0
----------------------------------------
0001 - Define optimized setters for first 10 attributes.

0002 - Cache members definition in an subclasses - it is safe cause it could be modified/overloaded.
And use `rb_attr_get` to lookup definition - it is safe cause result is checked later and `Qnil` is treated as error.

0003,0004 - Use custom hash structure (on top of Array) to lookup members index in a big structure.
Well, I doubt that big structures are useful, so I will not grieve if 0004 is not accepted.

---Files--------------------------------
0001-struct.c-speedup-struct.name-v-for-small-structs.patch (2.33 KB)
0002-struct.c-cache-member-definition-in-a-subclass.patch (1.09 KB)
0003-benchmark-struct-name.patch (2.42 KB)
0004-struct.c-speedup-for-big-structs.patch (5.47 KB)


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