Skip to content
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

[RFC] Give SegmentWriter a cachable Searcher #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

asedeno
Copy link

@asedeno asedeno commented Jun 16, 2021

When repeatedly calling update_document(), each call instantiates a Searcher, which is expensive. The SegmentWriter already has a write lock on the index, so if the conditions are right, let's cache a Searcher, override its close() method to keep it open, and close it on _finish() if it's around.

I think this is safe, but I don't know enough about whoosh to be certain. All tests are still passing, and I didn't break any django-haystack tests with this change either.

When repeatedly calling `update_document()`, each call instantiates a
`Searcher`, which is expensive. The `SegmentWriter` already has a
write lock on the index, so if the conditions are right, let's cache a
`Searcher`, override its closing method to keep it open, and close it
on `_finish()` if it's around.
Also don't cache a `Searcher` if the `SegmentWriter` is closed.
cclauss pushed a commit to cclauss/whoosh-1 that referenced this pull request Jan 4, 2024
Merge the main branch from whoosh-community/whoosh into our main branch.
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.

1 participant