Skip to content

IndexSearcher instance efficiency #4009

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

Closed
vladak opened this issue Jul 25, 2022 · 1 comment
Closed

IndexSearcher instance efficiency #4009

vladak opened this issue Jul 25, 2022 · 1 comment
Assignees
Labels
enhancement webapp web application

Comments

@vladak
Copy link
Member

vladak commented Jul 25, 2022

When working on PR #4008, I noticed that the MultiReader wrapping basically ignores the IndexSearcher objects, even for single project searches. Basically RuntimeEnvironment keeps the IndexSearcher objects in a map that is then used solely to get IndexReader objects (out of IndexSearcher objects) in order to create new IndexSearcher instance, outside of ThreadpoolSearcherFactory.

Also, project-less setup might want to leverage the SearcherManager approach too - to avoid opening the index directory (supposedly expensive operation) each time a search is performed:

if (projects.isEmpty()) {
// no project setup
FSDirectory dir = FSDirectory.open(indexDir.toPath());
reader = DirectoryReader.open(dir);
searcher = new IndexSearcher(reader);
closeOnDestroy = true;
} else {

@vladak
Copy link
Member Author

vladak commented Jul 25, 2022

Also, DirectoryHistoryReader should get the IndexReader objects from the SearcherManagers in RuntimeEnvironment and avoid IndexDatabase#getIndexReader(). Actually, it is IndexDatabase#getIndexReader() that should be replaced. This is an area (IndexDatabase#getDocument()) where IndexSearcher from the SearcherManager should be used (via RuntimeEnvironment.getInstance().getIndexSearcher(String projectName)), i.e. avoid creating new one. IndexDatabase#getDocument() is actually used pretty heavily in the webapp (to get the most recent revision of given document in order to construct URL for the redirect) so this might provide some speedup.

@vladak vladak self-assigned this Jul 26, 2022
vladak added a commit to vladak/OpenGrok that referenced this issue Jul 26, 2022
@vladak vladak closed this as completed in d594176 Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement webapp web application
Projects
None yet
Development

No branches or pull requests

1 participant