envoy icon indicating copy to clipboard operation
envoy copied to clipboard

json: replace literal string to constexpr and force Streamer to use simple output abstraction

Open wbpcode opened this issue 1 year ago • 1 comments

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.

wbpcode avatar Aug 29 '24 03:08 wbpcode

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

wbpcode avatar Aug 29 '24 03:08 wbpcode

quic is also flaky frequently.

wbpcode avatar Aug 31 '24 01:08 wbpcode

/retest

wbpcode avatar Aug 31 '24 01:08 wbpcode

/retest

wbpcode avatar Aug 31 '24 15:08 wbpcode

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?)

wbpcode avatar Sep 01 '24 15:09 wbpcode

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.

jmarantz avatar Sep 03 '24 03:09 jmarantz

Seems @alyssawilk still on vacation. Let's assign this to another senior maintainer.

/assign-from @envoyproxy/senior-maintainers

wbpcode avatar Sep 03 '24 14:09 wbpcode

@envoyproxy/senior-maintainers assignee is @alyssawilk

:cat:

Caused by: a https://github.com/envoyproxy/envoy/pull/35892#issuecomment-2326624629 was created by @wbpcode.

see: more, trace.

/assign-from @envoyproxy/senior-maintainers

wbpcode avatar Sep 03 '24 14:09 wbpcode

@envoyproxy/senior-maintainers assignee is @yanavlasov

:cat:

Caused by: a https://github.com/envoyproxy/envoy/pull/35892#issuecomment-2326625862 was created by @wbpcode.

see: more, trace.