Skip to content

fuzz: improve fuzz performance for accesslog and route#8397

Merged
htuch merged 2 commits intoenvoyproxy:masterfrom
asraa:usellvminitialize
Oct 4, 2019
Merged

fuzz: improve fuzz performance for accesslog and route#8397
htuch merged 2 commits intoenvoyproxy:masterfrom
asraa:usellvminitialize

Conversation

@asraa
Copy link
Copy Markdown
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 asraa@google.com

Signed-off-by: Asra Ali <asraa@google.com>
@asraa
Copy link
Copy Markdown
Contributor Author

asraa commented Sep 26, 2019

/review @htuch

Copy link
Copy Markdown
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 :)

// Remove invalid characters in request/response formatters.
std::vector<AccessLog::FormatterProviderPtr> formatters =
AccessLog::AccessLogFormatParser::parse(input.format());
AccessLog::AccessLogFormatParser::parse(replaceInvalidCharacters(input.format()));
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.

Should we have PGV annotations for this rather than substitution?

Copy link
Copy Markdown
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
Copy Markdown
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.

// 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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ditto


// 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
Copy Markdown
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
Signed-off-by: Asra Ali <asraa@google.com>
@stale
Copy link
Copy Markdown

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 <asraa@google.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.

2 participants