Skip to content

bun i with cache is much slower than with no cache #19936

@ermengchao

Description

@ermengchao

What version of Bun is running?

1.2.14+6a363a38d

What platform is your computer?

Darwin 24.5.0 arm64 arm

What steps can reproduce the bug?

mkdir test && cd test
bun add -D --no-cache husky
bun rm husky
bun add -D husky
bun rm husky
bun add -D husky

What is the expected behavior?

bun i ... will be faster than bun i ... --no-cache

What do you see instead?

Here's the speed with no cache:

chao@MacBook-Air test % bun i @commitlint/cli @commitlint/config-conventional -D --no-cache
bun add v1.2.14 (6a363a38)

installed @commitlint/[email protected] with binaries:
 - commitlint
installed @commitlint/[email protected]

101 packages installed [7.82s]

remove:

chao@MacBook-Air test % bun rm @commitlint/cli @commitlint/config-conventional
bun remove v1.2.14 (6a363a38)

- @commitlint/cli
- @commitlint/config-conventional
2 packages removed [2.00ms]

package.json has no dependencies! Deleted empty lockfile

since bun i --no-cache will not create cache, I run the following command to add cache:

chao@MacBook-Air test % bun i @commitlint/cli @commitlint/config-conventional -D           
bun add v1.2.14 (6a363a38)

installed @commitlint/[email protected] with binaries:
 - commitlint
installed @commitlint/[email protected]

2 packages installed [242.50s]

remove again:

chao@MacBook-Air test % bun rm @commitlint/cli @commitlint/config-conventional
bun remove v1.2.14 (6a363a38)

- @commitlint/cli
- @commitlint/config-conventional
2 packages removed [2.00ms]

package.json has no dependencies! Deleted empty lockfile

install with cache:

chao@MacBook-Air test % bun i @commitlint/cli @commitlint/config-conventional -D
bun add v1.2.14 (6a363a38)

installed @commitlint/[email protected] with binaries:
 - commitlint
installed @commitlint/[email protected]

2 packages installed [491.09s]

You can see that bun i with cache took much time than that with no cache.
Here's the table:

run command wall-clock cache state
1 bun i … --no-cache 7.82 s cache bypassed & not written
2 bun i … 242.50 s cache populated for the first time
3 bun i … 491.09 s cache already full

Additional information

My configurations:

export BUN_INSTALL_BIN="/Users/chao/.local/bin"
export BUN_INSTALL_GLOBAL_DIR="$XDG_DATA_HOME/bun"
export BUN_INSTALL_CACHE_DIR="$XDG_CACHE_HOME/bun"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbun installSomething that relates to the npm-compatible clientperformanceAn issue with performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions