# \[Performance\] Improve build speed in bndtools by using -compression: STORE

**URL:** https://bnd.discourse.group/t/performance-improve-build-speed-in-bndtools-by-using-compression-store/502
**Category:** TIPS
**Created:** [March 2, 2025, 9:03am UTC](https://bnd.discourse.group/t/performance-improve-build-speed-in-bndtools-by-using-compression-store/502 "2025-03-02T09:03:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chrisrueger](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/chrisrueger/32/18_2.png) [@chrisrueger](https://bnd.discourse.group/u/chrisrueger)
#### Post date: [March 2, 2025, 9:03am UTC](https://bnd.discourse.group/t/performance-improve-build-speed-in-bndtools-by-using-compression-store/502/1 "2025-03-02T09:03:08Z")

</div>

As you know bnd always produces a .jar file per bundle as its build output, and .jar files are actually zip files. And zip files can be used with and **without** compression.

I just found a simple way to speed up performance of builds, by using the [-compression](https://bnd.bndtools.org/instructions/compression.html) instruction to disable compression.

This can be used to control whether the `.jar` files bnd produces are compressed or not.

- DEFLATE: (default) compression is enabled
- STORE: no compression

Using STORE for no compression saves CPU cycles needed to compress the files.

I have now put the following into our `cnf/build.bnd`:

`-compression: ${if;${driver;eclipse};STORE;DEFLATE}`

This means that in Eclipse IDE when you are developing you will use `STORE` (no compression = faster, but bigger files). In all other builds (e.g. Maven, Gradle, Tycho etc. you will use `DEFLATE` (compressed, slower, smaller files). It uses the [${if} macro](https://bnd.bndtools.org/macros/if.html) and the [${driver} macro](https://bnd.bndtools.org/macros/driver.html).

The idea behind this tuning is my assumption , that locally in Eclipse you do not care about compression and thus larger files are acceptable, but instead you want things to be fast.

## Impact

I did some poor mans measurements to give you an impression:

### Full Workspace refresh

Doing a full workspace refresh rebuilds everything in your workspace:

 ![image](https://global.discourse-cdn.com/free1/uploads/bnd/original/1X/8062ecca79c6553fa2f18142856ebc5285fe4fa3.png)

`-compression: DEFLATE`: 70 seconds (avg)  
`-compression: STORE`: 57s seconds (avg)

STORE was around 16-19% faster.

### web-templates bundle

This bundle contains little java code, but lots of files (web templates, images etc.) which are copied to the .jar file.  
I did 3 runs.

**DEFLATE:**

```auto
filesize: 9.459.121 bytes
BUILD FULL web-templates 1 file was built in 1.257 sec
BUILD FULL web-templates 1 file was built in 1.304 sec
BUILD FULL web-templates 1 file was built in 1.252 sec

```

**STORE:**

```auto
filesize: 28.791.742 bytes
BUILD FULL web-templates 1 file was built in 0.576 sec
BUILD FULL web-templates 1 file was built in 0.611 sec
BUILD FULL web-templates 1 file was built in 0.611 sec

```

STORE is \> 50% faster.

### core-services bundle

This bundle contains a lot of java files, but little other files.

**DEFLATE**

```auto
BUILD FULL core-services 1 file was built in 5.317 sec
BUILD FULL core-services 1 file was built in 5.446 sec
BUILD FULL core-services 1 file was built in 5.610 sec

```

**STORE**

```auto
BUILD FULL core-services 1 file was built in 4.687 sec
BUILD FULL core-services 1 file was built in 4.687 sec
BUILD FULL core-services 1 file was built in 4.736 sec

```

STORE is about 12% faster.

## Conclusion

I think this is a reasonable speed up in build performance during developing OSGi bundles in the IDE with bndtools / bnd, where waiting time matters a lot, while filesize often is not that important.

Of course, it depends a little bit on the size of your workspace and the contents of your bundle. But I think this is a reasonable little trick to feel better pressing `Cmd + s` and drink less coffee 🙂

---

<div class="post-metadata">

### Author: ![juergen-albert](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/juergen-albert/32/20_2.png) [@juergen-albert](https://bnd.discourse.group/u/juergen-albert)
#### Post date: [March 3, 2025, 3:51pm UTC](https://bnd.discourse.group/t/performance-improve-build-speed-in-bndtools-by-using-compression-store/502/2 "2025-03-03T15:51:32Z")

</div>

Nice, thanks heaps for that nugget! I’ll definitely give it a try.

---

<div class="post-metadata">

### Author: ![chrisrueger](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/chrisrueger/32/18_2.png) [@chrisrueger](https://bnd.discourse.group/u/chrisrueger)
#### Post date: [May 4, 2025, 8:56am UTC](https://bnd.discourse.group/t/performance-improve-build-speed-in-bndtools-by-using-compression-store/502/3 "2025-05-04T08:56:16Z")

</div>

Another little tweak is to ensure the following in `cnf/build.bnd` is set to avoid that source files are added the jar in `OSGI-OPT` folder:

`-sources: false`

Then the copying of the sources does not happen which saves time.

Docs: [-sources BOOLEAN | bnd](https://bnd.bndtools.org/instructions/sources.html)

You could use the same conditional if/else logic above to only exclude sources during development in eclipse, but include them in the CI build.
