Skip to content

Instantly share code, notes, and snippets.

@shugo
Created February 10, 2022 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shugo/eabc9c67b09e5f4e90afc2b85f98580c to your computer and use it in GitHub Desktop.
Save shugo/eabc9c67b09e5f4e90afc2b85f98580c to your computer and use it in GitHub Desktop.
b9007b6c548f91e88fd3f2ffa23de740431fa969 is the first bad commit
commit b9007b6c548f91e88fd3f2ffa23de740431fa969
Author: Koichi Sasada <ko1@atdot.net>
Date: Wed Jan 8 16:14:01 2020 +0900
Introduce disposable call-cache.
This patch contains several ideas:
(1) Disposable inline method cache (IMC) for race-free inline method cache
* Making call-cache (CC) as a RVALUE (GC target object) and allocate new
CC on cache miss.
* This technique allows race-free access from parallel processing
elements like RCU.
(2) Introduce per-Class method cache (pCMC)
* Instead of fixed-size global method cache (GMC), pCMC allows flexible
cache size.
* Caching CCs reduces CC allocation and allow sharing CC's fast-path
between same call-info (CI) call-sites.
(3) Invalidate an inline method cache by invalidating corresponding method
entries (MEs)
* Instead of using class serials, we set "invalidated" flag for method
entry itself to represent cache invalidation.
* Compare with using class serials, the impact of method modification
(add/overwrite/delete) is small.
* Updating class serials invalidate all method caches of the class and
sub-classes.
* Proposed approach only invalidate the method cache of only one ME.
See [Feature #16614] for more details.
class.c | 45 +-
common.mk | 1 +
compile.c | 38 +-
debug_counter.h | 92 ++--
eval.c | 2 +-
ext/objspace/objspace.c | 1 +
gc.c | 204 +++++++-
id_table.c | 2 +-
insns.def | 13 +-
internal/class.h | 2 +
internal/imemo.h | 4 +
internal/vm.h | 41 +-
iseq.c | 17 +
method.h | 11 +-
mjit.c | 19 +-
mjit.h | 29 ++
mjit_compile.c | 42 +-
mjit_worker.c | 30 +-
test/-ext-/tracepoint/test_tracepoint.rb | 12 +-
test/ruby/test_gc.rb | 3 +
test/ruby/test_inlinecache.rb | 64 +++
tool/mk_call_iseq_optimized.rb | 2 +-
tool/ruby_vm/views/_mjit_compile_send.erb | 23 +-
tool/ruby_vm/views/mjit_compile.inc.erb | 2 +-
vm.c | 26 +-
vm_callinfo.h | 235 ++++++++-
vm_core.h | 3 +-
vm_dump.c | 4 +-
vm_eval.c | 50 +-
vm_insnhelper.c | 814 ++++++++++++++++--------------
vm_insnhelper.h | 15 +-
vm_method.c | 630 ++++++++++++++---------
32 files changed, 1606 insertions(+), 870 deletions(-)
create mode 100644 test/ruby/test_inlinecache.rb
bisect run success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment