-
Notifications
You must be signed in to change notification settings - Fork 16
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
Performance Enhancements #69
Performance Enhancements #69
Conversation
The live server also hot patched these methods to no longer spawn goroutines. This change should also probably be back ported Also we can see that
We can definitely do better, and this would be a good PR to address it Using an implementation like this results in significantly fewer allocations: func DeriveKerberosKey(pid int, password []byte) []byte {
iterationCount := 65000 + pid%1024
key := make([]byte, md5.Size)
copy(key, password)
for i := 0; i < iterationCount; i++ {
hash := md5.Sum(key)
copy(key, hash[:])
}
return key
} though this has not been tested on a live server, I only ran benchmarks:
This doesn't address the md5 CPU usage issue, but it drastically drops the memory usage |
63173c6
to
ad488be
Compare
LGTM 👍 |
Co-authored-by: Daniel López Guimaraes <112760654+DaniElectra@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Changes:
Since using the 2.0.3 release in production for the friends service, we noticed a bug which caused a leak in goroutines. The fix for this has already been applied in production but this backports that fix.
When observing the behaviour of the friends server, we noticed it was allocating a lot of memory. Currently we allocate a 64kb buffer every time a packet is sent to the server, that packet is only supposed to be held temporarily but it seems they're not being properly collected. This change means that the fixed pool of goroutines which respond to incoming packets will each have their own 64kb buffer that will be reused for each incoming packet instead, which should greatly reduce memory allocations.