envoy
envoy copied to clipboard
json: replace literal string to constexpr and force Streamer to use simple output abstraction
Commit Message: json: replace literal string to constexpr and force Streamer to use simple output abstraction Additional Description:
Continuous work of #35891. This replace the literal string to constexpr string view to make it's more friendly for dev tools. And this PR also create a simple wrapper to the Buffer::Instance to force the Streamer only access the limited abstraction (only provides an add()) to streaming it's output.
Risk Level: low. Testing: n/a. Docs Changes: n/a. Release Notes: n/a. Platform Specific Features: n/a.
BM_AllCountersJson/per_endpoint_stats_disabled_mean 570 ms 570 ms 10 output per iteration: 135789011
BM_AllCountersJson/per_endpoint_stats_enabled_mean 979 ms 979 ms 10 output per iteration: 180082411
BM_UsedCountersJson/per_endpoint_stats_disabled_mean 13.9 ms 13.9 ms 10 output per iteration: 1348901
BM_UsedCountersJson/per_endpoint_stats_enabled_mean 415 ms 415 ms 10 output per iteration: 45642301
BM_FilteredCountersJson/per_endpoint_stats_disabled_mean 172 ms 172 ms 10 output per iteration: 12
BM_FilteredCountersJson/per_endpoint_stats_enabled_mean 490 ms 490 ms 10 output per iteration: 12
BM_HistogramsJson/per_endpoint_stats_disabled_mean 10.2 ms 10.2 ms 10 output per iteration: 1820890
BM_HistogramsJson/per_endpoint_stats_enabled_mean 10.2 ms 10.2 ms 10 output per iteration: 1820890
quic is also flaky frequently.
/retest
/retest
I think the BufferOutput abstraction is useful if you make it an interface, and we exploit that with 2 overrides instead of using a template. But if we go with templating, you don't need to specify the class this way: just document that the templatized class must implement two methods.
I am inclined to use template and I will document it in the last PR . At that PR we will change the Streamer to template class.
The wrapper here is to ensure we needn't to change anything at the call sites of the output abstraction at the last PR. We just need to change the class Streamer to template <class OutputType> class Streamer. (And the constructor, may be only 5 lines code changes at last PR?)
Good point about sharing keywords. And the modern way of using a constexpr string view avoids the annoying lazy string singleton.
But I suggest you move these constants to their own file. Eg source/common/json/constants.h or well_known_names.h.
Seems @alyssawilk still on vacation. Let's assign this to another senior maintainer.
/assign-from @envoyproxy/senior-maintainers
@envoyproxy/senior-maintainers assignee is @alyssawilk
/assign-from @envoyproxy/senior-maintainers