From af1e8142bc72794660fbce34f8592a335ad92475 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Thu, 17 Jan 2019 16:09:11 +0100 Subject: [PATCH] more perf --- initialrenderer/renderer.go | 4 ++++ tilerenderer/renderer.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/initialrenderer/renderer.go b/initialrenderer/renderer.go index 2987835..d2f425c 100644 --- a/initialrenderer/renderer.go +++ b/initialrenderer/renderer.go @@ -21,6 +21,7 @@ func Render(tr *tilerenderer.TileRenderer, start := time.Now() complete_count := 512*512 current_count := 0 + perf_count := 0 jobs := make(chan coords.TileCoords, 100) @@ -37,6 +38,7 @@ func Render(tr *tilerenderer.TileRenderer, tc := coords.NewTileCoords(x,y,10,layer.Id) jobs <- tc current_count++ + perf_count++ if time.Now().Sub(start).Seconds() > 2 { start = time.Now() @@ -47,8 +49,10 @@ func Render(tr *tilerenderer.TileRenderer, "y": y, "progress%": progress, "layer": layer.Name, + "perf": perf_count, } + perf_count = 0 logrus.WithFields(fields).Info("Initial render progress") } } diff --git a/tilerenderer/renderer.go b/tilerenderer/renderer.go index d01623d..8f28c49 100644 --- a/tilerenderer/renderer.go +++ b/tilerenderer/renderer.go @@ -196,6 +196,13 @@ func (tr *TileRenderer) RenderImage(tc coords.TileCoords) (*image.NRGBA, error) png.Encode(buf, img) } + isEmpty := upperLeft == nil && upperRight == nil && lowerLeft == nil && lowerRight == nil + + if isEmpty && (tc.Zoom == 12 || tc.Zoom == 11 || tc.Zoom == 10) { + //don't cache empty zoomed tiles + return nil, nil + } + tile := tiledb.Tile{Pos: tc, Data: buf.Bytes(), Mtime: time.Now().Unix()} tr.tdb.SetTile(&tile)