Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Removed frequent call to regex compile - thus saving CPU time. This was discovered through callgrind that pointed at regex compilation happening during URL normalization. The resulting code improves average time to serve requests by ~15% (during the load tests performed as part of the travis builds) and ~50% improvement in TP99 on INTERNAL_SELECT.
Quantitative Performance Benefits
It is possible to observe the performance improvement in output of the following travis builds:
Baseline (INTERNAL_SELECT): https://travis-ci.org/etr/libhttpserver/jobs/482289425
50% 5
66% 5
75% 6
80% 7
90% 8
95% 10
98% 13
99% 13
100% 25 (longest request)
New version (INTERNAL SELECT): https://travis-ci.org/etr/libhttpserver/jobs/482774149
50% 5
66% 5
75% 5
80% 5
90% 5
95% 6
98% 6
99% 7
100% 21 (longest request)
Baseline (THREAD_PER_CONNECTION): https://travis-ci.org/etr/libhttpserver/jobs/482289426
50% 11
66% 12
75% 12
80% 13
90% 14
95% 15
98% 18
99% 20
100% 365 (longest request)
New version (THREAD_PER_CONNECTION): https://travis-ci.org/etr/libhttpserver/jobs/482774150
50% 8
66% 9
75% 10
80% 10
90% 12
95% 14
98% 18
99% 21
100% 202 (longest request)
Possible Drawbacks
None real.
Verification Process
Tested using travis.
Applicable Issues
None
Release Notes
Reduced the CPU time spent in normalizing URLs (thus saving ~15% on average per request).