-
Notifications
You must be signed in to change notification settings - Fork 31
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
Maven Central search results should be cached #263
Comments
@fbricon Do you think having such a cache to be stored only "in memory" and maintained without any persistence would be enough? What is expected to be cached: Collections of Strings for GroupIDs,, Artifact objects and ArtifactVersion objects provided by https://github.com/eclipse/lemminx-maven/blob/master/lemminx-maven/src/main/java/org/eclipse/lemminx/extensions/maven/searcher/RemoteCentralRepositorySearcher.java#L39. |
I think if we have an embed database like H2 or other, should b ereally nice, it will avoid have the same problem when Eclipse IDE will restart. |
I'm not sure a cache would help much in general. Is there a particular request you see being repeated very often in practice? |
@angelozerr IMHO, I don't see any persistence to be required here and personally I plan to drop the cached values after 30 minutes to 1 hour timeout. Not sure about the timeout value, but when we're about to edit a POM adding some new dependency - this is the only when @mickaelistria IMHO the cache will be really helpful "right here and right now" while you may repeatedly invoke Completions during adding/editing exactly this current dependency - it takes like 10-15 minutes as maximum, no? I don't expect anything other than adding a few in-memory HashMaps here and purging them out after 30-minutes - 1 hour of inactivity. And especially it will be useful in slow internet or interruptions that often occur with Maven Search API server(-s). |
I don't fully get what would be cached and when it is cached, when the cache is used... Can you please give more concrete example? |
@mickaelistria So, when you are adding a dependency/plugin - completions are searched by Maven Search API - for some requests it usually it takes 0.5 - 2 seconds to get the results from Maven Search API or even longer, including the requests might "hang" and never complete despite a timeout set for these operations. Having the successfully received values cached will help to speed-up on repeated content assist invocations while continue editing the same dependency/plugin (changing groupsID/artifactID/Version of the same dependency/plugin) and may be while adding another dependency of the cached groupID. Not used in diagnostics/definitions/code actions/hovers/etc. |
15 min cache should be enough. |
Are repeated content assist executions a real thing? Do the Maven Central search API return all results (so we know cache will contain the necessary result as user continues typing? What would be the key in such a cache? |
@mickaelistria When "user continue typing" -is probably a different case... Completion is not repeatedly invoked in most of such cases - the filtering the existing results happens. The cache has Maven Search API Request data as a key, so it doesn't matters what document and at what position we're editing. The only requested item types and existing filters are taken into account. So, in theory, we could save and re-use such a cache for a few days, bu this would make it excessively expensive to maintain. |
In order to avoid unnecessary HTTP requests, responses for Maven Central search queries should be cached in memory, for several minutes (period could be made configurable). See fbricon/m2e-core@f46db07#diff-15b5813d8fe377232c05123e45e1b1dda3d2ae85211fc3102c8f1e49e7cb2b36R55-R56 as an example.
Limiting http requests will help both users, by providing fast results, and not pound Sonatype's infra with a shitton of queries from all over the place.
The text was updated successfully, but these errors were encountered: