#18964 closed enhancement (fixed)
[Patch] MapCSS rules using index are slow
Reported by: | GerdP | Owned by: | team |
---|---|---|---|
Priority: | minor | Milestone: | 20.03 |
Component: | Core validator | Version: | |
Keywords: | validator mapcss performance | Cc: |
Description
For the validator we have several rules like this:
way >[index=1] node, way >[index=-1] node { set first_last_node; }
The current implementation for the index test works like this:
Perform a sequential search for the given node in the parent way. If found, compare the position with the value given with index.
I think it should work the other way around: Check if the node at the given position exists and if so compare it with the given node.
Attachments (1)
Change History (6)
comment:1 by , 5 years ago
Priority: | normal → minor |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
by , 5 years ago
Attachment: | 18964.patch added |
---|
comment:2 by , 5 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
Summary: | MapCSS rules using index are slow → [Patch] MapCSS rules using index are slow |
The attached patch improves performance drastically for the mentioned special cases, saw no changes with average data.
is it worth the additional code?
comment:3 by , 5 years ago
I'd say yes. Just make the firstAndLastOnly a private method so that the calling code simplifies to:
private boolean firstAndLastOnly() { for (Condition c : link.conds) { if (!(c instanceof IndexCondition) || !((IndexCondition) c).isFirstOrLast) { return false; } } return true; } /// ... int step = firstAndLastOnly() ? count - 1 : 1;
comment:5 by , 5 years ago
Milestone: | → 20.03 |
---|
Probably not a problem with real OSM data. I've noticed this with a generated file containing coastline data for Great Britain. The data has several ways with 64000 nodes. Only with this extreme case the sequential search is a problem.
For normal data the additional checks to avoid this search are even more complex.