#14485 closed enhancement (fixed)
[Patch] MapCSS sorting speed
Reported by: | michael2402 | Owned by: | michael2402 |
---|---|---|---|
Priority: | normal | Milestone: | 17.05 |
Component: | Core mappaint | Version: | |
Keywords: | mapcss performance | Cc: |
Description
I experimented with the sorting speed of MapCSS.
This is what I got on 8 cores for the big MapCSS performance test:
- Current implementation: 116ms
- Using parallel sort instead of default sort: 40ms
- Removing the branches for the comparator function: 53ms
- Both: 28ms
The disadvantage of the branch removal is that I changed the z-index to be a fixed-point decimal (24 bits of which 8 are behind the decimal). This allows to pack the Z-Indexes and the flags into a long that can then be compared more easily.
If there are no objections to this rescriction I'd like to commit it.
Attachments (2)
Change History (18)
by , 8 years ago
Attachment: | styled-map-renderer-precompute-order.patch added |
---|
by , 8 years ago
Attachment: | styled-map-renderer-use-parallel-sort.patch added |
---|
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Summary: | MapCSS sorting speed → [Patch] MapCSS sorting speed |
---|
comment:3 by , 8 years ago
Milestone: | 17.03 → 17.04 |
---|
comment:4 by , 8 years ago
Owner: | changed from | to
---|
comment:5 by , 8 years ago
Milestone: | 17.04 → 17.05 |
---|
comment:8 by , 8 years ago
Causes following warnings:
[javac] /var/lib/jenkins/jobs/JOSM-Integration/workspace/jdk/JDK8/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java:146: warning: [OperatorPrecedence] Use grouping parenthesis to make the operator precedence explicit [javac] long highestBitMask = 1L << totalBits - 1; [javac] ^ [javac] (see http://errorprone.info/bugpattern/OperatorPrecedence) [javac] Did you mean 'long highestBitMask = 1L << (totalBits - 1);'? [javac] /var/lib/jenkins/jobs/JOSM-Integration/workspace/jdk/JDK8/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java:149: warning: [OperatorPrecedence] Use grouping parenthesis to make the operator precedence explicit [javac] return signBit | value & valueMask;
The second seems correct and should obviously be "signBit | (value &valueMask)". Should the first really be "1L << (totalBits - 1)? Please add the correct brackets.
comment:10 by , 8 years ago
Could you please document the limitations?
Btw., it wouldn't be a problem to loose one or two bits in the exponent, e.g. S/360 floats have only 7 bits in the exponent.
comment:12 by , 7 years ago
comment:13 by , 7 years ago
Yes. We do not support 32 bit floats but only 24 bit floats.
You should not notice a much of difference unless your are using z-index values with more than 4 decimal digits - which may only happen when using complex computations.
If you encounter any issues with shorter z-indexes, there is a bug somewhere ;-)
comment:14 by , 7 years ago
So what exactly is the range that can be used? Can you please document at wiki:Help/Styles/MapCSSImplementation?
comment:15 by , 7 years ago
How exact should the documentation be? As far as I know, MapCSS has no real requirements on floating point values since there is no real spec for it.
The numeric range is approx -3.4 * 1038 ... 3.4 * 1038, with a precision of ~5 decimal digits. So having 1.0001 and 1.0002 should be fine, and having 10001 and 10002 should be fine as well ;-).
There are many other limitations on floating point values we have (e.g. numbers are not allowed to start with a '.'). I don't think we can document them all - if we would do that we could as well write a real MapCSS specification with exact grammar and so on and then state our differences.
comment:16 by , 7 years ago
I added the docu, please correct it if it is wrong:
https://josm.openstreetmap.de/wiki/Help/Styles/MapCSSImplementation?action=diff&version=144
Replying to michael2402:
So in decimal terms, the maximum z-index is 65535 and it should not have more than 2 digits after the decimal point? Sounds okay to me.