Kaui: evaluate enabling JRuby invokedynamic (setenv.sh hard-codes -Djruby.compile.invokedynamic=false)

未关闭
#349 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@tungleduyxyz 已经在做这个了。

开始于 2026年11月4日。

评估

这个 Issue 还没有评估数据。

描述

perf

Summary

The shared Tomcat setenv.sh template turns JRuby's invokedynamic support off for every image built from it, Kaui included. A JRuby performance team recommends turning it on:

Method profiles end up being heavily polluted by non-indy method call logic, including some places that appear to be polymorphic and could benefit from the indy logic's polymorphic cache. [...] it will improve the quality of the profiles and it should perform better (if it does not then that's what we need to investigate, because it blows non-indy away on smaller stuff).

Where

ansible/templates/tomcat/conf/setenv.sh.j2#L35 (same line on master and java2x):

-Djruby.compile.invokedynamic=false
  • The base image is shared by the Kill Bill and Kaui images. The setting was probably added for Kill Bill's JRuby plugins; it isn't documented why.
  • It is present on the Java 21 / Tomcat 11 perf server, running Kill Bill 0.25.5 + Kaui 4.0.26 / JRuby 10.0.6.0 (checked on the running JVM's command line).
  • Kaui can override it without touching Kill Bill: ansible/templates/kaui/conf/setenv2.sh.j2 appends {{ kaui_system_properties }} to CATALINA_OPTS after setenv.sh, and for a repeated -D the JVM uses the last value.

Relationship with the JIT login bug

The Kaui login bug (killbill/killbill-admin-ui-standalone#131) happens with invokedynamic on and off. It is a JIT bug in JRuby 10.0.x, fixed in 10.1.1.0+ (see killbill/killbill-admin-ui-standalone#133). So enabling indy is not blocked by it, as long as the current workaround (-Djruby.jit.exclude=Rails::Engine#call, killbill/killbill-cloud#346) or JRuby 10.1.1+ is in place.

Plan

  1. Experiment on the perf server, Kaui only: add -Djruby.compile.invokedynamic=true (keeping the jit.exclude workaround).
  2. Run the same Gatling scenarios as the baseline (killbill-admin-ui-standalone perf/, 10 users, 600 s), after warm-up: indy usually costs more at startup/warm-up and pays off once warm. Capture JFR for each run.
  3. Compare with the baseline below. Check method profiles (less call-site overhead), allocation, p75/p95/p99, and warm-up time.
  4. If it's better, change the default for the Kaui image only (via kaui_system_properties or the Kaui setenv2.sh.j2). Kill Bill's setting stays as is unless the Kill Bill team wants to evaluate it too.

Baseline (indy off, G1, shared Kill Bill + Kaui JVM on a t2.medium):

Scenario p75 p95 p99
realistic mix 1,097 ms 1,978 ms —
account_show — 331 ms —
timeline 292 ms 1,601 ms 2,533 ms

Acceptance criteria

  • Before/after Gatling results and JFR recordings with indy on vs off (same instance, same data, after warm-up)
  • Decision recorded; if positive, the Kaui image/role defaults to -Djruby.compile.invokedynamic=true, and the reason for keeping (or changing) Kill Bill's setting is documented in setenv.sh.j2

Related

  • killbill/killbill-admin-ui-standalone#131 / #133: JIT login bug and the JRuby 10.1 upgrade
  • killbill/killbill-cloud#346: the jit.exclude workaround
  • killbill/killbill-cloud#344: Tomcat 11 / JDK 21
  • killbill/killbill-client-ruby#125, #126 and killbill/killbill-admin-ui-standalone#136: the other items from the same profiling round
主要语言
Ruby
星标
68
派生
93
平均合并
1 天 13 小时
30 天内合并 PR
4

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

killbill/killbill-cloud 的其他 Issue

查看 killbill/killbill-cloud 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。