[MAGNOLIA-5900] Performance of ConfiguredInheritance.NodeDepthComparator is really slow Created: 28/Aug/14 Updated: 19/May/22 Resolved: 19/May/22 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | rendering |
| Affects Version/s: | 4.5.21 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | David Wartel | Assignee: | Unassigned |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | performance | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
| Date of First Response: |
| Description |
|
In this comparator we do a node iteration to calculate the position in the tree. Which seems to be quite slow. It seems to be used when there is inheritance involved which we use quite a lot but not to an extreme. Page generation can be up to 3 times slower because of this code. Which makes the site return 500 errors during a activation. At that time the full cache is flushed in our site because of the complexity of our dependencies. Is there no smarter, faster way to calculate the index? Copied the code that causes it. NodeDepthComparator
public int compare(Node lhs, Node rhs) {
try {
if (lhs.getDepth() != rhs.getDepth())
return lhs.getDepth() - rhs.getDepth();
return getSiblingIndex(lhs) - getSiblingIndex(rhs);
} catch (RepositoryException e) {
throw new RuntimeRepositoryException(e);
}
}
private int getSiblingIndex(Node node) throws RepositoryException {
if (node.getDepth() == 0) {
return 0;
}
int index = 0;
NodeIterator nodes = node.getParent().getNodes();
while (nodes.hasNext()) {
if (NodeUtil.isSame(node, nodes.nextNode())) {
return index;
}
index++;
}
return -1;
}
|
| Comments |
| Comment by Roman Kovařík [ 19/May/22 ] |
|
Hello, This ticket is now marked as closed due to one of the following reasons:
If you are still facing a problem or consider this issue still relevant, please feel free to re-open the ticket and we will reach out to you. Thank you, |