On 07.05.23 00:56, MG wrote:
Hi guys,
we have (a bit of an urgent) performance problem: The SQL generation
part that is an elemental part of our framework has become too slow in
certain key cases in the most recent extension to our main web application.
We have finally narrowed the cause down to what looks like the main
bottleneck, and to our surprise it is a very harmless looking ctor call
that every Table class uses to internally create references of itself:
Table(String name, String shortName, Table parentTable = null, boolean
isReference = false, Schema schema = null) {
super(name) // Base class just stores name in String field
this.parentTable = parentTable
this.shortName = shortName
this.isReferenceTable = isReference
this.schema = schema
this.originalTableField = parentTable?.originalTableField
}
The cost of the ctor should be something like:
cost for delegating this-call (1)
+ cost for super-call (2)
+ cost for initiating the trait helpers (3)
+ cost for setting fields (4)
[...]
The KMS, TBKMS, etc classes look harmless enough, and the only thing I
can see is, that it seems the performance degradation seems to be tied
to the number of traits the class depends on.
That speaks for (3) getting out of hand.
It could be the meta class generation... if you have one class and 5
traits, then you generate 1 meta class for the class itself and 1 for
each helper, that would mean then 6.
And that even though the helpers do not need meta classes in my opinion.
[...]
If any one has any suggestions how to speed up our scenario, that would
be appreciated. The code this applies to is a mix of predominantly
static & some dynamic Groovy...
If possible could you use @CompileStatic @POJO on the traits and see if
that improves things? This would reduce the number of generated meta
classes in the constructor at least. They might be still created of
course. So maybe it is no complete solution. But if you can put it on
even some of the traits the improvement should be noticeable. Then we
know for sure that this is the problem and discuss further steps.
Otherwise I would have to see the bytecode of the ctors of the trait
helpers and the table class to say more
bye Jochen