Skip to content
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

Making Memoization.jl threadsafe. #7

Open
krishvishal opened this issue Sep 30, 2020 · 2 comments
Open

Making Memoization.jl threadsafe. #7

krishvishal opened this issue Sep 30, 2020 · 2 comments

Comments

@krishvishal
Copy link

Can the following library be used to make Memoization.jl threadsafe?

ThreadSafe Dict: https://github.com/wherrera10/ThreadSafeDicts.jl

@marius311
Copy link
Owner

marius311 commented Sep 30, 2020

Nice! Didn't know about it. I think that should work for memoized top-level functions. At least, it will if the answer to this is yes (which I think it is, just wanting to verify).

I don't think it will currently work for memoized callables/closures though, since looking up the right cache itself is still happening with the non-threadsafe Memoization.cache :: IdDict. To make those threadsafe, I need to add some locking to this package (I don't think we could use ThreadsafeDict there, since the underlying thing needs to be an IdDict, which that doesn't seem to support yet). If this is important to you now, I'm happy to take a PR if you can show the performance hit is not too bad. Otherwise I will play around with this myself at some point in the future.

@marius311
Copy link
Owner

Well, the answer wasn't exactly yes but it should still work,

using ThreadSafeDicts, Memoization
@memoize ThreadSafeDict foo(x) = ...

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

No branches or pull requests

2 participants