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

Rust build image optimizations #1054

Merged
merged 5 commits into from
Jul 21, 2022
Merged

Conversation

namesty
Copy link
Collaborator

@namesty namesty commented Jul 20, 2022

This PR aims to improve the time it takes to build a Rust wrapper with Polywrap's CLI, by optimizing Docker's build image.

This is done, mainly, by copying over the Cargo manifests, building dependencies, and then copying the actual source code and rebuilding. With this trick, the copying of the source files doesn't invalidate Docker's cache at the dependencies building layer. Thus saving time when changing the source code and rebuilding (which is the most common iteration when developing a Rust wrapper).

I've also added a test to measure build times, comparing the previous image with the new one by measuring: the time it takes to build each image for the first time, the time it takes to build them again (with the image cached) and the time they take to build after modying the source code in each. I've set this test to be skipped by default as it would heavily increase the CI and overall testing times.

Below is a chart with the average results I've got:

Case Current (seconds) New (seconds)
First build (no cache) 189.77 220.26
Second build (with cache - no source modification) 71.90 37.22
Third build (after source modification) 73.31 36.99

In general, the first build takes a bit more, subsequent builds take less.

@namesty namesty marked this pull request as ready for review July 20, 2022 15:25
@@ -330,3 +335,95 @@ describe("wasm-rs test cases", () => {
);
})
});

describe.skip("Wasm-rs benchmarking", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can merge this as skipped for now, but we should probably make a benchmarking project that does this in the near future.

Copy link
Contributor

@dOrgJelli dOrgJelli left a comment

Choose a reason for hiding this comment

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

🔥

@dOrgJelli dOrgJelli merged commit 87f8dbf into origin-dev Jul 21, 2022
@dOrgJelli dOrgJelli deleted the namesty/rust-image-optimizations branch April 10, 2023 16:55
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