You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/03/18 15:16:05 UTC

[GitHub] [lucene] donnerpeter opened a new pull request #24: LUCENE-9852: Make Hunspell thread-safe

donnerpeter opened a new pull request #24:
URL: https://github.com/apache/lucene/pull/24


   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Lucene:
   
   * https://issues.apache.org/jira/projects/LUCENE
   
   You will need to create an account in Jira in order to create an issue.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * LUCENE-####: <short description of problem or changes>
   
   LUCENE must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   
   # Description
   
   Make the API thread-safe to simplify clients and prevent mistakes
   
   # Solution
   
   Remove mutable fields from Stemmer
   
   # Tests
   
   `TestPerformance` enriched with multi-threaded stemming measurement, to ensure that GC threads (with presumably higher load) won't affect the speed significantly. And they appear not to. There some degradations in stemming, but they seem humble to me. There also are some in spellchecking, but given the thread-safety benefits, I think we can live with those, especially considering it's a brand new API.
   
   The times on my corpora:
   
   Activity | Average time after change | Average time before change
   --- | --- | ---
   Stemming de | 666.1428571428571 | 636.2857142857143
   Multi-threaded stemming de | 569.0 | 556.8571428571429
   Spellchecking de | 756.2857142857143 | 714.5714285714286
   Suggestions for de | 320.85714285714283 | 319.2857142857143
   Stemming en | 600.7142857142857 | 635.5714285714286
   Multi-threaded stemming en | 531.5714285714286 | 554.8571428571429
   Spellchecking en | 449.14285714285717 | 461.0
   Suggestions for en | 835.8571428571429 | 821.5714285714286
   Stemming fr | 718.0 | 709.2857142857143
   Multi-threaded stemming fr | 675.1428571428571 | 665.8571428571429
   Spellchecking fr | 260.85714285714283 | 263.0
   Suggestions for fr | 931.2857142857143 | 897.8571428571429
   Stemming ru | 1044.0 | 1027.5714285714287
   Multi-threaded stemming ru | 919.1428571428571 | 893.1428571428571
   Spellchecking ru | 583.4285714285714 | 573.0
   Suggestions for ru | 800.7142857142857 | 784.4285714285714
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/lucene/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request title.
   - [x] I have given Lucene maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [ ] I have added tests for my changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] rmuir commented on pull request #24: LUCENE-9852: Make Hunspell thread-safe

Posted by GitBox <gi...@apache.org>.
rmuir commented on pull request #24:
URL: https://github.com/apache/lucene/pull/24#issuecomment-802174939


   I guess my question is why does the stemmer need to be threadsafe?
   
   Stemmers in lucene aren't threadsafe, we use a threadlocal model for the analysis chain. So tokenizers, stemmers, etc are cached per-thread, and maintain some buffers to avoid creating tons of garbage.
   
   e.g. the way the Analyzer class works, if you are indexing with 8 threads, is that you have 8 HunspellStemFilters, each one with its own HunspellStemmer, so there are no thread safety issues. Previously the idea is that only the "large" thing (Dictionary) needed to be threadsafe as we don't want to instantiate it all the time anyway.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] rmuir merged pull request #24: LUCENE-9852: Make Hunspell thread-safe

Posted by GitBox <gi...@apache.org>.
rmuir merged pull request #24:
URL: https://github.com/apache/lucene/pull/24


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] donnerpeter commented on pull request #24: LUCENE-9852: Make Hunspell thread-safe

Posted by GitBox <gi...@apache.org>.
donnerpeter commented on pull request #24:
URL: https://github.com/apache/lucene/pull/24#issuecomment-802203468


   The stemmer itself doesn't very much need to be thread-safe, but I'd prefer `Hunspell` API to be so, and the latter uses the former internally.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene] rmuir commented on pull request #24: LUCENE-9852: Make Hunspell thread-safe

Posted by GitBox <gi...@apache.org>.
rmuir commented on pull request #24:
URL: https://github.com/apache/lucene/pull/24#issuecomment-802208951


   OK, given that it doesn't hurt the performance that much and introduces no synchronization, seems like a good tradeoff.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org