---
# System prepended metadata

title: Build times considerations

---

# Build times considerations

## Docker Image Vs. Local Performance

Currently, with the latest PR to enable builds without Docker, the performance testing, using the [Enum Test Wrapper](https://github.com/polywrap/toolchain/tree/origin/packages/test-cases/cases/wrappers/wasm-rs/enum-types), I found:

| Minimal Wrapper (No deps) | Docker (s) | Local (s) | Docker VM |
| -------- | -------- | -------- | -------- |
| First time build (p/wrapper)     | 158.2     | 9.6     | 14.1 |
| Second build - No changes     | 0.5     | 9.4     | 4.8 |
| Second build - Source code changes     | 12    | 9.5     | 5.4 |
| Second build - Cargo Toml changes     | 26.8     | 9.5     | 5.4 |

Let's analyze the above for a minute. Why does the initial build take so long?  I built the image using `buildx` so that I could see how much time went into each image layer and found the following:

![](https://i.imgur.com/ifFoqKT.png)

Building sources and optimization passes take around 20% of the total build time. Each time we build a new wrapper or wipe our docker cache and re-build, we need to install these global dependencies all over again, which account for over 70% of the build time. But if you build locally, these are just installed once, and globally; hence the low build time.

But if we measure subsequent builds, it doesn't look so bad. But this is just a toy example, it uses no real production-grade external libs. So I added ethers into the project, which is a big dependency with a big amount of peer dependencies. And re-measured, to find the following:

| Wrapper with big deps (ethers) | Docker (s) | Local (s) | Docker VM (s) |
| -------- | -------- | -------- | -------- |
| First time build (p/wrapper) | 231.5 | 41.1  | 39.1  |
| Second build - No changes     | 2.2     | 9.3     | 8.8 |
| Second build - Source code changes | 49 | 9.2  | 8.7 |
| Second build - Cargo Toml changes     | 82.5     | 17.1     | 12.1 |

So, what makes the docker build after a simple source change, take so much time?

![](https://i.imgur.com/RAoXkyY.png)

We can see that almost 40% are just internal, irreducible Docker processes.