-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
rfc7692 context-takeover implemention #342
base: main
Are you sure you want to change the base?
Conversation
…essContextTakeover
Feature/impl compress context takeover
mod: split dict to rx and tx
add: context-takeover option to client
mod: remove mutex.
mod: add dict process
Feature/add test
Feature/upgrade writer
fbd55c3
to
e82d2a9
Compare
I prepared a branch that organized commit so I will replace it if necessary. $ git merge --squash feature/context-takeover |
Could you make a benchmark with and without CompressionContextTakeOver and compare the memory allocation/memory usage. I ran some tests internally and I noticed that memory usage was multiplied by 10. So I am not sure, maybe there's something wrong with my bench or a memory leak in the code... |
doc.go
Outdated
@@ -171,10 +171,17 @@ | |||
// | |||
// conn.EnableWriteCompression(false) | |||
// | |||
// Currently this package does not support compression with "context takeover". | |||
// Currently this package support compression with "context takeover". |
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.
Pluralize support
.
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.
thanks!
@theckman I'm sorry, I missed replying and I was late. thank you for your comment. First of all, @JordanP pointed out an increase in memory usage, but since it has not happened with my product, I do not know if I write test code. I think that it will take 1-2 weeks for that response. After that, I will also modify the comments. Thank you for review. |
On my side, my workload is different: tens of thousand clients, each sending one Websocket message every 5sec (i.e not frequently). |
So, in this implementation, I think that it has a maximum dictionary of 32 kb to share between client and server. Therefore, using context - takeover will increase memory usage. |
Hi everyone! Is there a chance to see this PR in master? Master:
PR:
Since this feature is optional why not have it in master? |
@hexdigest great that you have interest in this too. Could you share some numbers about your workload ? With compression enabled, how much more memory does your app need ? What about the CPU cost, did you measure some impact with/without this ? |
@JordanP I don't think these are legit questions. These two modes: with context takeover and with no context takeover serve different purposes. In my case, there are a few thousand long living clients that send ~1 message per second where every message is more or less the same small payload (around 200 bytes) with very few differences. For my case, having context takeover is crucial because we're paying for the traffic. I understand that the current compression implementation in the master branch uses the pool to minimize the overhead of memory allocations. This approach is especially good for the applications with hundreds of thousands of short living connections where each client rarely sends big chunks of random data. Unfortunately this is not my and @smith-30 use. Per message CPU costs are shown here:
With same compression level context takeover has less impact on CPU per message because there are less allocations. |
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.
@AlexVulaj I think this is worthy of inclusion in the next feature release sans any other PRs that tackle this better. I have one query of the PR but otherwise LGTM.
req.Header["Sec-WebSocket-Extensions"] = []string{"permessage-deflate; server_no_context_takeover; client_no_context_takeover"} | ||
switch { | ||
case d.EnableCompression && d.AllowClientContextTakeover: | ||
req.Header.Set("Sec-Websocket-Extensions", "permessage-deflate; server_max_window_bits=15; client_max_window_bits=15") |
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.
What's the significance of the bit size that's been chosen here?
related #339