Skip to content

skargo: use per-unit state.db to avoid cache thrashing#1120

Open
cristianoc wants to merge 1 commit intoSkipLabs:mainfrom
cristianoc:fix-state-db-cache-thrashing
Open

skargo: use per-unit state.db to avoid cache thrashing#1120
cristianoc wants to merge 1 commit intoSkipLabs:mainfrom
cristianoc:fix-state-db-cache-thrashing

Conversation

@cristianoc
Copy link
Contributor

@cristianoc cristianoc commented Feb 24, 2026

Lib and test targets sharing the same build directory and relocation model would read/write the same state.db, causing cache thrashing. Include the package name and unit hash in the state.db filename to make it unique per compilation unit.

Fix #1119

Lib and test targets sharing the same build directory and relocation
model would read/write the same state.db, causing cache thrashing.
Include the package name and unit hash in the state.db filename to
make it unique per compilation unit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mbouaziz mbouaziz requested a review from beauby February 24, 2026 16:35
@beauby
Copy link
Contributor

beauby commented Feb 25, 2026

My understanding is that the lib and test targets (for the same build profile) should be able to share the same cache, because the cache for the test target should be a superset of the cache for the lib target. Is building lib after test causing pessimistic evictions?

@cristianoc
Copy link
Contributor Author

My understanding is that the lib and test targets (for the same build profile) should be able to share the same cache, because the cache for the test target should be a superset of the cache for the lib target. Is building lib after test causing pessimistic evictions?

The observation is that cargo check is significantly slower when a single cache file is used.
Not sure if it matters, but the test target has additional source files that are not present in lib.

@beauby
Copy link
Contributor

beauby commented Feb 27, 2026

@cristianoc Do you observe this behavior for all projects or for one in particular?

@beauby
Copy link
Contributor

beauby commented Feb 27, 2026

Might be related: #971.

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.

Skargo: lib and test targets trample on each other's cache

2 participants