Skip to content

WIP: feat: add GraalVM native-image support #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

avelino
Copy link
Member

@avelino avelino commented Mar 5, 2025

This commit introduces GraalVM native-image support for ChronDB, enabling the creation of standalone native executables. Key changes include:

  • Added GraalVM native-image build workflow for Ubuntu and macOS
  • Created reflection and resource configuration files for GraalVM
  • Added build scripts for generating native images
  • Updated project documentation with native-image build instructions
  • Configured deps.edn for native-image compatibility
  • Reorganized documentation structure

These changes allow ChronDB to be compiled into a native binary, improving startup time and reducing memory footprint while maintaining full functionality.

fixed: #12

This commit introduces GraalVM native-image support for ChronDB, enabling the creation of standalone native executables. Key changes include:

- Added GraalVM native-image build workflow for Ubuntu and macOS
- Created reflection and resource configuration files for GraalVM
- Added build scripts for generating native images
- Updated project documentation with native-image build instructions
- Configured deps.edn for native-image compatibility
- Reorganized documentation structure

These changes allow ChronDB to be compiled into a native binary, improving startup time and reducing memory footprint while maintaining full functionality.

Signed-off-by: Avelino <[email protected]>
Copy link

coderabbitai bot commented Mar 5, 2025

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (4)
  • wip
  • WIP
  • draft
  • DRAFT

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

avelino added 24 commits March 5, 2025 07:49
> actions/upload-artifact@v3 is scheduled for deprecation on November 30, 2024. Learn more. Similarly, v1/v2 are scheduled for deprecation on June 30, 2024. Please update your workflow to use v4 of the artifact actions. This deprecation will not impact any existing versions of GitHub Enterprise Server being used by customers.

Signed-off-by: Avelino <[email protected]>
- Add continue-on-error to wait-for-test step
- Add allowed-conclusions (success,skipped)
- Add verbose mode for better debugging
- Add running-workflow-name to identify the workflow

Signed-off-by: Avelino <[email protected]>
- Remove dependency on test completion for native image build
- Change test check to be optional and non-blocking
- Rename job to better reflect its optional nature

Signed-off-by: Avelino <[email protected]>
- Add diagnostic script to help troubleshoot native-image build failures
- Implement build retry with explicit initialization parameters
- Continue pipeline execution even if initial build fails

Signed-off-by: Avelino <[email protected]>
- Added support for building JAR before native image
- Improved error handling during JAR building
- Added libz support for macOS and Linux systems
- Improved environment variables management
- Added support for extra compilation flags

Signed-off-by: Avelino <[email protected]>
- Adjust string format in workflow file
- Add extra flags for class initialization in GraalVM
- Improve build script for libz support across different systems

Signed-off-by: Avelino <[email protected]>
- Disabled default class initialization at build time
- Explicitly specified classes that should be initialized at runtime
- Added tracking for problematic class initialization
- Included additional classes that were causing issues:
  - com.sun.jndi.dns.DnsClient
  - sun.security.jca.JCAUtil$CachedSecureRandomHolder
  - org.eclipse.jgit.util.sha1.SHA1
  - org.eclipse.jgit.lib.RepositoryCache

Signed-off-by: Avelino <[email protected]>
- Removed `com.sun.jndi.dns.DnsClient` from runtime initialization list
- Added critical classes for runtime initialization:
  - sun.security.jca.JCAUtil$CachedSecureRandomHolder
  - org.eclipse.jgit.util.sha1.SHA1
  - org.eclipse.jgit.lib.RepositoryCache

Signed-off-by: Avelino <[email protected]>
…untime initialization class list

The issue was related to premature class initialization during native image building. The sun.security.jca.JCAUtil$CachedSecureRandomHolder class was removed from the list of classes that should be initialized at runtime, as it was unnecessary and causing build issues.

Signed-off-by: Avelino <[email protected]>
- Adopt clj-easy/graalvm-clojure recommended practices
- Remove unnecessary class initialization flags
- Streamline build configuration for better maintainability
- Focus on essential initialization controls for Clojure and problematic classes

Signed-off-by: Avelino <[email protected]>
- Added support for clj-easy/graal-build-time to manage class initialization
- Simplified build process by removing manual initialization flags
- Added GraalVM-specific configurations for Lucene
- Updated build script for better support across different operating systems
- Added automatic detection and configuration of native libraries (libz)
- Improved error handling and logging during build process

Signed-off-by: Avelino <[email protected]>
This commit adds support for building ChronDB as a native binary using GraalVM native-image. The changes include:

- Added necessary GraalVM configuration for native-image compilation
- Configured class initialization settings for Jetty, Lucene, and SLF4J
- Added trace class initialization for critical components
- Disabled security manager and unsupported codec checks for Lucene
- Implemented fallback index when Lucene initialization fails
- Updated build configuration to support native-image compilation

These changes enable ChronDB to be compiled into a standalone native binary,
improving startup time and reducing memory footprint while maintaining full functionality.

Signed-off-by: Avelino <[email protected]>
…uild

This change ensures that the ConcurrentMergeScheduler class from Apache Lucene
is initialized at runtime rather than build time, which is necessary for proper
functionality in the native image. This fixes potential initialization issues
that could occur during the native image build process.

Signed-off-by: Avelino <[email protected]>
Adds support for native libraries (libz, libpthread, libdl) required for
the native image build process. Includes:

- Automatic dependency installation on Linux via apt-get
- Automatic dependency installation on macOS via brew
- Verification of libraries presence after installation
- Build script adjustments for better path handling
- Improvements in build environment detection and configuration

These changes resolve linking issues encountered during native image
building across different operating systems.

Signed-off-by: Avelino <[email protected]>
This change adds:
- Simplified mode for native image generation (for CI and restricted environments)
- Solution for the ScopedMemoryAccess problem via JNI and substitutions
- Automatic CI environment detection to use appropriate configurations
- Improved reflection configuration for Lucene classes
- Support for JNI compilation across different platforms

Signed-off-by: Avelino <[email protected]>
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.

Implement GraalVM Native Image support for binary distribution
1 participant