-
Notifications
You must be signed in to change notification settings - Fork 39
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
feat: error resolution flow control without exceptions #1095
feat: error resolution flow control without exceptions #1095
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1095 +/- ##
============================================
+ Coverage 95.09% 95.34% +0.25%
- Complexity 400 402 +2
============================================
Files 39 39
Lines 917 924 +7
Branches 56 56
============================================
+ Hits 872 881 +9
+ Misses 24 23 -1
+ Partials 21 20 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
So far we used exception to handle our flowcontrol, but Exceptions are costly. In the end we enriched our evaluation Details with errorCode and errorMessage. This can be also handled by the providers if desired, to reduce the execution footprint in errornous cases, which do not have to be exceptions. Eg FlagNotFound - it might be the case, but in performance critical environments, an exception rather than a normal return, can cause overhead and can be already too costly. Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
2e3344d
to
4fb8e6b
Compare
IntStream.range( 0, 1000000 ).parallel().forEach(i -> {
String key = "key" + i;
c.getBooleanDetails(key, false);
});
Remarks:
// EDIT: forget about my tests, i might have made a mistake - i cant reproduce this - hence that, those are bad tests. // EDIT: https://www.baeldung.com/java-exceptions-performance is a nice comprehensive post about this |
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.
I agree with @guidobrei 's point here.
In addition, I'm wondering if we should remove stack traces from some or all Errors, in addition to the FlagNotFound.
I think for a few, like ProviderNotReady
and TypeMismatch
we can also remove the stack trace, especially since these will be frequently instantiated by the SDK here and it's very obvious what the problem is.
I added this via a parent class to the errors mentioned. This way, we can easily identify them later. Wdyt? (we can also try to achieve this with an interface and default methods) |
d523c6b
to
db6033b
Compare
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
db6033b
to
3d4b992
Compare
Not sure for the |
OK I'm fine with that. |
Approved but you can make the |
This has got me wondering if there is value in creating some JMH benchmarks for the sdk...? |
src/main/java/dev/openfeature/sdk/exceptions/TypeMismatchError.java
Outdated
Show resolved
Hide resolved
….java Co-authored-by: Justin Abrahms <justin@abrah.ms> Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
Quality Gate passedIssues Measures |
So far, we used exceptions to handle our flow control, but Exceptions are costly. In the end, we enriched our
evaluation Details with errorCode and errorMessage. If desired, the providers can also handle this to reduce the execution footprint in erroneous cases, which don't have to be exceptions. Till now, we also converted those into exceptions and threw them, with this little code change, we would return already the details, and call the hooks, without exceptions being thrown.
For example, FlagNotFound is such a case; it can be expected and not exceptional. Hence, the exception flow might add too much overhead to performance-critical environments.
This implementation now allows the prover implementors to decide whether to support either or both.
Follow-up Tasks
Most likely this is something we also want to do in all other sdks.
How to test