-
Notifications
You must be signed in to change notification settings - Fork 214
Add back write caching, simplify caching, use sync I/O #3995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Health |
e991d71
to
5d163a4
Compare
There is a possible issue with memory usage before this PR #3999 So I think it is not good to remove the lru cache and complicate things further :) The write part of the cache needs to not do discards, so that needs a bit of separate logic if keeping the lru cache; it should be a lot simpler now that everything is sync. I'll update the PR to do that then send for review again. Sorry for the noise! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving the comments and posting with your updated comment.
|
||
/// Pending [readAsBytes] operations. | ||
final _pendingBytesContentCache = <AssetId, Future<Uint8List>>{}; | ||
final _bytesContentCache = <AssetId, Uint8List>{}; | ||
|
||
/// Cached results of [exists]. | ||
/// | ||
/// Don't bother using an LRU cache for this since it's just booleans. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment no longer makes sense.
bool exists(AssetId id, {required bool Function() ifAbsent}) { | ||
final maybeResult = _canReadCache[id]; | ||
if (maybeResult != null) return maybeResult; | ||
return _canReadCache[id] = ifAbsent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got confused about the _canReadCache
name. Maybe _existsCache
would make more sense?
One thing though, with you changing this anyway: If not too much trouble, could you try doing the sync change as a separate PR? It would be interesting to know how much that changes on its own. |
Thanks--done--yes, it's better to split out. I noticed I should remove all the async methods from |
Closing in favour of #4001 |
For #3811.
This is more about adding back functionality removed during the refactoring than performance. The reason write caching was added was to prevent files appearing during the build from causing reanalysis.
But it does seem to be about 10% faster.
FilesystemCache
invalidate
on writing outputs is no longer neededFuture.wait
in favour of for loopsPossibly some cache size limit is still a good idea, although for most projects the total source size seen should be small, and there is always the "low resource mode" flag to turn it off.