Skip to content

switch to using json sanitizer for admin counters, gauges, and text-readouts#20745

Merged
jmarantz merged 7 commits intoenvoyproxy:mainfrom
jmarantz:json-sanitize-admin-stats
Apr 12, 2022
Merged

switch to using json sanitizer for admin counters, gauges, and text-readouts#20745
jmarantz merged 7 commits intoenvoyproxy:mainfrom
jmarantz:json-sanitize-admin-stats

Conversation

@jmarantz
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz commented Apr 8, 2022

Commit Message: Uses the new Json::sanitizer from #20637 to generate counters, gauges, and text-readouts in response to admin endpoint /stats?format=json, resulting in a 5.6x speedup for AllCountersJson, and making JSON output only around 10% slower than text output.

Additional Description:
Before:

------------------------------------------------------------------
Benchmark                        Time             CPU   Iterations
------------------------------------------------------------------
BM_AllCountersText             454 ms          453 ms            2
BM_UsedCountersText           35.8 ms         35.8 ms           20
BM_FilteredCountersText       1806 ms         1805 ms            1
BM_AllCountersJson            2824 ms         2823 ms            1
BM_UsedCountersJson           61.8 ms         61.8 ms           11
BM_FilteredCountersJson       1798 ms         1798 ms            1

after

------------------------------------------------------------------
Benchmark                        Time             CPU   Iterations
------------------------------------------------------------------
BM_AllCountersText             458 ms          458 ms            2
BM_UsedCountersText           36.1 ms         36.1 ms           19
BM_FilteredCountersText       1790 ms         1790 ms            1
BM_AllCountersJson             496 ms          496 ms            2
BM_UsedCountersJson           36.4 ms         36.4 ms           19
BM_FilteredCountersJson       1789 ms         1789 ms            1

Risk Level: low -- Json::sanitizer is new, but based on nlohmann, and is differentially fuzzed vs protobuf serialization
Testing: //test/server/admin/...
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

…eadouts

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #20745 was opened by jmarantz.

see: more, trace.

jmarantz added 2 commits April 8, 2022 18:58
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title switch to using json sanitizer for admin counters, gauges, and text-r… switch to using json sanitizer for admin counters, gauges, and text-readouts Apr 9, 2022
jmarantz added 2 commits April 9, 2022 00:02
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #20745 (comment) was created by @jmarantz.

see: more, trace.

@jmarantz jmarantz marked this pull request as ready for review April 10, 2022 02:55
@wbpcode wbpcode self-assigned this Apr 11, 2022
Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

LGTM overall. Only one nit comment.

std::unique_ptr<ProtobufWkt::ListValue> histogram_array_;
bool found_used_histogram_{false};
bool first_{true};
absl::string_view delim_{""};
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.

nit: absl::string_view delim_;

Copy link
Copy Markdown
Contributor Author

@jmarantz jmarantz Apr 11, 2022

Choose a reason for hiding this comment

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

nope; need to init to a valid pointer as this is used in Buffer::addFragments which passes .data() to memcpy, and having nullptr for the src arg fails ASAN even if size==0 :)

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.

get it.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #20745 (comment) was created by @jmarantz.

see: more, trace.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

LGTM.

@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Apr 12, 2022

cc @envoyproxy/senior-maintainers for merge or second pass for this PR that contains some core code updates.

@zuercher
Copy link
Copy Markdown
Member

/assign-from @envoyproxy/senior-maintainers

@repokitteh-read-only
Copy link
Copy Markdown

@envoyproxy/senior-maintainers assignee is @zuercher

🐱

Caused by: a #20745 (comment) was created by @zuercher.

see: more, trace.

@zuercher
Copy link
Copy Markdown
Member

@jmarantz I'll leave the merge to you

@jmarantz jmarantz merged commit 18acdb0 into envoyproxy:main Apr 12, 2022
@jmarantz jmarantz deleted the json-sanitize-admin-stats branch April 12, 2022 20:03
vehre-x41 pushed a commit to vehre-x41/envoy that referenced this pull request Apr 19, 2022
…eadouts (envoyproxy#20745)

Commit Message: Uses the new Json::sanitizer from envoyproxy#20637 to generate counters, gauges, and text-readouts in response to admin endpoint `/stats?format=json`, resulting in a 5.6x speedup for AllCountersJson, and making JSON output only around 10% slower than text output.

Additional Description:
Before:
```
------------------------------------------------------------------
Benchmark                        Time             CPU   Iterations
------------------------------------------------------------------
BM_AllCountersText             454 ms          453 ms            2
BM_UsedCountersText           35.8 ms         35.8 ms           20
BM_FilteredCountersText       1806 ms         1805 ms            1
BM_AllCountersJson            2824 ms         2823 ms            1
BM_UsedCountersJson           61.8 ms         61.8 ms           11
BM_FilteredCountersJson       1798 ms         1798 ms            1
```
after
```
------------------------------------------------------------------
Benchmark                        Time             CPU   Iterations
------------------------------------------------------------------
BM_AllCountersText             458 ms          458 ms            2
BM_UsedCountersText           36.1 ms         36.1 ms           19
BM_FilteredCountersText       1790 ms         1790 ms            1
BM_AllCountersJson             496 ms          496 ms            2
BM_UsedCountersJson           36.4 ms         36.4 ms           19
BM_FilteredCountersJson       1789 ms         1789 ms            1
```

Risk Level: low -- Json::sanitizer is new, but based on nlohmann, and is differentially fuzzed vs protobuf serialization
Testing: //test/server/admin/...
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a


Signed-off-by: Joshua Marantz <jmarantz@google.com>
ogle.com>
Signed-off-by: Andre Vehreschild <vehre@x41-dsec.de>
ravenblackx pushed a commit to ravenblackx/envoy that referenced this pull request Jun 8, 2022
…eadouts (envoyproxy#20745)

Commit Message: Uses the new Json::sanitizer from envoyproxy#20637 to generate counters, gauges, and text-readouts in response to admin endpoint `/stats?format=json`, resulting in a 5.6x speedup for AllCountersJson, and making JSON output only around 10% slower than text output.

Additional Description:
Before:
```
------------------------------------------------------------------
Benchmark                        Time             CPU   Iterations
------------------------------------------------------------------
BM_AllCountersText             454 ms          453 ms            2
BM_UsedCountersText           35.8 ms         35.8 ms           20
BM_FilteredCountersText       1806 ms         1805 ms            1
BM_AllCountersJson            2824 ms         2823 ms            1
BM_UsedCountersJson           61.8 ms         61.8 ms           11
BM_FilteredCountersJson       1798 ms         1798 ms            1
```
after
```
------------------------------------------------------------------
Benchmark                        Time             CPU   Iterations
------------------------------------------------------------------
BM_AllCountersText             458 ms          458 ms            2
BM_UsedCountersText           36.1 ms         36.1 ms           19
BM_FilteredCountersText       1790 ms         1790 ms            1
BM_AllCountersJson             496 ms          496 ms            2
BM_UsedCountersJson           36.4 ms         36.4 ms           19
BM_FilteredCountersJson       1789 ms         1789 ms            1
```

Risk Level: low -- Json::sanitizer is new, but based on nlohmann, and is differentially fuzzed vs protobuf serialization
Testing: //test/server/admin/...
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a


Signed-off-by: Joshua Marantz <jmarantz@google.com>
ogle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants