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

feat: reduce DNS response cache memory consumption #1196

Merged
merged 2 commits into from
Oct 10, 2023
Merged

Conversation

0xERR0R
Copy link
Owner

@0xERR0R 0xERR0R commented Oct 10, 2023

currently, we store dns.Msg struct in the DNS response cache. In my tests, a typical response for example "A google.com" needs approx. 270 bytes. If we cache the binary representation (wire format), we'll need only 70 bytes.

This PR changes the result cache struct from dns.Msg to []byte. This avoids also copying of dns struct on one place.

@0xERR0R 0xERR0R added the 🔨 enhancement New feature or request label Oct 10, 2023
@0xERR0R 0xERR0R added this to the v0.23 milestone Oct 10, 2023
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Files Coverage Δ
resolver/caching_resolver.go 90.43% <76.74%> (-4.26%) ⬇️

... and 1 file with indirect coverage changes

📢 Thoughts on this report? Let us know!.

Copy link
Collaborator

@ThinkChaos ThinkChaos left a comment

Choose a reason for hiding this comment

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

Seems like a pretty big win!

resolver/caching_resolver.go Outdated Show resolved Hide resolved
Co-authored-by: ThinkChaos <ThinkChaos@users.noreply.github.com>
@0xERR0R 0xERR0R enabled auto-merge (squash) October 10, 2023 19:45
@0xERR0R 0xERR0R merged commit 73bc60c into main Oct 10, 2023
2 of 3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the reduce-cache-memory branch October 10, 2023 21:56
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants