Skip to content

Add locations at recursive methods. - #5

Open
Pavel-Durov wants to merge 3 commits into
ykjit:masterfrom
Pavel-Durov:yk-recursive-locations
Open

Pavel-Durov wants to merge 3 commits into
ykjit:masterfrom
Pavel-Durov:yk-recursive-locations

Conversation

@Pavel-Durov

@Pavel-Durov Pavel-Durov commented Oct 19, 2026 •

Copy link
Copy Markdown

As in yklua, each irep now carries a called flag. It is set on frame entry and cleared in cipop.

The recursive benchmarks gain the most -Towers is 5.5x faster, CD 1.9x, Storage 1.7x and Bounce 14%. Queens, Mandelbrot, DeltaBlue, List and Json gain only 2–5%, and Sieve, Havlak and Permute unchanged.
Queens is recursive yet gains only 4.65%, and I plan to investigate why as a follow-up.

AWFY Benchmarks comparing with ykmruby/master

 Benchmark              master (ms)  this (ms)  Ratio  Summary
 Towers/mruby/600         97760 ±  90    17910 ±  53   0.18  81.68% faster
 CD/mruby/250            114998 ±2052    59238 ± 657   0.52  48.49% faster
 Storage/mruby/1000      118278 ± 182    71173 ±8168   0.60  39.83% faster
 Bounce/mruby/1500        27717 ± 105    23849 ±  36   0.86  13.95% faster
 NBody/mruby/250000       53106 ±  76    48240 ±  79   0.91  9.16% faster
 Richards/mruby/100      105342 ±1808    98468 ± 779   0.93  6.53% faster
 Queens/mruby/1000        13502 ± 405    12875 ±  71   0.95  4.65% faster
 Mandelbrot/mruby/500      7178 ±   2     6879 ±  20   0.96  4.17% faster
 DeltaBlue/mruby/12000    20505 ± 151    19859 ± 213   0.97  3.15% faster
 List/mruby/1500          16843 ± 108    16366 ±  81   0.97  2.83% faster
 Json/mruby/100           40472 ± 269    39648 ±  83   0.98  2.04% faster
 Sieve/mruby/3000         15199 ±  62    15060 ±  96   0.99  indistinguishable
 Havlak/mruby/15         161715 ± 722   160596 ± 823   0.99  indistinguishable
 Permute/mruby/1000       17404 ± 524    17665 ±  39   1.01  indistinguishable

haste.zip

As in yklua, an irep now carries a `called` flag, set on frame
entry and cleared in cipop.
Comment thread src/vm.c Outdated
if (!irep->yk_locs) ((mrb_irep*)irep)->yk_locs = yk_init_loc(mrb, irep); \
} \
yk_mt_control_point(yk_mt, &((YkLocation*)irep->yk_locs)[(size_t)(yk_pc - irep->iseq)]); \
mrb_jit_yk_hook(mrb, irep, yk_pc); \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before: you cannot rely on inlining. Please put that code inline. Otherwise everything (more-or-less) looks good.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my bad. Updated 06dad17

Comment thread include/mruby/yk.h Outdated
@Pavel-Durov

Copy link
Copy Markdown
Author

Moved recursive detection to call sites in 8035563.
This change makes DeltaBlue 3.73% faster. List and NBody are ~1–2% faster, Permute and Mandelbrot ~1% slower.
The rest of the benchmarks are indistinguishable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants