-
Notifications
You must be signed in to change notification settings - Fork 57
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
reduce relaxedBodyCanonicalizer allocations #46
Comments
Patches welcome! |
Yes I noticed that too 😅 I'll work on it tomorrow. |
Here is the PR #47 |
emersion
pushed a commit
that referenced
this issue
Mar 30, 2021
- reslice crlfBuf to an empty slice, instead of reset it to nil - change wspBuf to a boolean, the content was not used Fixes #46
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my application, nearly 50% of my memory allocations (in count) are caused by
relaxedBodyCanonicalizer
.go-msgauth/dkim/canonical.go
Lines 130 to 158 in 6dd5b6c
Especially lines 146 and 149.
I think this code could be optimized.
Currently each call to
append
causes a new memory allocation and requires to copy the memory.Because the slices are reset to nil.
It doesn't reuse the memory previously allocated.
The solution: do
c.wspBuf = c.wspBuf[:0]
instead ofc.wspBuf = nil
.Same for
crlfBuf
.WDYT ?
The text was updated successfully, but these errors were encountered: