Skip to content

Make bridge generation cacheable and incremental - #33

Merged
kdroidFilter merged 1 commit into
mainfrom
feat/incremental-bridge-generation
Oct 5, 2026
Merged

kdroidFilter merged 1 commit into
mainfrom
feat/incremental-bridge-generation

Conversation

@kdroidFilter

Copy link
Copy Markdown
Collaborator

Summary

  • generateKneNativeBridges is now a @CacheableTask; sources are merged in a deterministic order (roots in declaration order, files sorted by relative path) so outputs are reproducible and relocatable.
  • Source file → IR mapping: each file maps to a cached prescan + IR fragment (build/kne/incremental, Gradle local state). A file is re-parsed only if its content changed or a symbol it looked up now resolves differently. The PSI environment is not started when nothing needs parsing.
  • IR → outputs mapping: codegen is skipped when the merged API is unchanged; otherwise only changed generated files are rewritten and stale ones deleted (previously the output dirs were wiped every run and stale jvmResources metadata was never cleaned).
  • Type resolution moved to a PSI-free SymbolTable/TypeResolver with lookup tracking; KneType singletons are data objects with readResolve so they round-trip through the cache.
  • Removed unused prescan sets; README updated.

Note: calculator's kne_bridges.kt / GraalVM JSON are reordered once due to the deterministic merge order (same content); systeminfo and benchmark outputs are byte-identical.

Test plan

  • Plugin unit tests (new PsiSourceParserIncrementalTest, GeneratedOutputsTest)
  • :examples:calculator:jvmTest and :examples:systeminfo:jvmTest pass; benchmark compiles
  • Calculator: no change → UP-TO-DATE; body edit → 1 file parsed, codegen skipped; API edit → 1 file parsed, 2 outputs rewritten; revert → matches baseline
  • Deleting outputs with --build-cache restores them FROM-CACHE

Map each source file to a cached prescan and IR fragment, re-parsing only
files whose content changed or whose looked-up symbols now resolve
differently. Skip codegen when the merged API is unchanged, rewrite only
changed outputs and delete stale ones. Merge sources in a deterministic
order and mark the task @CacheableTask.
@kdroidFilter
kdroidFilter merged commit c164c79 into main Oct 5, 2026
1 check passed
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.

1 participant