mapbox/tilemill — Issue #798: optimize handling of expensive layer initialization
Author: springmeyer
Created: 2011-10-17 22:26:56+00:00
State: open

A common scenario in TileMill with postgis is very slow layer creation. The user is trying to visualize a table for the first time that contains millions of records. Mapnik expects the extent to be passed as an option to avoid the costly lookup of calling `ST_Extent` on the table, but this does not happen.

The impact of this (or any scenario where a layer takes a long time to create) is that when the Layer UI is saved the layer is created once, then when the css style is saved, it is created again, and when rendering starts and load increases, the pool of maps is increased by tilelive and the layer is created again (up to 5 times I think which is the max pools size in tilelive-mapnik).

Ideally the layer could be created once and its instance passed to tilelive-mapnik, but this is currently not feasible because all layer initialization is done through XML. (so tilelive-mapnik would need a way to just load the mss, and directly pass the layer instance to node-mapnik rather than re-reading the mml layer json).

And ideally new maps that are loaded could be cloned (rather than reloaded from XML) in an intelligent way such that layer instances would be unique (for proper parallel rendering that is thread safe), but expensive intialization steps could be skipped (this would be an upstream mapnik issue).