Skip to content
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

Inline function execution with bytecode evaluation #784

Merged
merged 3 commits into from
Oct 18, 2024

Conversation

jeffcharles
Copy link
Collaborator

Description of the change

Updates run_bytecode in javy-core to take an optional function name to execute and execute it if it's provided.

Why am I making this change?

This substantially reduces the amount of fuel to call an exported function with dynamically linked modules. This also allows re-using a runtime after using it when calling compile_src (see #781).

In terms of performance numbers, given a function that looks like:

function run() {
    console.log("hello");
}
run()

Fuel usage will increase from 36,929 to 36,983 (54 instructions).

Given a function that looks like:

export function run() {
    console.log("hello");
}

Fuel usage will decrease from 92,080 to 40,283 (51,797 instructions).

I'm opting to not to update the main.rs file for the time being because I'm planning to have it deleted soon.

Checklist

  • I've updated the relevant CHANGELOG files if necessary. Changes to javy-cli and javy-core do not require updating CHANGELOG files.
  • I've updated the relevant crate versions if necessary. Versioning policy for library crates
  • I've updated documentation including crate documentation if necessary.

Copy link
Member

@saulecabrera saulecabrera left a comment

Choose a reason for hiding this comment

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

Very nice! Left a comment/suggestion. I don't think it's blocking, however, I think it's worth considering.

crates/core/src/execution.rs Outdated Show resolved Hide resolved
@jeffcharles jeffcharles merged commit f2faf17 into main Oct 18, 2024
7 checks passed
@jeffcharles jeffcharles deleted the jc.more-efficient-exported-function-execution branch October 18, 2024 16:02
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