Skip to content

[RFC] Give SegmentWriter a cachable Searcher#15

Open
asedeno wants to merge 2 commits intomchaput:mainfrom
asedeno:segment-reader-cached-searcher
Open

[RFC] Give SegmentWriter a cachable Searcher#15
asedeno wants to merge 2 commits intomchaput:mainfrom
asedeno:segment-reader-cached-searcher

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.

asedeno added 2 commits June 15, 2021 20:17
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