Skip to content

feat(kotlin): Karbine ABI compile-avoidance (opt-in) — closes #11#21

Merged
Sam Gammon (sgammon) merged 1 commit into
mainfrom
fix/issue-11
Jun 23, 2026
Merged

feat(kotlin): Karbine ABI compile-avoidance (opt-in) — closes #11#21
Sam Gammon (sgammon) merged 1 commit into
mainfrom
fix/issue-11

Conversation

@sgammon

Copy link
Copy Markdown
Member

Implements #11: consume Elide's Karbine --abi-only capability so dependents key on a body-stable ABI header jar, pruning rebuilds on method-body edits.

What

New opt-in build setting //config/kotlinc:abi_compile_avoidance (default off). When enabled, a kt-only elide_kotlin_* target's JavaInfo.compile_jar comes from a dedicated, codegen-free elide kotlinc --abi-only header action instead of java_common.run_ijar:

  • Body edit → byte-identical header → dependents pruned. Replaces the body-sensitive Kotlin run_ijar jar (the "Bug 1" cascade).
  • Critical-path collapse: dependents wait on the fast header action, not the full compile (which runs in parallel).
  • Sound: const/inline/signature changes still change the header, so dependents that need to rebuild still do.

Scope

elide kotlinc --abi-only emits Kotlin ABI only, so mixed kt+java targets keep the run_ijar jar (correct, just not pruned). Mixed-source support filed upstream as WHIPLASH#1149.

Tests (per the issue's "verify empirically" ask)

  • Analysis tests (//tests, CI-gating): flag-on emits the ElideKotlincAbi --abi-only action and wires compile_jar to the _abi.jar; mixed kt+java does not take the abi path and keeps the ijar.
  • e2e/abi_avoidance/run.sh (real-elide soundness harness): asserts body & default-arg edits keep the header identical, while const/inline/signature edits change it — plus the two --abi-only behaviors the rule relies on (accepts -d <jar>; Kotlin-only on mixed sources). All 7 assertions green against 1.3.4+20260623.

Default-off, so zero behavior change until opted in. //tests/... 35/35.

Add //config/kotlinc:abi_compile_avoidance (default off). When enabled, a
kt-only target's JavaInfo.compile_jar comes from a dedicated, codegen-free
`elide kotlinc --abi-only` header action instead of java_common.run_ijar. The
header is body-stable: a method-body edit yields a byte-identical jar (same
digest), so Bazel prunes every dependent rebuild, and dependents key on the
fast header action rather than the full compile. const/inline/signature
changes still change the header, so pruning stays sound.

`elide kotlinc --abi-only` emits Kotlin ABI only, so this is scoped to kt-only
targets; mixed kt+java keeps the run_ijar compile jar (mixed-source ABI is
filed upstream).

Tests:
- Analysis tests (//tests): flag-on emits an ElideKotlincAbi `--abi-only`
  action and wires compile_jar to the `_abi.jar`; mixed kt+java does NOT take
  the abi path and keeps the ijar.
- e2e/abi_avoidance/run.sh: real-elide soundness harness asserting body/
  default-arg edits keep the header identical while const/inline/signature
  edits change it, plus the two --abi-only behaviors the rule relies on
  (jar output; Kotlin-only on mixed sources).
@codspeed-hq

codspeed-hq Bot commented Jun 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 3 untouched benchmarks


Comparing fix/issue-11 (963cee2) with main (1bff695)

Open in CodSpeed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an opt-in Kotlin build optimization that leverages Elide Karbine’s kotlinc --abi-only mode to produce a body-stable ABI/header jar for Kotlin-only targets, allowing Bazel dependents to key off the header jar and avoid rebuild cascades on method-body-only edits.

Changes:

  • Introduces //config/kotlinc:abi_compile_avoidance (default off) to enable ABI compile-avoidance for Kotlin-only targets.
  • Implements a dedicated ElideKotlincAbi header action in run_kotlinc and wires JavaInfo.compile_jar to the produced _abi.jar when enabled (fallback to run_ijar for mixed kt+java).
  • Adds analysis tests validating action emission/wiring behavior and an e2e/abi_avoidance harness for empirical soundness checks.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/kotlin_rule_test.bzl Adds analysis tests covering the ABI header action and mixed-source fallback behavior.
elide/rules/kotlin.bzl Routes Kotlin rule JavaInfo.compile_jar through a new compile_jar_override returned from run_kotlinc.
elide/private/compile_common.bzl Implements --abi-only header action generation and supports overriding compile_jar in make_java_info.
e2e/abi_avoidance/run.sh Adds a local soundness script validating header stability vs ABI-affecting edits and key --abi-only behaviors.
e2e/abi_avoidance/README.md Documents the ABI avoidance soundness harness and how/why to run it.
config/kotlinc/BUILD.bazel Adds the new abi_compile_avoidance build setting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/kotlin_rule_test.bzl
@sgammon Sam Gammon (sgammon) merged commit aa84819 into main Jun 23, 2026
15 checks passed
@sgammon Sam Gammon (sgammon) deleted the fix/issue-11 branch June 23, 2026 23:57
This was referenced Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants