When JIT code size (RubyVM::YJIT.runtime_stats[:code_region_size])
reaches this value, YJIT triggers "code GC" that frees all JIT
code and starts recompiling everything. Compiling code takes
some time, so scheduling code GC too frequently slows down your
application. Increasing --yjit-exec-mem-size may speed up your
application if RubyVM::YJIT.runtime_stats[:code_gc_count] is
not 0 or 1.
https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md#co...It just dumps all the JIT-compiled code? I'd expect to see some kind of heuristic or algorithm there... LFU or something.
The internals of a JIT are essentially black magic to me, and I know the people working on YJIT are super talented, so I am sure there is a good reason why they just dump everything instead of the least-frequently used stuff. Maybe the overhead of trying frecency outweighs the gains, maybe they just haven't implemented it yet, or maybe it's just a rarely-reached condition.
(I hope a YJIT team member sees this, I'm super curious now)