-
Notifications
You must be signed in to change notification settings - Fork 81
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
More alloc cache improvements #583
Conversation
It's not safe to concurrently access a dict while it may be mutated.
Thanks! I'll take a look at it this evening |
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.
Some suggestions could not be made:
- src/host/abstractarray.jl
- lines 65-66
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.
Some suggestions could not be made:
- src/host/abstractarray.jl
- lines 65-66
fbdc064
to
07571f8
Compare
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.
Some suggestions could not be made:
- src/host/abstractarray.jl
- lines 65-66
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.
Looks good. Left minor comment
"Invalidating inside `@cached` is not allowed." | ||
) | ||
for pool in values(cache.busy) | ||
isempty(pool) || error("Cannot invalidate a cache that's in active use") |
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.
Maybe check that the pool is empty and that the cache is in use (reading ScopedValue). Otherwise, if an exception happens during @cached
it will raise this in the cache finalizer.
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.
That sounds questionable. Shouldn't @cached
instead have a try
/catch
(well, the scope-less variety) that wipes the cache in the finally
block, making sure the cache is always in a known-good state outside of the @cached
block?
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.
Some suggestions could not be made:
- src/host/abstractarray.jl
- lines 65-66
The manual refcount fiddling is a bit dangerous (it should be compatible with manual
unsafe_free!
s and the GC), but I think is correct. @pxl-th Maybe test with one of your apps using this? Ideally, first adapt your back-end to key on bufsize instead of dims and remove T.