ruby/test/ruby
Jean Boussier f3206cc79b Struct: keep direct reference to IMEMO/fields when space allows
It's not rare for structs to have additional ivars, hence are one
of the most common, if not the most common type in the `gen_fields_tbl`.

This can cause Ractor contention, but even in single ractor mode
means having to do a hash lookup to access the ivars, and increase
GC work.

Instead, unless the struct is perfectly right sized, we can store
a reference to the associated IMEMO/fields object right after the
last struct member.

```
compare-ruby: ruby 3.5.0dev (2025-08-06T12:50:36Z struct-ivar-fields-2 9a30d141a1) +PRISM [arm64-darwin24]
built-ruby: ruby 3.5.0dev (2025-08-06T12:57:59Z struct-ivar-fields-2 2ff3ec237f) +PRISM [arm64-darwin24]
warming up.....

|                      |compare-ruby|built-ruby|
|:---------------------|-----------:|---------:|
|member_reader         |    590.317k|  579.246k|
|                      |       1.02x|         -|
|member_writer         |    543.963k|  527.104k|
|                      |       1.03x|         -|
|member_reader_method  |    213.540k|  213.004k|
|                      |       1.00x|         -|
|member_writer_method  |    192.657k|  191.491k|
|                      |       1.01x|         -|
|ivar_reader           |    403.993k|  569.915k|
|                      |           -|     1.41x|
```

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2025-08-06 17:07:49 +02:00
..
enc Speed up initial test creation in test_case_comprehensive.rb: 2025-01-03 21:28:47 +09:00
namespace Fix class instance variable inside namespaces 2025-06-12 13:43:29 +02:00
allpairs.rb
beginmainend.rb
bug-11928.rb
bug-13526.rb
lbtest.rb
marshaltestlib.rb
sentence.rb
test_alias.rb rb_alias: improve "undefined method" error message by invoking 2025-01-31 00:20:47 +09:00
test_allocation.rb Avoid allocation for positional splat for literal array keyword argument 2025-06-22 06:43:13 +09:00
test_argf.rb Update ARGF.write interface 2024-04-04 18:54:54 +09:00
test_arithmetic_sequence.rb
test_arity.rb Allow anonymous memberless Struct 2023-04-24 07:37:20 -07:00
test_array.rb Update comments for pack/unpack tests [ci skip] 2025-07-28 00:06:44 +09:00
test_assignment.rb Avoid opt_aset_with optimization inside multiple assignment 2025-01-08 08:49:51 -08:00
test_ast.rb Add NODE_DEFINED tests for cases with parentheses to test_ast.rb 2025-07-25 01:07:32 +09:00
test_autoload.rb namespace on read 2025-05-11 23:32:50 +09:00
test_backtrace.rb Set up callable_method_entry for DUMMY frame on ArgumentError 2025-06-24 11:39:58 +09:00
test_basicinstructions.rb
test_beginendblock.rb Disable callcc when ASAN is enabled 2024-03-04 13:07:26 +11:00
test_bignum.rb Improve performance of bignum[beg, len] (#14007) 2025-07-29 16:34:13 +00:00
test_call.rb Fix assertion failure with anonymous splats 2025-04-02 19:31:05 -07:00
test_case.rb Prevent a warning (retry) 2024-09-18 11:16:22 +09:00
test_class.rb Remove respond_to check from Class#bind_call 2025-05-12 14:10:29 -07:00
test_clone.rb rb_obj_setup: do not copy RUBY_FL_SEEN_OBJ_ID 2024-02-09 17:38:54 +01:00
test_comparable.rb Add tests for passing nil to Comparable#clamp(min, max) 2023-10-25 16:34:48 +09:00
test_compile_prism.rb Fix compilation for forwarding params in Prism 2025-07-17 18:00:33 -04:00
test_complex.rb Make Complex#{inspect,to_s} work correctly if real part #inspect returns frozen string 2024-09-21 20:00:23 +02:00
test_complex2.rb
test_complexrational.rb
test_condition.rb
test_const.rb
test_continuation.rb Disable callcc when ASAN is enabled 2024-03-04 13:07:26 +11:00
test_data.rb [Bug #21440] Stop caching member list in frozen Data/Struct class 2025-06-13 14:22:06 +09:00
test_default_gems.rb Ignore method chains succeeding git ls-files 2024-03-23 23:58:40 +09:00
test_defined.rb Handle void expressions in defined? 2025-03-18 14:44:28 -04:00
test_dir.rb Windows 11 24H2 with VS 2019 16.11.45 couldn't handle long name test 2025-04-08 15:46:45 +09:00
test_dir_m17n.rb Prefer the simple read/write File singleton methods 2024-03-16 23:44:07 +09:00
test_dup.rb Adding more clone tests, and adding dup tests 2022-06-16 08:48:08 -07:00
test_econv.rb Remove --disable-gems for assert_separately 2023-08-03 09:11:08 +09:00
test_encoding.rb Autoload encodings on the main ractor 2025-07-07 12:44:21 +02:00
test_enum.rb Enumerable#all?: Stop optimizing when a given block is not optimizable 2024-07-11 12:28:23 +09:00
test_enumerator.rb [Bug #21008] Normalize before sum to float 2025-01-07 11:38:51 +09:00
test_env.rb Ractor::Port 2025-05-31 04:01:33 +09:00
test_eval.rb Omit TestEval#test_outer_local_variable_under_gc_compact_stress with s390x 2024-12-23 09:39:08 +09:00
test_exception.rb Update ruby test for colon-style hash inspect 2024-10-03 18:47:09 +09:00
test_fiber.rb Removed Solaris conditions from test files 2025-04-02 16:24:47 +09:00
test_file.rb Rename variables to suit each method 2025-07-09 17:56:38 +09:00
test_file_exhaustive.rb Refine dirname test on Windows 2025-04-09 19:14:36 +09:00
test_fixnum.rb
test_flip.rb
test_float.rb [Bug #21163] Fix hexadecimal float conversion 2025-03-07 12:14:48 +09:00
test_fnmatch.rb
test_frozen.rb Added tests for setting ivars on frozen objs 2022-06-16 08:48:08 -07:00
test_frozen_error.rb
test_gc.rb Fix flaky TestGc#test_heaps_grow_independently 2025-06-26 16:38:39 -04:00
test_gc_compact.rb Fix typo in test_gc_compact.rb [ci skip] 2025-02-18 18:41:57 -05:00
test_hash.rb Change test to avoid stack overflow with MN threads 2025-05-23 21:28:16 +02:00
test_ifunless.rb
test_inlinecache.rb Avoid defining the same test class in multiple files 2022-04-22 15:00:16 -07:00
test_insns_leaf.rb
test_integer.rb Fix Integer.sqrt to never exceed actual value 2025-04-07 11:08:10 +09:00
test_integer_comb.rb [Bug #19335] Integer#remainder should respect #coerce (#7120) 2023-01-15 13:03:27 +09:00
test_io.rb Ensure that forked process do not see invalid blocking operations. (#13343) 2025-05-15 15:50:15 +09:00
test_io_buffer.rb io_buffer: Reimplement dcompact for IO::Buffer 2025-06-17 07:57:02 +02:00
test_io_m17n.rb Deprecate Kernel#open and IO support for subprocess creation/forking 2023-08-10 09:38:11 +09:00
test_io_timeout.rb Add support for sockaddr_un on Windows. (#6513) 2022-11-17 14:50:25 -08:00
test_iseq.rb Fix memory leak in Prism's RubyVM::InstructionSequence.new 2025-06-03 10:00:15 -04:00
test_iterator.rb Prevent warnings "the block passed to ... may be ignored" 2024-09-13 16:52:38 +09:00
test_key_error.rb
test_keyword.rb ruby2_keywords warnings: Quote non-UTF8 method names fully 2024-12-19 10:32:14 -05:00
test_lambda.rb [Feature #6012] Extend source_location for end position and columns 2025-01-09 20:21:41 +09:00
test_lazy_enumerator.rb Do not set Enumerator::Lazy#zip to use packed format 2024-07-20 18:16:42 -07:00
test_literal.rb [Bug #20988] [prism] Fix escaped octal character literals 2024-12-29 10:32:33 +09:00
test_m17n.rb Try all assertions in TestM17N#test_regexp_usascii 2025-01-03 10:10:54 +09:00
test_m17n_comb.rb
test_marshal.rb variable.c: Fix rb_ivar_foreach to not yield object_id of complex objects 2025-08-01 18:00:05 +02:00
test_math.rb math.c: Fix Math.log against huge bignum [Bug #19878] 2023-09-13 21:40:05 +09:00
test_memory_view.rb Ractor::Port 2025-05-31 04:01:33 +09:00
test_metaclass.rb
test_method.rb Set up callable_method_entry for DUMMY frame on ArgumentError 2025-06-24 11:39:58 +09:00
test_method_cache.rb
test_mixed_unicode_escapes.rb Switch the default parser from parse.y to Prism 2024-09-12 13:43:04 -04:00
test_module.rb [Bug #21094] Update nested module names when setting temporary name 2025-03-18 23:47:20 +09:00
test_name_error.rb
test_namespace.rb Introduce Namespace#eval 2025-06-26 10:18:14 -07:00
test_nomethod_error.rb Do not include a backtick in error messages and backtraces 2024-02-15 18:42:31 +09:00
test_not.rb
test_numeric.rb [Bug#19445] Fix keyword splat in enumerator 2023-02-17 10:57:22 +09:00
test_object.rb [Feature #21219] Selective inspect of instance variables 2025-06-09 09:25:37 +02:00
test_object_id.rb Struct: keep direct reference to IMEMO/fields when space allows 2025-08-06 17:07:49 +02:00
test_objectspace.rb rb_gc_impl_copy_finalizer: generate a new object id 2025-05-16 20:16:52 +02:00
test_optimization.rb opt_new needs to happen after safe navigation 2025-04-29 13:33:23 -07:00
test_pack.rb Expand opt_newarray_send to support Array#pack with buffer keyword arg 2024-07-29 16:26:58 -04:00
test_parse.rb [Bug #21026] no singleton method on pseudo variable literal 2025-03-20 17:32:26 +09:00
test_path.rb
test_pattern_matching.rb Update ruby test for colon-style hash inspect 2024-10-03 18:47:09 +09:00
test_pipe.rb
test_primitive.rb
test_proc.rb Suppress warnings for variables 2025-07-16 00:03:04 +09:00
test_process.rb test_process.rb: UID.from_name may raise Errno::ENOENT 2025-07-16 10:42:22 -07:00
test_ractor.rb Struct: keep direct reference to IMEMO/fields when space allows 2025-08-06 17:07:49 +02:00
test_rand.rb Avoid illegal pointer 2024-11-29 03:01:46 +09:00
test_random_formatter.rb Freeze Random::Formatter::ALPHANUMERIC and its elements 2024-12-16 20:54:40 +09:00
test_range.rb [Bug #21185] Fix Range#overlap? with infinite range 2025-03-17 16:26:23 +09:00
test_rational.rb Do not round a**b to infinity 2024-11-08 19:48:56 +09:00
test_rational2.rb
test_readpartial.rb
test_refinement.rb Remove deprecated method Refinement#refined_class 2024-11-19 14:33:38 +09:00
test_regexp.rb [Bug #19417] Make word prop match join_control ... 2025-07-10 21:28:41 +09:00
test_require.rb Use erb instead of ostruct for test_frozen_loaded_features 2025-01-08 17:12:19 +09:00
test_require_lib.rb Implement Set as a core class 2025-04-26 10:31:11 +09:00
test_rubyoptions.rb Suppress warnings for variables 2025-07-16 00:03:04 +09:00
test_rubyvm.rb [PRISM] Refactor parser support into its own module 2024-07-18 21:15:54 -04:00
test_set.rb [Bug #21513] Raise on converting endless range to set 2025-07-29 18:42:18 +09:00
test_settracefunc.rb Maintain same behavior regardless of tracepoint state 2025-05-15 14:19:48 -07:00
test_shapes.rb Fix rb_shape_transition_object_id transition to TOO_COMPLEX 2025-08-01 12:39:14 +02:00
test_signal.rb Fix race condition in test_self_stop 2024-11-08 22:13:15 -07:00
test_sleep.rb Replace all GC.disable with EnvUtil.without_gc 2024-09-17 10:34:26 -04:00
test_sprintf.rb Fix update_coderange for binary strings 2024-11-08 17:39:19 -08:00
test_sprintf_comb.rb
test_stack.rb EnvUtil.invoke_ruby also passes ASAN options 2023-08-02 19:55:30 +09:00
test_string.rb Update comments for pack/unpack tests [ci skip] 2025-07-28 00:06:44 +09:00
test_string_memory.rb Replace all GC.disable with EnvUtil.without_gc 2024-09-17 10:34:26 -04:00
test_stringchar.rb
test_struct.rb [Bug #21440] Stop caching member list in frozen Data/Struct class 2025-06-13 14:22:06 +09:00
test_super.rb Prevent method redefinition warnings in test 2024-11-07 13:18:57 +09:00
test_symbol.rb Prevent a warning due to error recovery of prism 2024-09-17 14:15:44 +09:00
test_syntax.rb Revert "[Bug #21256] Fix it parameter when splatting and define_method is…" 2025-07-18 13:28:46 +09:00
test_system.rb [Bug #19624] Hide internal IO for backquote 2023-05-01 05:10:34 +09:00
test_thread.rb Fix a flaky test by making sure that a test thread stops 2025-04-24 19:06:49 +09:00
test_thread_cv.rb Remove stale tests 2023-03-10 11:54:59 +09:00
test_thread_queue.rb record load average at fail 2025-06-08 04:24:56 +09:00
test_threadgroup.rb
test_time.rb Win32: Defer change of timezone name encoding after 3.4 2024-12-24 13:25:55 +09:00
test_time_tz.rb [Bug #20327] Do not count subsecond to calculate UTC offset 2024-03-07 13:08:37 +09:00
test_trace.rb
test_transcode.rb [Bug #18651] Pass undefined region in CP51932 as is to CP50220 2024-09-20 16:23:55 +09:00
test_undef.rb
test_unicode_escape.rb
test_variable.rb Suppress warnings for variables 2025-07-16 00:03:04 +09:00
test_vm_dump.rb Try to run ignored tests with macOS 15 2025-06-11 15:40:52 +09:00
test_warning.rb Add regression test for Bug #20573 2024-06-12 10:25:57 -07:00
test_weakkeymap.rb Fix use-after-free in WeakKeyMap#clear 2024-08-23 16:37:11 -04:00
test_weakmap.rb Fix WeakMap use-after-free 2024-08-22 10:01:55 -04:00
test_whileuntil.rb [Bug #20094] Distinguish begin and parentheses 2023-12-27 17:50:15 +09:00
test_yield.rb
test_yjit.rb Prevent enabling yjit when zjit enabled (GH-13358) 2025-05-16 17:31:43 +00:00
test_yjit_exit_locations.rb YJIT: Fallback opt_getconstant_path for const_missing (#8623) 2023-10-13 08:52:23 -07:00
test_zjit.rb ZJIT: Enable IncrCounter for arm64 (#14086) 2025-08-01 17:37:00 -07:00
ut_eof.rb