Skip to content

refactor: caching logic#90

Merged
klkvr merged 23 commits intofoundry-rs:mainfrom
klkvr:klkvr/refactor-cache
Mar 13, 2024
Merged

refactor: caching logic#90
klkvr merged 23 commits intofoundry-rs:mainfrom
klkvr:klkvr/refactor-cache

Conversation

@klkvr
Copy link
Member

@klkvr klkvr commented Mar 12, 2024

Currently we are not keeping cache entries for files which were out of scope of compiler (might be dirty or not)

Because of that, when running forge compile, then running forge compile --skip ... which will filter some artifacts out, and then running forge compile again, some artifacts will be recompiled, because --skip run removed those entries from cache.

Solution is to keep those entries in cache (we already silently keep artifacts anyway).

@klkvr klkvr requested review from DaniPopes and Evalir as code owners March 12, 2024 01:14
@klkvr klkvr requested a review from mattsse March 12, 2024 01:14
// 3 contracts
assert_eq!(cache.dirty_source_files.len(), 3);
assert!(cache.filtered.is_empty());
assert!(cache.cache.is_empty());
Copy link
Member Author

Choose a reason for hiding this comment

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

we are now adding entries for dirty files to cache during preprocessing

Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

makes sense to me, ptal @mattsse

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

great!
this makes a lot of sense

@klkvr
Copy link
Member Author

klkvr commented Mar 12, 2024

Patched foundry-rs/foundry#7334 with this PR branch, will merge after it succeeds

@klkvr klkvr force-pushed the klkvr/refactor-cache branch from ae4e864 to 9af80fe Compare March 13, 2024 01:46
@klkvr
Copy link
Member Author

klkvr commented Mar 13, 2024

@mattsse @onbjerg mind taking one more look? updated impl after failed foundry ci

it should become a little bit more safer now, there were some edge cases with multiple versions when we could have dirty artifacts staying in cache

@klkvr klkvr force-pushed the klkvr/refactor-cache branch from 30bb08e to 122c9e5 Compare March 13, 2024 01:52
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

this looks great!
clean

Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

lgtm as well :shipit:

@klkvr klkvr merged commit 70c6f8b into foundry-rs:main Mar 13, 2024
mattsse pushed a commit that referenced this pull request Apr 17, 2024
missed this in #90

ref https://t.me/foundry_support/52331

after #90 we stopped removing out of scope sources from cache, however,
we never validated if they are dirty, this results in invalid cached
artifacts in certain cases.

with this PR we iterate over all cache entries out of scope of current
compiler run, then build graph with them to find if they import any of
files marked as dirty.
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.

3 participants