Skip to content

Commit 4cbebff

Browse files
committed
Update tile57 to main: the ownership partition is the engine's, not ours
tile57's compose ABI now finds/reuses/rebuilds the ownership partition beside the archives itself (compose_open/compose_tree dropped partition_path; compose_save_partition is gone). Drop all the host-side sidecar plumbing: NewComposer no longer takes a partitionPath, Composer.SavePartition and livePartitionPath are deleted, bake.go stops writing partition.tpart, and openLiveComposer just opens — no load, no save. Fixes the StalePartition dance that forced a blocking owned-face rebuild at boot on an engine bump. Bumps the tile57 submodule to origin/main (2c36da6, PR #31 label-cache).
1 parent 3dae5df commit 4cbebff

5 files changed

Lines changed: 19 additions & 41 deletions

File tree

cmd/chartplotter/bake.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,16 @@ func (c bakeCmd) Run() error {
7979
return fmt.Errorf("no coverage: no valid S-57 cells under %s", input)
8080
}
8181

82-
// Build + save the ownership-partition sidecar next to the tiles (the compositor loads it on
83-
// open to skip the build).
84-
comp, err := tilesource.NewComposer(paths, "")
82+
// Pre-warm the ownership partition: opening a compositor over the freshly baked cells
83+
// builds it and persists it beside the archives, so the runtime open doesn't pay the
84+
// owned-face build. (The engine owns the sidecar now — nothing to save by hand.)
85+
comp, err := tilesource.NewComposer(paths)
8586
if err != nil {
8687
return err
8788
}
8889
defer comp.Close()
89-
if err := comp.SavePartition(filepath.Join(outDir, "partition.tpart")); err != nil {
90-
return err
91-
}
9290
m := comp.Meta()
93-
fmt.Printf("baked %d cell(s) → %s/tiles/*.pmtiles + partition.tpart (z%d..%d, bounds %.4f,%.4f,%.4f,%.4f)\n",
91+
fmt.Printf("baked %d cell(s) → %s/tiles/*.pmtiles (z%d..%d, bounds %.4f,%.4f,%.4f,%.4f)\n",
9492
len(paths), outDir, m.MinZoom, m.MaxZoom, m.W, m.S, m.E, m.N)
9593
return nil
9694
}

internal/engine/server/live_compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (s *Server) registerLiveCompose() {
4747
if name == "" {
4848
name = "live"
4949
}
50-
src, err := tilesource.NewComposer(paths, os.Getenv("TILE57_LIVE_PARTITION"))
50+
src, err := tilesource.NewComposer(paths)
5151
if err != nil {
5252
log.Printf("live-compose: open %s failed: %v", dir, err)
5353
return

internal/engine/server/live_provider.go

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@ import (
1818
)
1919

2020
// liveCellsDir is <setDir>/tiles — the KEPT per-cell PMTiles the runtime compositor mmaps.
21-
// This is the same layout `tile57 bake -o <dir>` writes (<dir>/tiles/<STEM>.pmtiles next to
22-
// <dir>/partition.tpart), so a CLI-baked structure drops straight into a provider's set dir.
21+
// This is the same layout `tile57 bake -o <dir>` writes (<dir>/tiles/<STEM>.pmtiles), so a
22+
// CLI-baked structure drops straight into a provider's set dir. The engine keeps its own
23+
// ownership-partition sidecar beside these archives; the host neither writes nor reads it.
2324
func (s *Server) liveCellsDir(provider string) string {
2425
return filepath.Join(s.setDir(provider), "tiles")
2526
}
2627

27-
// livePartitionPath is <setDir>/partition.tpart — the saved ownership-partition sidecar.
28-
func (s *Server) livePartitionPath(provider string) string {
29-
return filepath.Join(s.setDir(provider), "partition.tpart")
30-
}
31-
3228
// liveGenPath is <setDir>/live.gen — it holds the provider's CONTENT cache-bust token (a
3329
// decimal of the sha-of-shas over its per-cell archives; see liveGenToken), which packGen reads
3430
// and stamps into tile URLs as ?g. It changes exactly when the cell set or any cell's content
@@ -125,23 +121,10 @@ func (s *Server) openLiveComposer(provider string) (*tilesource.Composer, error)
125121
if len(paths) == 0 {
126122
return nil, nil
127123
}
128-
sidecar := s.livePartitionPath(provider)
129-
load := ""
130-
if fi, err := os.Stat(sidecar); err == nil && fi.Size() > 0 {
131-
load = sidecar
132-
}
133-
c, err := tilesource.NewComposer(paths, load)
134-
if err != nil {
135-
return nil, err
136-
}
137-
// Persist the (possibly rebuilt) partition so the on-disk sidecar always matches the current
138-
// cell set: a progressive re-key or an added/removed district changes the inputs, the
139-
// compositor rebuilds from a stale sidecar, and saving keeps the sidecar current for a fast
140-
// boot. (When the sidecar was loaded intact this re-writes identical bytes.)
141-
if err := c.SavePartition(sidecar); err != nil {
142-
log.Printf("live %s: save partition sidecar: %v", provider, err)
143-
}
144-
return c, nil
124+
// The engine owns the ownership partition now: NewComposer finds it beside the archives,
125+
// reuses it when it still matches the cell set, and rebuilds + refreshes it on disk when it
126+
// does not. Nothing to load or save here.
127+
return tilesource.NewComposer(paths)
145128
}
146129

147130
// progressiveReKey re-opens the live compositor over the cells baked SO FAR, registers it as the

internal/engine/tilesource/composer.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ type Composer struct {
1515
}
1616

1717
// NewComposer opens a runtime compositor over the per-cell PMTiles at paths (each from
18-
// `tile57 compose --keep-cells` / tile57.BakeChart). partitionPath (or "") names a partition
19-
// sidecar (`tile57 compose --save-partition`) to load and skip the owned-face build. Close it
18+
// `tile57 compose --keep-cells` / tile57.BakeChart). The ownership partition is an internal
19+
// detail of the engine now — found beside the archives, reused when it still matches the cell
20+
// set, and rebuilt (and refreshed on disk) when it does not; nothing to pass or manage. Close it
2021
// when done — callers must not Close while any request can still call Tile.
21-
func NewComposer(paths []string, partitionPath string) (*Composer, error) {
22-
src, err := tile57.OpenCompose(paths, partitionPath)
22+
func NewComposer(paths []string) (*Composer, error) {
23+
src, err := tile57.OpenCompose(paths)
2324
if err != nil {
2425
return nil, err
2526
}
@@ -62,9 +63,5 @@ func (c *Composer) TileOwned(z uint8, x, y uint32) (body []byte, owned bool, err
6263
// Meta returns the compositor's display metadata (zoom range + coverage bounds).
6364
func (c *Composer) Meta() TileMeta { return c.meta }
6465

65-
// SavePartition persists the resident ownership partition to path, so a later NewComposer can load
66-
// it (as partitionPath) and skip the owned-face build.
67-
func (c *Composer) SavePartition(path string) error { return c.src.SavePartition(path) }
68-
6966
// Close releases the compositor (io.Closer, so tilesource.Close finds it).
7067
func (c *Composer) Close() error { return c.src.Close() }

tile57

Submodule tile57 updated 85 files

0 commit comments

Comments
 (0)