Skip to content

Fix #503: Improve caching#504

Closed
kluhan wants to merge 27 commits into
codefori:mainfrom
Inventegrate:feature/advanced-cache
Closed

Fix #503: Improve caching#504
kluhan wants to merge 27 commits into
codefori:mainfrom
Inventegrate:feature/advanced-cache

Conversation

@kluhan

@kluhan kluhan commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix duplicate include loading in RPGLE include graphs and harden cache behavior across parser/server flows.

This addresses the issue where the same include (for example d.rpgle) could be loaded multiple times when referenced through multiple branches (for example via b.rpgle and c.rpgle from a.rpgle).

Problem

See the bug report for details: Issue #503.

What Changed

  1. Include resolution dedup + short-lived include cache
  • Replaced boolean in-progress tracking with in-flight Promise dedup keyed by baseUri::includeString.
  • Added resolved-include cache with TTL and max-size eviction.
  • Added eviction of stale include cache entries when files change.
  1. Parser cache correctness and invalidation improvements
  • Added reverse dependency index (include -> dependents) to invalidate only affected files.
  • Switched parsed cache clearing from assigning undefined to deleting entries.
  • Added parsed/table/include cache hit/miss instrumentation (CacheMetrics).
  1. Remote file-content caching and tuning
  • Added TTL + max-entries cache for remote getFile content requests.
  • Added server-side cache settings hook from client initialization options.
  • Added user settings:
    • vscode-rpgle.cache.fileTTLSeconds
    • vscode-rpgle.cache.fileMaxEntries
  1. Concurrent table/lint config fetch dedup
  • Table cache fetch now shares in-flight Promise instead of returning transient empty values.
  • Lint config loading now deduplicates concurrent fetches and caches parsed JSON separately.
  1. Developer/diagnostic commands
  • Added RPGLE: Clear All Caches command.
  • Added RPGLE: View Cache Statistics command.

Why This Fixes the Reported Issue

For include graphs like:

a.rpgle
|- b.rpgle
|  \- d.rpgle
\- c.rpgle
   \- d.rpgle

the resolver now:

  • shares one in-flight include fetch for the same include key,
  • reuses recently resolved include results from cache,
  • avoids repeated full-cache scans during invalidation.

This prevents unnecessary repeated loads of shared include sources and reduces parse overhead for large graphs.

Checklist

  • have tested my change
  • updated relevant documentation
  • Remove any/all console.logs I added
  • eslint is not complaining
  • have added myself to the contributors' list in the README
  • for feature PRs: PR only includes one feature enhancement.

@kluhan kluhan changed the title Feature/advanced cache Fix #503: Improve caching May 4, 2026
@worksofliam

Copy link
Copy Markdown
Member

@kluhan can you fix the conflicts here and i will look into a review?

@kluhan kluhan marked this pull request as draft May 7, 2026 08:41
@kluhan

kluhan commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

The conflicts were a bit messy, and I might have missed some side effects introduced by the merged PRs. I’m marking this PR as Draft until I’ve confirmed everything works as intended.

@kluhan

kluhan commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Kudos to @bobcozzi — the improved logging is a game changer for debugging the extension. The PR is now up to date and ready for review.

@kluhan kluhan marked this pull request as ready for review May 7, 2026 10:37
@bobcozzi

bobcozzi commented May 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the mention, @kluhan But I think the logging improvements you're referring to are actually from @richardm90 — his fixes added log levels, enhanced logging for include/member resolution, and the debounce logging. Definitely a benefit. Unless I didn't understand your specifics? Thanks!

@kluhan

kluhan commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

My bad, I must’ve mixed up the names while snoozing through the git diffs — sorry about that 😄

Credits definitely go to @richardm90 👍

@worksofliam

Copy link
Copy Markdown
Member

@kluhan this is my mistake, but can you update the conflicts again? I merged a PR that added the start of OPM support. I don't think the conflicts are big.

Alternatively, because this is my fault, I am happy to cleanup the conflicts for you - just give me access to your branch/forked repo and I can do it. Let me know!

…solution

Fix codefori#501: Fix file path resolution on Windows
@kluhan

kluhan commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

@worksofliam No worries at all — I’m happy to update the conflicts on Monday when I’m back in office, that’s completely fine. The OPM support changes shouldn’t be a big problem.

@kluhan kluhan mentioned this pull request May 19, 2026
6 tasks
@kluhan

kluhan commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

I messed up my branch a bit by merging the live main branch into it, which made it difficult to review. I’ll close this PR in favor of a cleaner one: #519

@kluhan kluhan closed this May 19, 2026
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.

5 participants