Skip to content

Add cache to dedupe table (which adds limit)#177

Merged
NGTmeaty merged 1 commit intomasterfrom
fix-heap
Feb 3, 2026
Merged

Add cache to dedupe table (which adds limit)#177
NGTmeaty merged 1 commit intomasterfrom
fix-heap

Conversation

@NGTmeaty
Copy link
Copy Markdown
Collaborator

@NGTmeaty NGTmeaty commented Feb 3, 2026

This should ensure that we don't grow infinitely 😅 Default is 1M which seems sane.

This should prioritize entries that have been retreived.
@NGTmeaty NGTmeaty self-assigned this Feb 3, 2026
@NGTmeaty NGTmeaty added the bug Something isn't working label Feb 3, 2026
Copy link
Copy Markdown
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 pull request adds a bounded cache to the deduplication table to prevent unbounded memory growth. The implementation replaces the unbounded sync.Map with a bounded LRU cache from the github.com/maypok86/otter library, with a default size limit of 1 million entries.

Changes:

  • Replaced sync.Map with otter.Cache[string, revisitRecord] for bounded deduplication storage
  • Added DedupeCacheSize configuration option to DedupeOptions
  • Updated API calls from Load/Store to type-safe Get/Set methods, eliminating type assertions
  • Added proper cache cleanup in Close() method

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
client.go Added otter cache import, changed dedupeHashTable type to otter.Cache, implemented cache initialization with default 1M size, added closeDedupeCache cleanup function
dedupe.go Added DedupeCacheSize field to DedupeOptions, updated checkLocalRevisit to use type-safe Get() method, removed minor trailing whitespace
dialer.go Updated Store call to Set for storing dedupe entries

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

Copy link
Copy Markdown
Collaborator

@willmhowes willmhowes left a comment

Choose a reason for hiding this comment

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

Looks good! Have one question, primarily for my own understanding

Comment thread client.go
@NGTmeaty NGTmeaty merged commit e9d5bde into master Feb 3, 2026
12 checks passed
@NGTmeaty NGTmeaty deleted the fix-heap branch February 3, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants