Upgrade to Pro — share decks privately, control downloads, hide ads and more …

rage against annotate_predecessor

rage against annotate_predecessor

Avatar for Junichi Kobayashi

Junichi Kobayashi

August 30, 2025
Tweet

More Decks by Junichi Kobayashi

Other Decks in Programming

Transcript

  1. 自己紹介 Junichi Kobayashi • X / GitHub: @junk0612 • Working

    at ESM, Inc. ◦ Work as a Rails engineer ◦ A Member of Parser Club • Committer of Lrama • Hobbies ◦ Parsers ◦ Rhythm games ◦ Board games ◦ Haiku
  2. Optimize IELR Calculation $ time bundle exec lrama -D lr.type=ielr

    parse.y 69.02s user 0.29s system 99% cpu 1:09.38 total
  3. Optimize IELR Calculation $ time bundle exec lrama -D lr.type=ielr

    parse.y 69.02s user 0.29s system 99% cpu 1:09.38 total $ time bundle exec lrama -D lr.type=ielr parse.y 11.51s user 0.26s system 82% cpu 14.193 total
  4. Optimize IELR Calculation $ time bundle exec lrama -D lr.type=ielr

    parse.y 69.02s user 0.29s system 99% cpu 1:09.38 total $ time bundle exec lrama -D lr.type=ielr parse.y 11.51s user 0.26s system 82% cpu 14.193 total 6x Faster !!!
  5. s s' s'' t C': kernels Γ: Conflicted Actions C:

    kernels γ: Contribution Matrix (Size: [|Γ|][|C'|]) For each action 1≦i≦Γ and kernel item 1≦j≦C', γ[i][j] is true iff C'[j] may contribute token t into Γ[i]'s lookahead set at state s''.
  6. s s' s'' t C': kernels Γ: Conflicted Actions C:

    kernels γ: Contribution Matrix (Size: [|Γ|][|C'|]) For each action 1≦i≦Γ and kernel item 1≦j≦C', γ[i][j] is true iff C'[j] may contribute token t into Γ[i]'s lookahead set at state s''. annotate_predecessor
  7. The Naive Implementation class State def annotate_predecessor(predecessor) @annotation_list.each do |annotation|

    annotation.actions.each do |action| @kernels.each do |kernel| predecessor.kernels.each do |pred_kernel| ...
  8. s s' s'' t C': kernels Γ: Conflicted Actions C:

    kernels γ: Contribution Matrix (Size: [|Γ|][|C'|]) For each action 1≦i≦Γ and kernel item 1≦j≦C', γ[i][j] is true iff C'[j] may contribute token t into Γ[i]'s lookahead set at state s''. annotate_predecessor
  9. Lanes • A: 'a' 'a'・, ['a', 'b'] • A: 'a'・,

    ['a', 'b'] • A: 'a'・'a', ['a', 'b'] a
  10. Cache Lanes $ time bundle exec lrama -D lr.type=ielr parse.y

    69.02s user 0.29s system 99% cpu 1:09.38 total $ time bundle exec lrama -D lr.type=ielr parse.y 24.02s user 0.25s system 108% cpu 22.275 total
  11. Cache Lanes $ time bundle exec lrama -D lr.type=ielr parse.y

    24.02s user 0.29s system 99% cpu 1:09.38 total $ time bundle exec lrama -D lr.type=ielr parse.y 11.51s user 0.26s system 82% cpu 14.193 total
  12. ✦ Optimize IELR calculation ✦ Introduce IELR to CRuby and

    make parse.y better ← ??? Future Work
  13. ✦ Tokens in the same group are temporarily equivalent for

    IELR ✦ If token paths differ, detect it as an Inadequacy Annotation Token Group