Skip to content

Commit 96a7e08

Browse files
asraanandu-vinodan
authored andcommitted
fuzz: improve fuzz performance for accesslog and route (envoyproxy#8397)
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]>
1 parent b1ef32e commit 96a7e08

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

test/common/router/route_fuzz_test.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ cleanRouteConfig(envoy::api::v2::RouteConfiguration route_config) {
3636
// headers.
3737
envoy::api::v2::RouteConfiguration clean_config =
3838
replaceInvalidHeaders<envoy::api::v2::RouteConfiguration>(route_config);
39-
// Replace invalid characters from
4039
auto internal_only_headers = clean_config.mutable_internal_only_headers();
4140
std::for_each(internal_only_headers->begin(), internal_only_headers->end(),
4241
[](std::string& n) { n = Fuzz::replaceInvalidCharacters(n); });
@@ -69,9 +68,9 @@ cleanRouteConfig(envoy::api::v2::RouteConfiguration route_config) {
6968

7069
// TODO(htuch): figure out how to generate via a genrule from config_impl_test the full corpus.
7170
DEFINE_PROTO_FUZZER(const test::common::router::RouteTestCase& input) {
71+
static NiceMock<Envoy::StreamInfo::MockStreamInfo> stream_info;
72+
static NiceMock<Server::Configuration::MockFactoryContext> factory_context;
7273
try {
73-
NiceMock<Envoy::StreamInfo::MockStreamInfo> stream_info;
74-
NiceMock<Server::Configuration::MockFactoryContext> factory_context;
7574
TestUtility::validate(input.config());
7675
ConfigImpl config(cleanRouteConfig(input.config()), factory_context, true);
7776
Http::TestHeaderMapImpl headers = Fuzz::fromHeaders(input.headers());

0 commit comments

Comments
 (0)