Skip to content

Serialize Outbound Message on Flush#57084

Merged
original-brownbear merged 4 commits intoelastic:masterfrom
original-brownbear:even-lazier-writes
May 27, 2020
Merged

Serialize Outbound Message on Flush#57084
original-brownbear merged 4 commits intoelastic:masterfrom
original-brownbear:even-lazier-writes

Conversation

@original-brownbear
Copy link
Copy Markdown
Contributor

Follow up to #56961:

We can be a little more efficient than just serializing at the IO loop by serializing
only when we flush to a channel. This has the advantage that we don't serialize a long
queue of messages for a channel that isn't writable for a longer period of time (unstable network,
actually writing large volumes of data, etc.).
Also, this further reduces the time for which we hold on to the write buffer for a message,
making allocations because of an empty page cache recycler pool less likely.

Follow up to #56961:

We can be a little more efficient than just serializing at the IO loop by serializing
only when we flush to a channel. This has the advantage that we don't serialize a long
queue of messages for a channel that isn't writable for a longer period of time (unstable network,
actually writing large volumes of data, etc.).
Also, this further reduces the time for which we hold on to the write buffer for a message,
making allocations because of an empty page cache recycler pool less likely.
@original-brownbear original-brownbear added >non-issue :Distributed/Network Http and internode communication implementations v8.0.0 v7.9.0 labels May 23, 2020
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (:Distributed/Network)

@elasticmachine elasticmachine added the Team:Distributed Meta label for distributed team. label May 23, 2020
Copy link
Copy Markdown
Member

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

LGTM assuming that there's only a single thread in play here; I think there is but I'm not 100% familiar with this code.

Requested an assertion that I think would catch any bad threading anyway.

if (buf == null) {
buf = Netty4Utils.toByteBuf(context.get());
context = null;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we assert context == null here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, added it. But yes, all of this is happening on a single IO thread thread so this is all safe I think :)

@original-brownbear
Copy link
Copy Markdown
Contributor Author

Thanks David!

@original-brownbear original-brownbear merged commit beb3e49 into elastic:master May 27, 2020
@original-brownbear original-brownbear deleted the even-lazier-writes branch May 27, 2020 11:31
original-brownbear added a commit that referenced this pull request Jun 4, 2020
Follow up to #56961:

We can be a little more efficient than just serializing at the IO loop by serializing
only when we flush to a channel. This has the advantage that we don't serialize a long
queue of messages for a channel that isn't writable for a longer period of time (unstable network,
actually writing large volumes of data, etc.).
Also, this further reduces the time for which we hold on to the write buffer for a message,
making allocations because of an empty page cache recycler pool less likely.
@original-brownbear original-brownbear restored the even-lazier-writes branch August 6, 2020 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Network Http and internode communication implementations >non-issue Team:Distributed Meta label for distributed team. v7.9.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants