Skip to content

Conversation

@andreaTP
Copy link

This PR

This PR uses the Chicory compiler at build time instead of the(default) slow interpreter.
You can check the differences in the docs.
With this configuration I'd expect a huge increase of performance, also you don't need anymore to carry around the original wasm file as everything is taken care by the Maven plugin.

Related Issues

Fixes #1234523

Notes

@aepfli successful nerd snipe 😅 congratz!

Follow-up Tasks

Using the @WasmModuleInterface annotation to have an automatically typed version of the exported functions.
Given, at the moment, there are only 3 exported functions this looks superfluous ...

How to test

Same functionality and tests as before just going faster 🚀

@gemini-code-assist
Copy link

Summary of Changes

Hello @andreaTP, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant performance improvement for the Go-Feature-Flag provider by integrating the Chicory compiler. Instead of interpreting the WebAssembly module at runtime, the WASM is now compiled into Java bytecode during the build process. This change not only promises a substantial speedup but also simplifies deployment by embedding the compiled module directly, removing the need for external WASM file management.

Highlights

  • Performance Enhancement: Switched from the Chicory interpreter to the Chicory compiler to compile Go-Feature-Flag WASM to Java bytecode at build time, significantly boosting performance.
  • Build Process Streamlining: The Maven build now directly compiles the WASM module, eliminating the need to download and carry the original .wasm file.
  • Dependency Updates: The chicory-wasi dependency has been updated to version 1.6.0, and the chicory-runtime dependency has been removed as it's no longer needed with the compiler approach.
  • Codebase Refactoring: The EvaluationWasm.java class has been updated to load the pre-compiled Java bytecode module, simplifying the WASM instantiation process.
  • Static Analysis Adjustments: Added new SpotBugs exclusions for generated classes (ModuleMachine, ModuleMachineFuncGroup_0) to accommodate the Chicory compiler's output.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great improvement, migrating the GO Feature Flag provider to use the Chicory AOT compiler instead of the interpreter. This should result in a significant performance boost as mentioned in the description. The changes in pom.xml to use the chicory-compiler-maven-plugin and the corresponding adjustments in EvaluationWasm.java to load the pre-compiled module are well-implemented.

I have one suggestion to improve build reproducibility by pinning the version of the new Maven plugin.

Additionally, it seems the download-wasm.sh script is now obsolete with these changes and could be removed to keep the codebase clean.

Overall, this is a solid contribution that improves the performance and packaging of the provider.

<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<groupId>com.dylibso.chicory</groupId>
<artifactId>chicory-compiler-maven-plugin</artifactId>

Choose a reason for hiding this comment

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

medium

For build reproducibility, it's a best practice to explicitly specify the version for Maven plugins. Since the wasi dependency is at version 1.6.0, it's likely this plugin should be pinned to the same version.

                <artifactId>chicory-compiler-maven-plugin</artifactId>
                <version>1.6.0</version>

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@andreaTP
Copy link
Author

the chicory-runtime dependency has been removed as it's no longer needed with the compiler approach.

This is not correct, runtime is a transitive dependency of wasi, so, declaring it is redundant ...

Copy link
Member

@thomaspoignant thomaspoignant left a comment

Choose a reason for hiding this comment

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

@andreaTP thanks a lot for this PR, this is such an honour to have you here.
Chicory is a really awesome lib and I was not able to find this optimisation myself, thanks a lot for this 🙇.

This is great to have the same thing but fast 🙌 .

@andreaTP
Copy link
Author

andreaTP commented Nov 14, 2025

Glad to see you’re making good use of Chicory, this is a great project, and I’m always happy to help 🙂
Feel free to ping me anytime if you have questions about the integration!

I also noticed that the Wasm module is built with the wasm-unknown-unknown target.
Have you tried using that version? If you’re not relying on WASI-specific features, there might be some easy performance improvements available with that build.

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