Feature #6826
reduce the BDT usage in FWD runtime
100%
Related issues
History
#1 Updated by Constantin Asofiei over 1 year ago
There are resources like StaticTempTable where the state is kept as BDT, and converted APIs are being called to read this state, instead of accessing the state directly. BDT instances are heavy, and FWD runtime should use as few as possible, to reduce both BDT allocation count and CPU time.
This task is meant to:- analyze BDT usage in FWD - class members being kept for runtime purposes only need to be changed to their Java equivalent. Any complex scenarios, like maybe datetime/tz, need to be discussed.
- converted API calls where for example a character attribute is being read by FWD runtime, just to get its Java value - the Java value needs to be read directly.
- do not pass
handle
instances around the FWD runtime - pass the WrappedResource directly. ExternalProgramWrapper instances will be covered in #6817
Some fixes will be in 6129a/3821c.
#2 Updated by Constantin Asofiei over 1 year ago
- Related to Feature #6817: replace INSTANTIATING-PROCEDURE and other handle<ExternalProgram> with the actual referrent added
#3 Updated by Constantin Asofiei over 1 year ago
- Related to Feature #6827: reduce the memory footprint of WrappedResource implementations: replace BDTs with Java types added
#4 Updated by Constantin Asofiei over 1 year ago
The WrappedResource refactor will be done in #6827.
#5 Updated by Constantin Asofiei over 1 year ago
Some changes are in 3821c/14272. Ovidiu, please review.
#6 Updated by Constantin Asofiei over 1 year ago
Another idea is to replace new unknown
(conversion and runtime) with a singleton instance.
#7 Updated by Ovidiu Maxiniuc over 1 year ago
Constantin Asofiei wrote:
Global notes:Some changes are in 3821c/14272. Ovidiu, please review.
- the replacement of BDT (for
getUniqueID
andADM-DATA
attribute) is definitively a good thing: not only they take up less space but the operations are faster. I found no issues with the new code. - some time ago, I also wrote some code for nano-timing pieces of code related to (new) persistence. I did not commit them (or rolled them back) because I was afraid of a possible performance penalty which come with the wrapping the productive code as lambdas. There is also extra code for handling non-final variables constraint of Java. I wonder whether we can find a solution to allow direct call to Impl methods in normal code, and activate the JMX wrappers only when doing profiling. Maybe as an aspect post-processing?
- replacing
tableHandle().unwrapTempTable()
withgetParentTable()
is very nice. Maybe we do something similar for default buffer? I wonder whether we can cache the result, though.
AnnotatedAst
:
private String getPath(int max)
: it does not look like an optimization to me. All characters are twicereverse
d. If the original problem was theArrayList
iterator, then it cam be replaced with a (reversed)for
and each element from list can be accessed directly usingget(index)
(it returnselementData[index]
);private void putAnnotationImpl(String key, Object annotation)
: doesn'tRulesTracing
expect a lowercasekey
?
#8 Updated by Constantin Asofiei over 1 year ago
Ovidiu Maxiniuc wrote:
AnnotatedAst
:
private String getPath(int max)
: it does not look like an optimization to me. All characters are twicereverse
d. If the original problem was theArrayList
iterator, then it cam be replaced with a (reversed)for
and each element from list can be accessed directly usingget(index)
(it returnselementData[index]
);
The changes want to reduce the number of object allocations - String instances in this case. I've tested with and without, and the change is marginally better than the previous one. I'll continue keeping an eye on this.
private void putAnnotationImpl(String key, Object annotation)
: doesn'tRulesTracing
expect a lowercasekey
?
Fixed in 3821c/14281
3821c/14281 contains other performance improvements:- Performance improvements - avoid the ProcedureData lookup, by keeping a parallel stack of this data for THIS-PROCEDURE
#9 Updated by Greg Shah over 1 year ago
- Assignee set to Stanislav Lomany
#10 Updated by Constantin Asofiei over 1 year ago
Stanislav, did you start work on this?
#11 Updated by Stanislav Lomany over 1 year ago
No.
#12 Updated by Constantin Asofiei over 1 year ago
- Assignee changed from Stanislav Lomany to Constantin Asofiei
Stanislav Lomany wrote:
No.
OK, I'm taking it, as is easier to look in the profiler and see what can be reduced.
#13 Updated by Constantin Asofiei over 1 year ago
6129b/14366 contains a set of changes related to this, mainly from what profiling a large customer app showed.
#14 Updated by Constantin Asofiei over 1 year ago
- Status changed from New to Review
- % Done changed from 0 to 100
Profiling and manual/automated code review was used to identify BDT field and local variable definitions. These were replaced with their Java counterpart. This task can be closed, as in performance terms, the parts which showed up in profiling were fixed, and the code review covers a large part of possible BDT usage.
#15 Updated by Constantin Asofiei about 1 year ago
7826a/14811 fixes other cases to reduce BDT usage from within FWD runtime.
#16 Updated by Constantin Asofiei about 1 month ago
- Related to Bug #8510: replace all 'new logical' in FWD runtime with logical.of or logical.UNKNOWN added
#17 Updated by Ovidiu Maxiniuc about 1 month ago
There are many cases where a BDT is used as a short-lived constant value. The most of case are logical
and interger
s.
Can we implement a cache, similar to Integer
? They have a small cache of the most used values (up to 256 IIRC) and return these instead of creating these short-lived constant values. The unknown
values is just an example of such a constant. We must ensure they are immutable, or better said, use them only when they are immediately discarded (no assign
or other mutation allowed).