-
Notifications
You must be signed in to change notification settings - Fork 153
Conversation
Parse ex_conv_clause::convInstrStrInfo at sql process startup (in sqInit) into a sparsely populated index for quick reference by ex_conv_clause::findInstruction.
Parse ex_conv_clause::convInstrStrInfo at sql process startup (in sqInit) into a sparsely populated index for quick reference by ex_conv_clause::findInstruction.
Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1220/ |
Test Passed. https://jenkins.esgyn.com/job/Check-PR-master/1220/ |
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.
+1 Looks good, but there is a very tiny window where a thread-safety issue might cause incorrect results.
} | ||
|
||
// Allocate a sparsely populated array | ||
sv_convIndexSparse = (int *) calloc(sizeof(int), |
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 this logic is idempotent to it probably doesn't matter but it looks like two threads could do the calloc, one of them will win in setting sv_convIndexSparse, then both of them could interleave in the initialization logic below. Could be the fast one sets the sv_instrOffsetIndexPopulated flag to true while the slow one is in the Initialize to -1 loop so theoretically we could get wrong answers. Might be safer to use a local variable here and only set sv_convIndexSparse at the very end just before setting the boolean. Then the worst thing that happens is we allocated the array twice but it will never be inconsistent.
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.
Thanks Dave! Agreed - will take care of it as you suggested.
I will also remove the call to ex_conv_clause::populateInstrOffsetIndex() from ex_conv_clause::getInstrOffset. This way ex_conv_clause::populateInstrOffsetIndex() will only be called from sqInit().
New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1222/ |
conversion instructions are usually computed during compile of a query and Some scenarios where instructions are not generated is if expressions are not used In the query example of this jira, was an expression used to insert or was instruction being This change will help in fast computation of conversion instructions but we also need Another thing: in addition to conversions, instructions are also computed for comparison |
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.
Looks good. Please avoid calling ex_conv_clause::populateInstrOffsetIndex() at other places than sqInit as you have already mentioned in your response
Test Passed. https://jenkins.esgyn.com/job/Check-PR-master/1222/ |
Are we ready to merge this change in?. The other changes requested by @anoopsharma00 can be done in phases using the same JIRA. |
@narendragoyal , it might be good to edit add the JIRA heading in the subject line in github. This would help other reviewers to decide if he/she would want to review this PR, |
As part of the upsert (of the case in question), EXP_FIXED_OV_ADD or EXP_FIXED_OV_MUL functions are being called that then result in the findInstruction() being called many times The EXP_FIXED_OV_* functions call convDoIt() as follows (without passing the conv function (effectively 'unknown' ). We could get the conversion function once and set it in the call (that way 'convDoIt' does not have to compute it all the time). Perhaps we can do that as part of a follow on checkin for the JIRA. |
@selvaganesang, @anoopsharma00: Is this change ready to merge? |
+1 |
@anoopsharma00 Is it ok to merge this PR? |
I will merge this in. If there is any other fix needed further, it is good to create a new Jira |
[TRAFODION-2265]
Parse ex_conv_clause::convInstrStrInfo at sql process startup
(in sqInit) into a sparsely populated index for quick reference by
ex_conv_clause::findInstruction.