-
Notifications
You must be signed in to change notification settings - Fork 357
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
Improving SSE Performance #5832
base: 2.x
Are you sure you want to change the base?
Conversation
…o increases inlining likeliness
…ng-based hash table lookup; also getting rid of unused variable then.
…onymous class; also has increased likeliness of inlining das no dynamic binding is needed
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.
This indeed is a bit faster, thanks
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.
On the other hand, there is a difference in the code, if "\n" is the last symbol written, the DATA_LEAD is not added. (I see your comment about this)
Correct, this is a bug fix. The original code wrote an excess |
Suppose the following:
With the current code, the last |
Also, |
Yes and no, it depends how you define the word "regression". 😉 Actually the old code was incorrect. It accepted
Even worse, the exact combination Having said that, I will file another PR which first corrects the wrong handling of |
Minor addition, forgot to mention earlier: As a result of this definition in the SSE Spec, users MUST NOT expect to receive the exact same line breaking bytes on the receiver side that they put into place in the sending side. The only guarantee they have is that there will be ONE line break on the receiving end if there was either |
I would not change 2.x, and update just 3.1. |
Okay so I will target the bug fix PR for the 3.1 branch only. |
SSE, in contrast to "usual" polling-style REST APIs, typically implies a comparably higher amount of messages sent to a comparably higher amount of peers, as a lot of events is sent to a lot of observers each time a resource is modified.
To reduce server load, it makes sense to make the event sending part as lean as possible.
Due to that reasoning I propose the adoption of the attached changes:
DATA_LEAD
prefix) as fast as possible, making it at most likely for inlining, even if it might make the code three lines longer and slightly harder to read.NB: The outcome of this PR is even more correct than the original code, as a trailing
\n
as the last character produced by the "inner" MBW previously lead to a "dangling" (i. e. otherwise empty)DATA_LEAD
prefix!