forked from MTSR/mapserver
multiple cores
This commit is contained in:
parent
fa8c21bc4b
commit
92c78ac2eb
@ -5,7 +5,7 @@ import (
|
|||||||
"mapserver/coords"
|
"mapserver/coords"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
"runtime"
|
||||||
"github.com/sirupsen/logrus"
|
"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)
|
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{}
|
func Job(ctx *app.App) {
|
||||||
logrus.WithFields(fields).Info("Starting initial rendering")
|
|
||||||
tilecount := 0
|
|
||||||
|
|
||||||
totalLegacyCount, err := ctx.Blockdb.CountLegacyBlocks()
|
totalLegacyCount, err := ctx.Blockdb.CountLegacyBlocks()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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)
|
lastcoords := coords.NewMapBlockCoords(rstate.LastX, rstate.LastY, rstate.LastZ)
|
||||||
|
|
||||||
|
jobs := make(chan *coords.TileCoords, 10)
|
||||||
|
|
||||||
|
for i:=0; i<runtime.NumCPU(); i++ {
|
||||||
|
go worker(ctx, jobs)
|
||||||
|
}
|
||||||
|
|
||||||
for true {
|
for true {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
@ -43,6 +61,7 @@ func Job(ctx *app.App) {
|
|||||||
"tiles": tilecount,
|
"tiles": tilecount,
|
||||||
}
|
}
|
||||||
logrus.WithFields(fields).Info("Initial rendering complete")
|
logrus.WithFields(fields).Info("Initial rendering complete")
|
||||||
|
close(jobs)
|
||||||
rstate.InitialRun = false
|
rstate.InitialRun = false
|
||||||
ctx.Config.Save()
|
ctx.Config.Save()
|
||||||
|
|
||||||
@ -78,11 +97,7 @@ func Job(ctx *app.App) {
|
|||||||
logrus.WithFields(fields).Debug("Dispatching tile rendering (z11-1)")
|
logrus.WithFields(fields).Debug("Dispatching tile rendering (z11-1)")
|
||||||
|
|
||||||
tilecount++
|
tilecount++
|
||||||
ctx.Objectdb.RemoveTile(tc)
|
jobs <- tc
|
||||||
_, err = ctx.Tilerenderer.Render(tc, 2)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
const migrateScript = `
|
const migrateScript = `
|
||||||
PRAGMA foreign_keys = ON;
|
PRAGMA foreign_keys = ON;
|
||||||
PRAGMA journal_mode = MEMORY;
|
-- PRAGMA journal_mode = MEMORY;
|
||||||
-- PRAGMA synchronous = OFF;
|
-- PRAGMA synchronous = OFF;
|
||||||
|
|
||||||
create table if not exists objects(
|
create table if not exists objects(
|
||||||
|
Loading…
Reference in New Issue
Block a user