Repository navigation
Simple benchmark to compare OwnedImpl::add to WatermarkBuffer::add - #19169
Conversation
Also, benchmark to cover buffer account use. Signed-off-by: Antonio Vicente <[email protected]>
|
Benchmark results included below. The summary is that the high watermark checks can have a measurable performance impact when doing a lot of small writes as seen during HTTP1 header serialization to the output buffer. The bulk of the impact seems to come from use of WatermarkBuffer instead of OwnedImpl even if the high-watermark is not set. WatermarkBuffer is most expensive in cases where the high-watermark is already triggered due to additional checks needed to determine if the overflow watermark callback should be invoked. Accounts may have some performance impact when doing a large number of mid-sized writes but the performance impact is low. I'm wondering if there's some room for improvement in how high/low watermark checks are done. Strawperson: Have a RAII scoped object that wraps code regions where a specific buffer may increase/decrease in size. Record the size of the buffer when entering the block. Check if it has increased/decreased when exiting the block and invoke the appropriate high/low callback. There should be an ASSERT at the top of each buffer mutation method to verify that the mutation call happened in the context of a mutation enabler RAII scoped object in order to ensure in debug mode that all mutations happen in contexts which will trigger watermark checks afterwards. In addition to performance, benefits of this approach may include limiting the number of different call stacks in which high/low watermark callbacks are triggered. |
|
cc @wbpcode |
|
@antoniovicente 👍 Looks great. May be we also can add some more test to observe the impact of write unit length on buffer performance |
alyssawilk
left a comment
There was a problem hiding this comment.
Awesome - love having more data here!
|
/retest |
|
Retrying Azure Pipelines: |
KBaichoo
left a comment
There was a problem hiding this comment.
Thanks for adding these benchmarks, looks good otherwise.
| UNREFERENCED_PARAMETER(_); | ||
| Buffer::OwnedImpl buffer; | ||
| if (enable_accounts) { | ||
| auto account = buffer_factory.createAccount(reset_handler); |
There was a problem hiding this comment.
We'll want to call clearDownstream() on this account when we're finished with it
There was a problem hiding this comment.
The reset_handler outlives the account so it shouldn't be needed. I changed the benchmark so clearDownstream() is called.
| buffer->add("a", 1); | ||
| } | ||
| } | ||
| benchmark::DoNotOptimize(length); |
There was a problem hiding this comment.
nit: I don't think this is needed for this benchmark (and probably not in a lot of the other ones where it has been cargo culted)
There was a problem hiding this comment.
Thanks. I removed this one, the remaining ones seem correct.
Signed-off-by: Antonio Vicente <[email protected]>
Added a 32 byte write case to contrast with the 1 byte write case. Full results below. As expected, the reduction in number of buffer operations results in a significantly faster benchmark result. I think that the benchmark you're reaching for is add(size) vs reserve(N*size) plus memcpy's which is a different situation. Still I hope that we can use these simple benchmarks as a starting point towards understanding where time is spent and if we can do anything to shave off some cycles. |
Commit Message:
Simple benchmark to compare OwnedImpl::add to WatermarkBuffer::add
Also, benchmark to cover buffer account use.
Risk Level: n/a (benchmark, test-only changes)
Testing: test-only changes
Docs Changes: n/a
Release Notes: n/a