Skip to content

fuzz: improve fuzz performance for accesslog and route #8397

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

Merged
merged 2 commits into from
Oct 4, 2019

Conversation

asraa
Copy link
Contributor

@asraa asraa commented Sep 26, 2019

This PR includes some performance improvements to route_fuzz_test.

Exec/sec on my local machine with libFuzzer:

  • route_fuzz_test: 17 exec/sec -> 850 exec/sec

Risk level: Low

Signed-off-by: Asra Ali [email protected]

@asraa
Copy link
Contributor Author

asraa commented Sep 26, 2019

/review @htuch

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Very promising speedups :)

std::vector<AccessLog::FormatterProviderPtr> formatters =
AccessLog::AccessLogFormatParser::parse(input.format());
AccessLog::AccessLogFormatParser::parse(replaceInvalidCharacters(input.format()));
Copy link
Member

Choose a reason for hiding this comment

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

Should we have PGV annotations for this rather than substitution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I have this PR out specifically for that purpose because I'd like to have a PGV constraints for string to not_contain a null character, I bumped it last week, but will do again.
bufbuild/protoc-gen-validate#253

Actually a lot of time is being spend replacing invalid characters across all fuzzers and it'd be nice to either have this PGV constraint, or specifically guide mutations to not contain nulls.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, maybe remove this for now and then wait until bufbuild/protoc-gen-validate#253 lands; I agree that the PGV constraint is the right long term solution, not only for performance, but because Envoy will reject bad configs on the wire when we add these annotations to the API.

@@ -48,6 +47,10 @@ cleanRouteConfig(envoy::api::v2::RouteConfiguration route_config) {
// remove from each request and response that get routed through it. This replaces invalid
// header characters in these fields.
virtual_host = replaceInvalidHeaders<envoy::api::v2::route::VirtualHost>(virtual_host);
// Replace invalid characters from the list of domains matched to this virtual host.
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

@@ -69,9 +72,9 @@ cleanRouteConfig(envoy::api::v2::RouteConfiguration route_config) {

// TODO(htuch): figure out how to generate via a genrule from config_impl_test the full corpus.
DEFINE_PROTO_FUZZER(const test::common::router::RouteTestCase& input) {
static NiceMock<Envoy::StreamInfo::MockStreamInfo> stream_info;
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@htuch htuch self-assigned this Sep 26, 2019
@stale
Copy link

stale bot commented Oct 4, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Oct 4, 2019
@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Oct 4, 2019
@htuch htuch merged commit f4755c3 into envoyproxy:master Oct 4, 2019
nandu-vinodan pushed a commit to nandu-vinodan/envoy that referenced this pull request Oct 17, 2019
This PR includes some performance improvements to route_fuzz_test.

gMock objects that are unmodified are now static (see recommendation by libFuzzer: https://llvm.org/docs/LibFuzzer.html#startup-initialization)
Exec/sec on my local machine with libFuzzer:

route_fuzz_test: 17 exec/sec -> 850 exec/sec
Risk level: Low

Signed-off-by: Asra Ali <[email protected]>
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.

2 participants