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 1 commit 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.

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