From 92c78ac2ebde490c40d2cda336d5d8e57865cd15 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Wed, 23 Jan 2019 15:00:31 +0100 Subject: [PATCH] multiple cores --- server/initialrenderer/job.go | 37 +++++++++++++++++++--------- server/mapobjectdb/sqlite_migrate.go | 2 +- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/server/initialrenderer/job.go b/server/initialrenderer/job.go index 084cb4d..06dcb57 100644 --- a/server/initialrenderer/job.go +++ b/server/initialrenderer/job.go @@ -5,7 +5,7 @@ import ( "mapserver/coords" "strconv" "time" - + "runtime" "github.com/sirupsen/logrus" ) @@ -13,21 +13,39 @@ func getTileKey(tc *coords.TileCoords) string { return strconv.Itoa(tc.X) + "/" + strconv.Itoa(tc.Y) + "/" + strconv.Itoa(tc.Zoom) } -func Job(ctx *app.App) { +func worker(ctx *app.App, coords <-chan *coords.TileCoords){ + for tc := range coords { + ctx.Objectdb.RemoveTile(tc) + _, err := ctx.Tilerenderer.Render(tc, 2) + if err != nil { + panic(err) + } + } +} - fields := logrus.Fields{} - logrus.WithFields(fields).Info("Starting initial rendering") - tilecount := 0 +func Job(ctx *app.App) { totalLegacyCount, err := ctx.Blockdb.CountLegacyBlocks() if err != nil { panic(err) } - rstate := ctx.Config.RenderState + fields := logrus.Fields{ + "jobs": runtime.NumCPU(), + "totalLegacyCount": totalLegacyCount, + } + logrus.WithFields(fields).Info("Starting initial rendering") + tilecount := 0 + rstate := ctx.Config.RenderState lastcoords := coords.NewMapBlockCoords(rstate.LastX, rstate.LastY, rstate.LastZ) + jobs := make(chan *coords.TileCoords, 10) + + for i:=0; i