-
Notifications
You must be signed in to change notification settings - Fork 63
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
Use CacheDictType for caching GF(p) #1660
Conversation
Builds upon Nemocas#1659 to provide thread-safety by default.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1660 +/- ##
==========================================
- Coverage 86.75% 86.75% -0.01%
==========================================
Files 115 115
Lines 29668 29664 -4
==========================================
- Hits 25739 25735 -4
Misses 3929 3929 ☔ View full report in Codecov by Sentry. |
BTW, regarding localization, there is some strange error, not sure if this warrants an issue or not: julia> total_ring_of_fractions(ZZ)
ERROR: TypeError: in TotFracRing, in T, expected T<:RingElem, got Type{BigInt}
Stacktrace:
[1] total_ring_of_fractions(R::AbstractAlgebra.Integers{BigInt}; cached::Bool)
@ AbstractAlgebra.Generic C:\data\projects\aaa\AbstractAlgebra.jl\src\generic\TotalFraction.jl:617
[2] total_ring_of_fractions(R::AbstractAlgebra.Integers{BigInt}; cached::Bool)
@ AbstractAlgebra C:\data\projects\aaa\AbstractAlgebra.jl\src\TotalFraction.jl:25
[3] total_ring_of_fractions(R::AbstractAlgebra.Integers{BigInt})
@ AbstractAlgebra C:\data\projects\aaa\AbstractAlgebra.jl\src\TotalFraction.jl:24
[4] top-level scope
@ REPL[47]:1 |
Lets ignore it for now. |
Btw, did you test that this makes it thread-safe with |
Yes, it worked fine with |
Strange, it should be broken too. I would suggest to always do |
Do you mean that using |
It might work, but there is no guarantee for it being threadsafe. It might be even worse, because it does not throw an error like a normal dict. It just gets corrupted silently. |
Sounds scary. I think I saw that CacheDictType writes/reads using a lock. |
Scary? We are talking about multithreading, so everything is scary and hard to get right.
Anyway, it seems that we are indeed using the version with the lock. The purpose of the lock was to make it play nice with the GC. I don't know if this also makes it threadsafe. |
Builds upon #1659 to provide thread-safety by default.
My tentative search shows 1 place with the same issue potentially:
AbstractAlgebra.jl/src/generic/Misc/Localization.jl
Line 39 in 17e182a