Skip to content

linfa-preprocessing::countgrams: RefCell is replaced with OnceLock #387

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kakserpom
Copy link

Simple fix to allow for concurrent access.

@kakserpom kakserpom changed the title linfa-preprocessing::countgrams: Multi-threading made possible linfa-preprocessing::countgrams: RefCell is replaced with OnceLock May 15, 2025
@relf
Copy link
Member

relf commented May 19, 2025

OnceLock is not serde. What about cloning to use multi-threading?

@kakserpom
Copy link
Author

@relf I don't quite understand what you mean by that. OnceLock is a better fit here than RefCell because it's thread-safe.

@relf
Copy link
Member

relf commented May 21, 2025

With OnceLock we cannot serialize/deserialize CountVectorizerValidParams which is a no go (cf. CI tests errors).

I meant you can just clone CountVectorizerParams and use an independent copy in each thread (if it was your initial problem with the multi-threading).

@kakserpom
Copy link
Author

@relf Well, I guess we could solve the issue by implementing serialize and deserialize manually, right?

@relf
Copy link
Member

relf commented May 26, 2025

Maybe... But there is no problem in the first place if you just clone CountVectorizerParams so no need of a special serde code complication.

@kakserpom
Copy link
Author

@relf please review the updated version.

@kakserpom kakserpom force-pushed the linfa-preprocessing-multi-threading branch from 24449de to 776e311 Compare June 10, 2025 20:50
Copy link

codecov bot commented Jun 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.17%. Comparing base (5272ad1) to head (0a23fc7).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #387      +/-   ##
==========================================
+ Coverage   35.90%   36.17%   +0.26%     
==========================================
  Files          97      101       +4     
  Lines        6409     6563     +154     
==========================================
+ Hits         2301     2374      +73     
- Misses       4108     4189      +81     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

2 participants