Skip to content
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 IncludeExcludeSet testing #9071

Merged
merged 2 commits into from
Dec 20, 2022

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Dec 19, 2022

Improve testing and code coverage of IncludeExcludeSet.

Updating IncludeExcludeSet for best performing .test(input) method.
(jmh testing of different algorithms shows this one to be fastest)

Signed-off-by: Joakim Erdfelt joakim.erdfelt@gmail.com

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Comment on lines 177 to 183
if (!_includes.isEmpty())
{
// We have includes defined, if input has no match, return false immediately
if (!_includePredicate.test(t))
return false;
// We have an include match, let excludes override if needed.
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't find the cascading ifs with hanging comment clearer. How about:

Suggested change
if (!_includes.isEmpty())
{
// We have includes defined, if input has no match, return false immediately
if (!_includePredicate.test(t))
return false;
// We have an include match, let excludes override if needed.
}
// If we have defined includes, but none match then
if (!_includes.isEmpty() && !_includePredicate.test(t))
{
// return false immediately, no need to check excluded
return false;
}
// We are included by omission or match, so we now check excludes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually one of the implementations we tried.

This was the "simplified" algorithm from ...
https://github.com/eclipse/jetty.project/blob/fix/jetty-12.0.x/improve-includeexcludeset/jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/IncludeExcludeSet.java#L160-L164

It (surprisingly) is 10% slower in the jmh testing than what we are using now.
I'll be happy to adjust the comments though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be identical, but it wasn't.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm very dubious of the test if they are not identical!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm very dubious of the test if they are not identical!

You aren't the only one, even @sbordet and @lorban had the same initial reaction, and even with some jmh test tweaking couldn't make it identical.
Even testing both techniques side by side on the same jmh run showed the difference! (consistently the same difference each jmh run)

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime requested a review from gregw December 19, 2022 22:49
@joakime joakime merged commit b01bcdc into jetty-10.0.x Dec 20, 2022
@joakime joakime deleted the fix/jetty-10.0.x/IncludeExcludeSet-redux branch December 20, 2022 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants