Skip to content

Limit path depth and add cache cleanup#523

Merged
talyguryn merged 5 commits intomasterfrom
fix/try-to-fix-oom-by-ai
Feb 10, 2026
Merged

Limit path depth and add cache cleanup#523
talyguryn merged 5 commits intomasterfrom
fix/try-to-fix-oom-by-ai

Conversation

@talyguryn
Copy link
Member

Review required!

Prevent excessive memory usage and reduce GC pressure by limiting traversal path depth in data-filter (cap depth logic at 20). In grouper worker, add a periodic cache cleanup interval (every 5 minutes) started on worker start and cleared on finish to avoid unbounded cache growth. Free large references after delta computation by nulling event payloads to allow garbage collection. Also tighten memoization for findSimilarEvent (max reduced from 200 to 50 and ttl set to 600s) to further limit memory retained by caches.

Prevent excessive memory usage and reduce GC pressure by limiting traversal path depth in data-filter (cap depth logic at 20). In grouper worker, add a periodic cache cleanup interval (every 5 minutes) started on worker start and cleared on finish to avoid unbounded cache growth. Free large references after delta computation by nulling event payloads to allow garbage collection. Also tighten memoization for findSimilarEvent (max reduced from 200 to 50 and ttl set to 600s) to further limit memory retained by caches.
Copilot AI review requested due to automatic review settings February 10, 2026 13:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to reduce memory usage/GC pressure in the Grouper worker pipeline by limiting deep traversal work in the data filter, bounding cache growth, and tightening memoization settings.

Changes:

  • Added a periodic cache cleanup interval in GrouperWorker.start() and cleared it in finish().
  • Adjusted findSimilarEvent memoization limits (max) and TTL.
  • Modified DataFilter traversal to (intended) cap path depth during recursion.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
workers/grouper/src/index.ts Adds periodic cache clearing, changes memoization settings, and attempts to free large references after delta computation.
workers/grouper/src/data-filter.ts Attempts to cap traversal path depth to reduce memory allocations for deeply nested objects.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Limit path growth in data filter to avoid creating new arrays past 20 levels (reduces excessive allocations for deeply nested objects). Import TimeMs and replace magic numbers: set MEMOIZATION_TTL to 600_000, use TimeMs.MINUTE for cache cleanup interval, and apply MEMOIZATION_TTL to the memoize decorator. Clear large delta references by setting them to undefined to aid GC. Add a test that verifies filtering works on objects nested >20 levels without causing excessive memory allocations.
Introduce MAX_TRAVERSAL_DEPTH in data-filter.ts and replace the hardcoded depth check (20) to prevent excessive memory allocations from deep object nesting. Add CACHE_CLEANUP_INTERVAL_MINUTES in index.ts and use it for the cache cleanup setInterval instead of the literal 5, improving readability and making these tuning values easier to adjust.
Remove the unnecessary eslint-disable-next-line on the memoize import and apply the no-unused-vars ignore to the MEMOIZATION_TTL constant instead. This ensures the linter suppression targets the unused constant (decorators not counted) rather than the import, improving clarity.
Add an explanatory comment and an `/* eslint-disable-next-line no-unused-vars */` directive before the `memoize` import in workers/grouper/src/index.ts. This prevents ESLint from flagging the import as unused since decorators (which rely on the import) are not recognized as usages by the linter.
@talyguryn talyguryn merged commit 81b0d27 into master Feb 10, 2026
5 checks passed
@talyguryn talyguryn deleted the fix/try-to-fix-oom-by-ai branch February 10, 2026 15:52
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.

2 participants