Skip to content

[CALCITE-7985] Bindables generated by EnumerableInterpretable keep their bytecode on the heap - #5474

Open
vlsi wants to merge 1 commit into
apache:mainfrom
vlsi:codex/calcite-7985-release-class-bytes
Open

vlsi wants to merge 1 commit into
apache:mainfrom
vlsi:codex/calcite-7985-release-class-bytes

Conversation

@vlsi

@vlsi vlsi commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Jira Link

CALCITE-7985

Changes Proposed

A cached Bindable keeps its defining loader alive. Janino’s loader keeps the original class-file byte arrays on the heap after the JVM defines those classes.

For Janino compilations without an active security manager, use a Calcite-owned loader that releases each byte array after defineClass succeeds. It keeps pending companion definitions available for lazy loading. Other compiler providers and compilations with an active security manager use the compiler’s loader. The new loader delegates resource lookups to its parent, consistent with Janino 3.1.12’s behavior for generated class files.

Reproduction

I ran Austin Richardson’s 20,000-query repro on Calcite 1.42.0 with and without the equivalent loader patch. Both runs used Janino 3.1.12, Corretto 21.0.9, G1, -Xms128m -Xmx512m, and -Dcalcite.bindable.cache.maxSize=100000. The table shows post-full-GC measurements in MiB.

Loader Retained byte arrays Total heap used Bindable Metaspace used
Janino 3.1.12 loader 145.47 305.00 488.18
Calcite loader 0 149.50 488.18

With the Bindable cache disabled, all 20,000 Bindable loaders unloaded in both runs by the final GC.

@vlsi
vlsi force-pushed the codex/calcite-7985-release-class-bytes branch from 967f429 to e1e1e19 Compare December 4, 2026 15:37
…eir bytecode on the heap

A cached Bindable keeps its defining loader alive. Janino's loader
retains the original class files after defining the generated classes.

Use a Calcite loader for Janino compilations without an active security
manager. Release each byte array after successful definition and keep
pending definitions available for companions that load later.

Reported-by: Austin Richardson
Generated-by: OpenAI Codex
@vlsi
vlsi force-pushed the codex/calcite-7985-release-class-bytes branch from e1e1e19 to 9569bb7 Compare December 4, 2026 16:33
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

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