-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already being done in CVT_move_common.
It's not inline, but, I think this is not going to be so relevant.
src/jrd/ExtEngineManager.cpp
Outdated
*dstNullPtr = 0; | ||
} | ||
else | ||
*dstNullPtr = -1; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being paranoid, I'd also add an assertion about fmt_count
being even ;-)
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see nothing this scope would protect. Is it really needed?
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 used it mostly as a block to not create a separate function just for it.
I'm not removing the explicit scope
label.
src/jrd/ExtEngineManager.cpp
Outdated
defaultValue = EVL_expr(tdbb, request, fieldInfo.defaultValue); | ||
|
||
if (request->req_flags & req_null) | ||
defaultValue = nullptr; |
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.
IIRC, this condition/assignment is redundant, EVL_expr()
is guaranteed to return nullptr
in this case.
Test preparation:
Comparison: