Claude 6c2bd6d27b Serve tiles with Caddy; fix serve.py falling back to HTTP/1.0
serve.py inherited SimpleHTTPRequestHandler's HTTP/1.0 default, which
closes the socket after every response. A map view pulls ~30 tiles, so
that was ~30 TCP handshakes per pan. Setting HTTP/1.1 more than doubled
loopback throughput on its own.

That still leaves thread-per-connection behind the GIL. Measured over 480
tile requests on reused connections:

  conc  8   serve.py 2,622 req/s p95 4.0ms  |  caddy 6,987 req/s p95 1.9ms
  conc 32   serve.py   462 req/s max 1013ms |  caddy 5,877 req/s max  21ms

serve.py does not merely slow down under load, its throughput falls and
tail latency crosses a second. Caddy stays flat, so it is now the default.

run.ps1 picks Caddy when server/caddy.exe is present and falls back to
serve.py, so a fresh clone still works with nothing installed.
get-caddy.ps1 fetches the binary; it is gitignored.

HTTP/2 is not active: browsers only negotiate h2 over TLS, and trusting a
local CA on every phone is not worth it on a LAN. The gain is Go's I/O.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-08 02:20:39 -07:00

TarkovMap

Self-hosted, mobile-friendly Escape from Tarkov map viewer. Layered PSDs go in, a Leaflet tile pyramid comes out, and every map — related or not — sits side by side on one shared canvas you can pan across.

Only the base map art is extracted. Markers, spawns, legends, captions and titles are dropped during the render.

Quickstart

python -m pip install -r tools/requirements.txt
python tools/build.py
pwsh server/get-caddy.ps1
pwsh server/run.ps1

Open the printed URL. The LAN address works from a phone on the same network.

run.ps1 uses Caddy when server/caddy.exe is present and falls back to serve.py otherwise, so the first step is optional — see Serving.

Source PSDs are not in the repo (see .gitignore) — get them from the shared drive and put them under sources/.

Adding a map

See docs/adding-a-map.md. Short version: run tools/psd_tree.py to find the group holding the art, add an entry to maps.json, run tools/build.py. No application code changes.

Layout

maps.json          the only thing you edit to add or change a map
tools/
  psd_tree.py      inspect a PSD's layer tree
  export_base.py   PSD -> build/<id>/base.png   (base group only)
  tile.py          base.png -> web/tiles/<id>/{z}/{x}/{y}.webp
  build.py         orchestrator; also writes web/data/world.json
  preview.py       stitch built tiles into one overview image
  common.py        config loading + the world-grid maths
server/serve.py    dependency-free static server with sane cache headers
web/               the site: index.html, app.js, style.css, vendored Leaflet
sources/           gitignored — source PSDs
build/             gitignored — intermediate PNGs
web/tiles/         gitignored — generated tiles

How the shared canvas works

Maps are placed on a grid of 8192 × 8192 px cells (tileSize · 2^maxZoom). At that cell size, a map's tile indices shift into world coordinates by exactly cell · 2^z at every zoom — always an integer. So each map keeps its own locally numbered pyramid, the browser translates on the fly, and adding a map never re-tiles the others.

A map must fit in one cell. Raising maxZoom in maps.json doubles the cell.

No black gaps

Each map is drawn twice. Underneath sits a backdrop layer pinned to underlayZoom (default 2) — Leaflet serves that one level at every view zoom, scaled to fit. The whole world at z2 is 17 tiles / 134 KB, so it lands almost immediately and then stays resident, and detail tiles draw over it.

Any gap while detail tiles load shows blurry map instead of the page background. Raising underlayZoom sharpens the backdrop but costs a lot more up front (z3 is 49 tiles / 471 KB) — z2 is the sweet spot.

Current maps

Map Source size Tiled Tiles
Customs 7832 × 5016 7832 × 3015 503 (8.4 MB)
Customs — Dorms 4301 × 4904 4301 × 4904 469 (1.4 MB)

Serving

Two options, both driven by server/run.ps1:

serve.py Caddy
Dependencies none (stdlib) one 47 MB binary
conc 8 2,622 req/s · p95 4.0 ms 6,987 req/s · p95 1.9 ms
conc 32 462 req/s · max 1,013 ms 5,877 req/s · max 21 ms
ETags / compression no yes (zstd, gzip)

Measured on loopback, 480 tile requests over reused connections.

The number that matters is the second row. serve.py is thread-per-connection behind the GIL, so under load it doesn't just slow down — throughput falls and tail latency goes past a second. Caddy stays flat. Use Caddy for anything real; serve.py exists so a fresh clone works with nothing installed.

serve.py was also defaulting to HTTP/1.0, which closes the socket after every response — one TCP handshake per tile, ~30 per map view. It now sets HTTP/1.1, which is most of its improvement above.

Neither runs HTTP/2: browsers only negotiate h2 over TLS, and putting a trusted cert on every phone isn't worth it on a LAN. The Caddy win is Go's I/O, not h2.

To reach it from a phone, allow the port once (elevated):

netsh advfirewall firewall add rule name="TarkovMap 8080" dir=in action=allow protocol=TCP localport=8080

Licence

Map art is by re3mr.com under CC BY-NC-SA 4.0. Attribution is shown in the viewer and must stay there. Use is non-commercial, and derivative map images inherit the same licence. Local and LAN hosting is fine; get sign-off before hosting publicly.

S
Description
A interactive map for Escape from Tarkov
https://map.luci.ooo
Readme
8.1 GiB
0 Stars 1 Watchers 0 Forks
Languages
Python 59.2%
JavaScript 32.8%
CSS 5.7%
HTML 1.2%
PowerShell 1.1%