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

[#412] cache enablement for URI #415

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

Conversation

ghentschke
Copy link
Contributor

part of #412

Copy link
Member

@ruspl-afed ruspl-afed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
So, only restart will clear the cache and this is desired, correct?

@ghentschke
Copy link
Contributor Author

LGTM So, only restart will clear the cache and this is desired, correct?

Yes. But I would like to add a clear mechanism which would be triggered when the preferLspEditor has been modifed. I'll wait until your PR #410 has been merged.

@ruspl-afed
Copy link
Member

I'll wait until your PR #410 has been merged.

Please fill free to merge both when needed.

Copy link
Member

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that the PropertyTester's test method is called a lot so speeding that up has great value. Here are some comments.

  • The title of this PR and commit need cash -> cache
  • PropertyTester must be stateless, see javadoc - the new cache is kindof stateful, or rather you may end up with multiple caches the way it is done now.
  • The cache is accessed from multiple threads, so some consideration to concurrency is needed.
  • Should this be doing LRU style so that items don't stay and this grows forever. CDT has one org.eclipse.cdt.internal.core.LRUCache<K, V>
  • I think the discussions in [#1207] cache IResource in EnablementTester eclipse-lsp4e/lsp4e#1208 are relevant to this PR too so I am cross referencing them here
  • Cache invalidation may be needed, see longer comment below

Cache invalidation

My concern with this change is rather a corner case, but that there should be logic to clear the cache as some of the tests can return different results. For example you are checking content types and caching that result. In that case you need to add a listener org.eclipse.core.runtime.content.IContentTypeManager.addContentTypeChangeListener(IContentTypeChangeListener) so that you find out about content type changes.

A simple manual test:

  1. Create a file called "file.jonah"
  2. Double-click to open, will not be opened in CDT LSP because it isn't a C/C++ file
  3. Add jonah as a C file extension in preferences:
    image
  4. Make sure the file now opens as an LSP editor

Doing a addContentTypeChangeListener will be sufficient to invalidate cache for content type changes, similar mechanism may be needed for other cases.

I mentioned LRU above, but time based caching may also be useful.

@ghentschke ghentschke changed the title [#412] cash enablement for URI [#412] cache enablement for URI Feb 5, 2025
@ghentschke
Copy link
Contributor Author

Thank you @jonahgraham for the good input I'll consider it!

@ghentschke
Copy link
Contributor Author

ghentschke commented Feb 6, 2025

Ok, this is more a reminder to me:
The cache shall be cleared if:

  • the Prefer LSP Editor setting has been changed (workspace or project level) or
  • on changes in the c/c++ content types for which we enable LSP4E

A resource shall be removed form the cache if it's getting closed in the editor.

The cache shall be implemented as FIFO buffer with n entries which considers concurrency and stateless aspects

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.

3 participants