-
Notifications
You must be signed in to change notification settings - Fork 116
Add new IndexLogEntryTag to avoid duplicate calculation in getCandidateIndexes #293
Conversation
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
So, what's the summary? I wasn't sure which number to look at to see the gain. Also, is the duration in milliseconds? |
|
@imback82 I updated the test results with 2 different binaries. |
|
Cool, the result makes more sense now. I will get to the review this weekend. @apoorvedave1 / @pirz can you review this PR meanwhile? Thanks! |
imback82
left a comment
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.
General approach seems fine to me.
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
|
|
||
| indexes.foreach { index => | ||
| val taggedConfigs = index.getTagValue(plan, HYBRIDSCAN_CONFIG_CAPTURE) | ||
| if (taggedConfigs.isEmpty || !taggedConfigs.get.equals(curConfigs)) { |
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.
nit: prefer using map or foreach for this pattern taggedConfigs.isEmpty || taggedConfigs.get:
index.getTagValue(plan, HYBRIDSCAN_CONFIG_CAPTURE).foreach { taggedConfigs =>
if (taggedConfigs.equals(curConfigs)) {
// Need to reset cached tags as these config changes can change the result.
index.unsetTagValue(plan, IS_HYBRIDSCAN_CANDIDATE)
index.setTagValue(plan, HYBRIDSCAN_CONFIG_CAPTURE, curConfigs)
}
}
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/rules/RuleUtils.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/rules/RuleUtils.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/rules/RuleUtils.scala
Outdated
Show resolved
Hide resolved
Can you update these, which are not in the code base anymore? |
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntryTags.scala
Outdated
Show resolved
Hide resolved
| isCandidate | ||
| } | ||
|
|
||
| def prepareHybridScanCandidateSelection( |
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.
Not related to this PR, but we need to think about refactoring RuleUtils.scala. This is already two levels deep (getCandidateIndexes -> isHybridScanCandidate -> prepareHybridScanCandidateSelection).
src/main/scala/com/microsoft/hyperspace/index/rules/RuleUtils.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/rules/RuleUtils.scala
Outdated
Show resolved
Hide resolved
Btw, this comment was regarding the PR description. |
imback82
left a comment
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.
LGTM (few minor comments), thanks @sezruby!
src/main/scala/com/microsoft/hyperspace/index/IndexLogEntry.scala
Outdated
Show resolved
Hide resolved
src/main/scala/com/microsoft/hyperspace/index/rules/RuleUtils.scala
Outdated
Show resolved
Hide resolved
src/test/scala/com/microsoft/hyperspace/index/rules/RuleUtilsTest.scala
Outdated
Show resolved
Hide resolved
|
@sezruby Can you update the PR description? It is now out of sync with code. Thanks! |
What is the context for this pull request?
What changes were proposed in this pull request?
Introduce new tags to avoid duplicate operation while applying rules.
SIGNATURE_MATCHEDtag keeps the result ofdef signatureValidfor each relation & indexes, and reuse if exists. Since there's no config to affect the result, it can be reused without any check.IS_HYBRIDSCAN_CANDIDATE' tag keeps the result ofdef isHybridScanCandidate` for each relation & indexes. If some hybrid scan related configs are changed, the result can be changed. So before using this tag, reset the tag values if related configs are changed.HYBRIDSCAN_RELATED_CONFIGSkeeps the related config values.Test results
Test data
Test scripts
Result w/o this change:
Result with this change
Does this PR introduce any user-facing change?
No, it's an internal optimization.
How was this patch tested?
existing tests will cover these changes.