From: Eric Wong Date: 2014-12-11T23:04:57+00:00 Subject: [ruby-core:66792] Re: [ruby-trunk - Feature #10585] [Open] struct: speedup struct.attr = v for first 10 attributes and struct[:attr] for big structs benchmark results on r48774 (Xeon E3-v1230 v3): Speedup ratio: compare with the result of `trunk' (greater is better) name built loop_whileloop2 1.001 vm2_struct_big_aref_hi* 1.006 vm2_struct_big_aref_lo* 1.000 vm2_struct_big_aset* 1.005 vm2_struct_big_href_hi* 1.466 vm2_struct_big_href_lo* 1.213 vm2_struct_big_hset* 1.305 vm2_struct_small_aref* 1.010 vm2_struct_small_aset* 2.604 vm2_struct_small_href* 1.215 vm2_struct_small_hset* 1.215 Comments on patches: * [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. * [2/4] struct.c: cache member definition in a subclass I think NIL_P(var) is preferred over "var != Qnil". Overall, I think this patch makes sense on its own. * [3/4] benchmark struct[:name] Good :) * [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).