Skip to content

Conversation

Akirathan
Copy link
Member

@Akirathan Akirathan commented Aug 28, 2025

Closes #13816

Blocked by #13918

Pull Request Description

Using java.lang.foreign.Arena for mmapping a big cache file when loading the cache.

Important Notes

  • When loading big cache file:
    • A previous Arena is closed. Which invalidates any byte buffers associated with that Arena.
    • New Arena is created.
    • File is mmapped via that new arena.
  • Both load and save closes previous arena.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.
  • If meaningful changes were made to logic or tests affecting Enso Cloud integration in the libraries,
    or the Snowflake database integration, a run of the Extra Tests has been scheduled.
    • If applicable, it is suggested to paste a link to a successful run of the Extra Tests.

@Akirathan Akirathan self-assigned this Aug 28, 2025
@Akirathan Akirathan added CI: No changelog needed Do not require a changelog entry for this PR. CI: Clean build required CI runners will be cleaned before and after this PR is built. labels Aug 28, 2025
.settings(
frgaalJavaCompilerSetting,
// Needed for `java.lang.Foreign`.
customFrgaalJavaCompilerSettings("24"),
Copy link
Member

Choose a reason for hiding this comment

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

  • I was afraid that this would be needed.
  • I wanted to suggest to create a separate runtime-caches module:
    • move all the cache related code there
    • invoke it with requires (from runtime)/provides pattern
    • if the runtime-caches module is missing, then runtime would just avoid loading caches
  • Because such a change would prevent usage of runtime inside of IGV/VSCode on LTS JDK (e.g. JDK 21)
  • but we don't need runtime in there anyway
    • the plans we have count with usage of runtime-compiler at max
    • and runtime-compiler can still run on JDK21, maybe even JDK17

Copy link
Member Author

Choose a reason for hiding this comment

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

Tracked in #13898

Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

  • close mmapped files first, only then write
  • avoid yet another level of indirection - e.g. remove statistics abstractions

Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

I'd suggest to keep allocate new Arena when mmapping.

Previous arena is closed both in load and save.
# Conflicts:
#	engine/runtime/src/main/java/org/enso/interpreter/caches/Cache.java
@JaroslavTulach JaroslavTulach mentioned this pull request Sep 30, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: No changelog needed Do not require a changelog entry for this PR. x-on-hold
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider using Foreign Memory API when reading .bindings
2 participants