-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve substitution formatter parsing performance #35498
improve substitution formatter parsing performance #35498
Conversation
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
…ptimize-date-formatter
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
By the way, from the performance results, the json formatter is too slow...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Big fan of const std::string&
to string_view
migration.
Arguably the date formatting change could be a separate PR to the string-parameter change, but I'm okay with approving both together.
testing::NiceMock<MockTimeSystem> time_system; | ||
ON_CALL(time_system, systemTime()) | ||
.WillByDefault(testing::Return(SystemTime(std::chrono::seconds(1234567890)))); | ||
ON_CALL(time_system, monotonicTime()) | ||
.WillByDefault(testing::Return(MonotonicTime(std::chrono::seconds(1234567890)))); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this block is repeated a lot, probably worth a helper function so you can just do MockTimeSystem time_system = makeMockTime()
(the function can still wrap it in a NiceMock but you won't have to say it's so every time, or set up the ON_CALLs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, let's have a try.
cc @ravenblackx Thanks so much for the approval. And yeah, actually DateFormatter refactoring is a separated PR. See #35450 I developed this patch based on #35450. And I will do a rebase after #35450 is landed. |
Signed-off-by: wbpcode <[email protected]>
Signed-off-by: wbpcode <[email protected]>
@@ -16,17 +16,9 @@ namespace Formatter { | |||
class MetadataFormatterCommandParser : public ::Envoy::Formatter::CommandParser { | |||
public: | |||
MetadataFormatterCommandParser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructor should be =default or not declared at all now that the impl was removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmmm, so weird. I need to re run the tests in my local env.
I remember I had fixed all these. Seems some code changes are lost.
Signed-off-by: wbpcode <[email protected]>
Any idea why JSON is 20x slower? Is it because it's using some library? |
Not sure. But format the output proto struct has taken 10x time than the text formatter. |
/retest |
…efactor-formatter-with-re2
Signed-off-by: wbpcode <[email protected]>
#35450 was landed. Now, it's this PR's turn. |
/assign-from @envoyproxy/senior-maintainers |
@envoyproxy/senior-maintainers assignee is @mattklein123 |
…efactor-formatter-with-re2
/retest |
Commit Message: improve substitution formatter parsing performance Additional Description: See envoyproxy#35466 Previous parsing performance result: ``` --------------------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------------------- BM_AccessLogFormatterSetup 75744 ns 75605 ns 9401 ``` Latest parsing performance result: ``` --------------------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------------------- BM_AccessLogFormatterSetup 8932 ns 8917 ns 78153 ``` Risk Level: mid. Core code change. Testing: unit. Docs Changes: n/a. Release Notes: no behavior change. Platform Specific Features: n/a. --------- Signed-off-by: wbpcode <[email protected]> Signed-off-by: Martin Duke <[email protected]>
Commit Message: improve substitution formatter parsing performance Additional Description: See envoyproxy#35466 Previous parsing performance result: ``` --------------------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------------------- BM_AccessLogFormatterSetup 75744 ns 75605 ns 9401 ``` Latest parsing performance result: ``` --------------------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------------------- BM_AccessLogFormatterSetup 8932 ns 8917 ns 78153 ``` Risk Level: mid. Core code change. Testing: unit. Docs Changes: n/a. Release Notes: no behavior change. Platform Specific Features: n/a. --------- Signed-off-by: wbpcode <[email protected]> Signed-off-by: asingh-g <[email protected]>
Commit Message: improve substitution formatter parsing performance
Additional Description:
See #35466
Previous parsing performance result:
Latest parsing performance result:
Risk Level: mid. Core code change.
Testing: unit.
Docs Changes: n/a.
Release Notes: no behavior change.
Platform Specific Features: n/a.