-
Notifications
You must be signed in to change notification settings - Fork 133
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
[OPENJPA-2924] BlacklistClassResolver is improved #118
Conversation
BTW IMO it would be useful to have some |
I assume all the constants can be hardcoded (no reflection needed) and match_any can be extracted to avoid any loop or alike and be a "return always true/false" impl when present? else ok for me, just a small note that in terms of perf it depends the number of hit of the preferred types (primitives/arrays) cause now the user does not control anymore the ordering so there are cases it can be slower - but I guess when this class is used it is not the most common concern :D |
Thanks for the quick review @rmannibucau :) primitives are in the Should I ? :) |
@solomax I'd prefer to drop that and update the old impl to use Set instead of arrays and do a "contains" and fallback on starts with if not, overhead will be low but I wouldn't hardcode - except in defaults - any type, including primitives and arrays. PS: also check the set constant time is faster than the array loop for a standard number of items, it is always constant but often slower |
@rmannibucau I have created this https://github.com/solomax/contains-microbench benchmark The results are:
this is my first benchmark, I'll appreciate review :) |
@solomax globally looks good to give an idea except a small detail: it tests arraylist which is not used instead of array of strings ( I modified the bench to add this test and here is my raw result:
(which is close to what you had for the overlapping part except you have a better computer ;)). What is interesting is that the set is "hot" faster by design where the array string needs some cycles (JIT) - but not sure it is critical since normally the blacklist is small and whitelist open. What is sure is that Reran with mode details - in particular the ops/sec instead of avg - here is what I'm getting:
So overall I'm not sure of the improvement in terms of speed nor usage - which would need to have stats about the ratio between primitives and custom classes, we can probably assume the primitives are numerous - if we include String as a primitive indeed - but I'm less convinced about arrays there. Keep in mind that even if we use a set for known types and add configuration to drop them from the default "known" set, we still need to iterate for other types so the speed of the set will be mitigated a bit and the small remaining distance with a plain array will be reduced so overall I think the compromise in terms of speed and code simplicity is not that bad with a plain array. Wdyt? |
@rmannibucau makes a lot of sense :) PR is updated :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for me, just for the record there is one case missing (but not worse than before): what when there are overlapping between or a wildcard.
There are a few options:
- if one wildcard and not the other -> test the other first to override the wildcard (often desired)
- add another config to say which list wins over the other (tomee flavor for ex)
- use the longest as "winner" and respect its list behavior (include/exclude)
but guess it is not needed there (yet at least ;))
The list of improvement is:
*
, this is especially useful for blacklist i.e. block allSystem.property
value is now treated as empty listprimitives are now whitelistedThe code might be simplified in case
Class
will be checked (not it's name)@rmannibucau you were the author of the original fix, could you please review these changes? :)