-
Notifications
You must be signed in to change notification settings - Fork 820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render unpaved roads different #3357
Conversation
@rrzefox Could you test this branch on your server giving some feedback about performance on different zoom levels, compared to the current master? |
I have tried to simply render a 2048x1024 tile with nik4.py on zoomlevels 8 to 12. The server has a full planet DB. The results are not good. Each test was run 3 times, once for warmup, and the following table gives the best of the other 2 results:
Under these circumstances, I really do not want to deploy this into the live rendering ;) benchmark outputunpatched run 2: real 0m20.997s real 0m34.405s real 0m54.297s real 0m29.649s real 1m21.594s unpatched run 3: real 0m15.126s real 0m24.917s real 0m53.036s real 0m31.206s real 1m23.309s patched run 2: real 0m35.593s real 1m11.907s real 3m11.256s real 0m43.480s real 2m1.607s patched run 3: real 0m35.349s real 1m10.434s real 3m7.632s real 0m43.129s real 1m59.042s |
Based on a few quick tests without a global database it seems that even without the global bounding box geometries and the comp-op stuff the restructured MSS code is significantly slower than before. The SQL code seems to be fine now OTOH. It has been some time since i looked over this so forgive me if this is stupid but can't you sort the global bounding box (in several instances, one for each road color) into the SQL defined drawing order and this way get rid of the attachments in the MSS code (and this way keep the MSS structure essentially as it is now - just adding the comp-op stuff)? |
@rrzefox Thanks for sharing these numbers. Could you add some information about your hardware please? |
@rrzefox Thanks a lot for testing this!
That’s what I suspected earlier (see the last point of my previous comment).
I fear that I can’t. The reason is the behaviour of
|
That is unfortunate. But what you describe to me kind of contradicts the mapnik docs because what you do is what in https://github.com/mapnik/mapnik/wiki/Compositing is described as Feature level compositing which should work on a per feature basis and not involve the creation of temporary canvas (which is described below as Style level compositing). The lack of reliable documentation of how mapnik works really hampers developing a solution to this kind of problem. |
Well, maybe you could just ask Mapnik developers then - @talaj, would you have any advise here? |
Adding That's a heck of an unexpected default setting. |
It looks like upstream (Mapnik) implementation of roads with pattern rendering is at least doable - mapnik/mapnik#3977 (comment). That would be really great... |
Even better - it's a real work in progress! See mapnik/mapnik#3980. |
Rebased. I’ve implemented the performance tuning that @talaj had proposed.
That didn’t work. I eventually used Now, on my local machine (based in single tile rendering once per zoom level), the branch |
Strange - because for me it did work. It would also make sense by the way to check if other layers would profit from this as well. Roads is the most obvious candidate but it is not the only place attachments are used. |
Indeed I was thinking about that, but I wanted to wait for the results of @rrzefox before. In general, I suppose that this option is without any negative consequences on layers that do not use attachments. If so, I could imagine add this in general to all SQL layers, regardless of their current usage. This way, we do not need to worry about. (I’m not sure about non-SQL layers however…) |
Please remember to look also at memory consumption - this was a big problem that made this option to be turned off by default, see mapnik/mapnik#657. Do you think this PR still makes sense when there's a Mapnik feature for rendering line patterns being implemented (mapnik/mapnik#3980)? |
OK, so I reran the simple benchmarks, and they indeed do look a LOT better now:
In other words, the performance impact is now zero (within margin of error). As for the memory usage, the maximum memory usage was 1529592 KB for the Z08 tile. The same tile without this PR used 1424076 KB, so it's +7%. That is only the memory used by mapnik, no idea how much the corresponding database process used. I also tried the 'evil' Z10 tile mentioned in the linked mapnik-bugreport. The memory usage for that one increases from 872468 to 1007784 KB (+16%). Fun fact: with the old revision of this PR this actually used 4056448 KB! I have now deployed this PR, |
Thanks a lot @rrzefox for testing this! It’s really great to see this live on a map! A possible support in Mapnik for direct polygon pattern rendering on lines might come in the future, but it will take a very long time until being available (Mapnik code is currently just a proposal, Mapnik release, than Cartocss release with the necessary changes considering this new symbolizer, Ubuntu packaging, new Ubuntu long term release and the first following maintance release might be maybe 20.4.1?) A lot of conditions… I would like therefore love to see this PR in openstreetmap-carto in the meantime. |
I see. How hard do you think it will be to switch to the Mapnik support with this code? If this is possible to make smooth migration once it's available, I would have no problem merging it. Depending on circumstances making Mapnik implementation available on OSMF servers might take few weeks or months probably (it's just my rough estimation). It took almost a year with fixing label placement bug on production, but there were more problems along the way. |
Quite easy.
We would still use the same SVG files for the pattern. After that, the code structure will be less complex. The first step will reduce the lines of code. The second one will raise them again. It is more verbose, but less complex and more straightforward. All in all, I think will will end up with roughly the same amount of code. |
OK, it sounds reasonable for me! Do you think we should merge it now or wait until v4.15.0 is out? Personally I would not wait, since the code will rather not get any more testing than it already did. |
I’m fine with merging it now. |
The merge will likely make a lot of work again, as like last time almost all of roads.mss has been changed. |
I have tested it roughly and it works OK, so I give 👍 for merging. |
I now have some numbers to support my gut feeling that "rerendering seemed to take longer than usual" mentioned above:
2018-08-28, -29 and -30 were before this PR was deployed, the other two were after it was deployed (in the version from Sept. 03). |
If such a difference is directly due to style code changes it should be measurable in a single tile test render as well. If that is the case it would also be possible to determine what the cause of the difference is which is essential to determine if something can be done about it. |
Do you think Mapnik implementation might not have this problem? ~2x slower rendering will be noticeable. |
I don’t know. I would guess that we have maybe three factors that influence rendering performance here:
Number 1 and number 3 would be eliminated when using a native Mapnik implementation. Number 2 will obviously still be present also with a native Mapnik implementation (but when number 1 is eliminated, this will maybe reduce the number of SVG geometries and therefore will make that number 2 has less impact.) Obviously I’m not sure about all this because currently there is no Mapnik release that implements this, so I have no way to test it. |
@rrzefox Do you have an idea what could be the reason for this performance decrease? In the previous performance test (“simple benchmarks”) you got roughly the same performance. Was this on a per-tile base? What could cause the “big” test for 24 hours give different results from the “small” test for a few tiles? |
I do not have an idea what exactly causes the performance decrease except the obvious (drawing more and querying the DB more means it'll get slower). The 'simple benchmarks' were just that, more of a first sanity check than a proper benchmark - I rendered a few tiles to see if there was an extreme performance hit, like there was in the first attempt of this PR. Notice however that those were on Z8 - Z12 and on tiles that would already take "bloody ages" to render. "it takes on average 1 second more to render" isn't really visible on tiles that render for two minutes - but it is on high-zoom tiles that only take 1-3 seconds. |
Rendering a line with
No, native Mapnik implementation will perform similarly to solid line rendering. |
@talaj Thanks for commenting here!
When there would be a The reason for asking this is that currently, the SQL code generates a global bounding box for each road type – always, independent of if this particular road type really occurs in this particular tile. This could be optimized maybe…
What could be an approximative time frame for a Mapnik release that ships this implementation? @imagico Better revert this PR for the moment? |
The
I can finish the feature let's say in two weeks, but what will continue is hard to guess. |
@sommerluk You can also ask OSMF admins, since this is our primary deployment target. |
@tomhughes Suppose that what @rrzefox measured would be bad for OSMF servers? |
Well is that CPU time in mapnik? or is a it a real time delay caused by waiting for I/O? or some combination? |
It's not CPU time, it's time from "tirex starts to render the tile" to "tirex finished rendering the tile". Where that time is really lost I cannot tell, probably a combination of "more waiting for the DB to reply due to more queries" and "more CPU usage". |
Well CPU time in postges is still CPU time ;-) My thought was mostly that the production servers will probably handle increased I/O better than increased CPU but even that is only really a guess. |
Do you think it can be deployed? |
Fixes #110 using the idea from #2640 while trying to avoid re-introducing #3280