-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix thread unsafety #63
Conversation
Thank you so much for your work and for spotting this issue. However, I really do not want to add dependencies (also, OhMyTreads also seems to depend on other dependencies so does not seem that lightweight). It would be great if you could try to fix it without adding this dependency. |
while IMO it is a worthwhile dependency for any multithreaded application, I can definitely understand the reticence. the use case here is pretty vanilla so it shouldn't be too bad to just stick to |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #63 +/- ##
==========================================
- Coverage 97.54% 97.34% -0.20%
==========================================
Files 8 8
Lines 571 566 -5
==========================================
- Hits 557 551 -6
- Misses 14 15 +1 ☔ View full report in Codecov by Sentry. |
reimplemented using the note that I've assumed here that the |
One issue in your current rewrite is that the min_score does not get updated over the iteration loop. This is actually super important, as a lot of StringDistances can bail early if they realize that compare is never going to give something higher than min_score. |
gotcha, so I'll have to stick closer to the original process re: the atomic operations, what is your preference w.r.t. Julia version compatibility? the current code uses |
I'm fine with doing a v1.7 version. The optimal thing would be to keep having a common min_score across threads (what I have right now), but I think it'd be fine to have one specific to each thread if that makes things much easier. |
latest commit should allow for short circuiting with a common min_score. I would recommend trying to benchmark in the same context as |
Thank you very much! |
fixes some potential race conditions involving the use of
threadid
. seehttps://julialang.org/blog/2023/07/PSA-dont-use-threadid/
for detailsI've chosen to use the library
OhMyThreads.jl
here, which did not exist at the time the original code here was written, but it's a quite nice + lightweight dependency to do parallel stuff