Improve performance of external (UDR) functions#7989
Conversation
|
Does this only improve the performance of external functions only, or is there an effect for procedures/triggers too? |
It's mostly about functions only. There could be a marginal improvement with procedures with parameters with constraints, but I didn't tested it, as procedure/trigger implementation could also be greater improved, but is much more difficult. |
|
@dyemanov are you going to review this before merge? |
| dsc dstDesc = dstDescIt[0]; | ||
| dstDesc.dsc_address = dstMsg + dstArgOffset; | ||
|
|
||
| MOV_move(tdbb, &srcDesc, &dstDesc); |
There was a problem hiding this comment.
In some places we still have the code like this:
if (DSC_EQUIV(src, dst))
memcpy
else
MOV_move
Do you think it could improve something? I know we also have the same trick inside CVT_move_common(), but it's two calls deeper in the stack...
There was a problem hiding this comment.
It's already being done in CVT_move_common.
It's not inline, but, I think this is not going to be so relevant.
| *dstNullPtr = 0; | ||
| } | ||
| else | ||
| *dstNullPtr = -1; |
There was a problem hiding this comment.
Maybe add a named constant e.g. MSG_NULL_FLAG = -1 instead of using magic numbers directly in code?
There was a problem hiding this comment.
I think FB_FALSE / FB_TRUE could be used as we used them extensively in similar places.
| Parameter* parameter = parameters[argNumber / 2]; | ||
| defaultValueNode = NULL; | ||
| // Iterate over the format items, except the EOF item. | ||
| const unsigned paramCount = message->format->fmt_count / 2; |
There was a problem hiding this comment.
Being paranoid, I'd also add an assertion about fmt_count being even ;-)
There was a problem hiding this comment.
It should be wrong. It's used to initialize output message, that is going to have the null flag.
In this case, it purposely ignores it.
|
|
||
| // Initialize outputs in the internal message. | ||
| { // scope | ||
| fb_assert(udf->getOutputFormat()->fmt_desc.getCount() / 2 == udf->getOutputFields().getCount()); |
There was a problem hiding this comment.
I see nothing this scope would protect. Is it really needed?
There was a problem hiding this comment.
I used it mostly as a block to not create a separate function just for it.
I'm not removing the explicit scope label.
| defaultValue = EVL_expr(tdbb, request, fieldInfo.defaultValue); | ||
|
|
||
| if (request->req_flags & req_null) | ||
| defaultValue = nullptr; |
There was a problem hiding this comment.
IIRC, this condition/assignment is redundant, EVL_expr() is guaranteed to return nullptr in this case.
Test preparation:
Comparison: