-
-
Notifications
You must be signed in to change notification settings - Fork 76
Description
I’m using cache2k 2.0.0.Final.
In org.cache2k.processor.EntryProcessor, I see the code:
try {
R result = processor.process(mutableEntry);
c.result(result);
} catch (WantsDataRestartException rs) {
c.wantData();
return;
} catch (NeedsLockRestartException ex) {
needsLock = true;
c.wantData();
return;
} catch (Throwable t) {
c.failure(new EntryProcessingException(t));
return;
}
So it's code were exception are used as flow control. But it's usually a bad idea, see https://shipilev.net/blog/2014/exceptional-performance/ for a deep analysis of that.
For example, when generating flamegraph for some of my code, I get the following result:
Most of the time is spent filling in the stack trace.
The code that generate this stack can be found at NettyNameResolver.java
Performance could be increased I think if both WantsDataRestartException and NeedsLockRestartException (and perhaps other) were static and not saving the stack.
This constructor can be used for that:
protected Exception(String message,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace)
If writableStackTrace is set to false, the stack trace is not saved.
