Map: draw the ground off the keystroke, and stop reprojecting the world
A pan cost 0.9-2.4 s. It was never the tiles - those already load in a thread - it was render_map, which rasterizes the vector ground on the paint path: 900-2342 ms for a view holding ~16k features. Two changes, in that order. The projection was doing the same trigonometry once per vertex. Every feature_to_dot call recomputed Viewport.origin_world - a sin/log pair - and a 2** for values constant across the whole frame, 107k times a frame. The mapping is affine in tile-local coordinates, so tile_transform folds it into three numbers and _draw_tile spells the arithmetic out inline: two multiplies and two adds per vertex, no call at all. That alone is 2.4x (z12 2342 -> 991 ms). The rest is genuinely per-feature Python and will not shrink to keystroke size, so the raster moved off the paint path. A paint now returns the best picture available immediately and a background task draws the real one: unchanged view serves the finished frame; a view that only gained a tile keeps the old raster, which is still correctly aligned; a view that *moved* draws the nodes alone on the new viewport, which is a few ms, so panning tracks the keys and the streets catch up. The title says "drawing..." while it does. Exactly one raster runs at a time and it is always the newest requested - a held arrow hands us a new viewport every repaint, and starting a second of thread-bound work per keypress would queue frames that are already stale on arrival and slow the keystrokes this exists to protect. On the device: pan 1205 -> 89 ms, 1156 -> 130 ms, 2449 -> 91 ms; zoom 1161 -> 142 ms; a settled view 37 ms. Also flips MESHTERM_FASTRENDER on by default (=0 still opts out), and asks whether a loop is running *before* building a coroutine, so a static render no longer leaves an un-awaited one behind. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
57386fe879
commit
e53e35523e
6 files changed
+270
-17
No files matched your search
@@ -283,14 +283,14 @@ def _fast_renderer(frames: list[str]) -> tuple["FastRenderer", _CapturingOutput]
|
||||
return renderer, out
|
||||
|
||||
|
||||
def test_fastrender_is_off_unless_asked_for(monkeypatch) -> None: # noqa: ANN001
|
||||
"""The bypass is opt-in: an unset environment leaves prompt_toolkit in charge."""
|
||||
def test_fastrender_is_on_with_an_escape_hatch(monkeypatch) -> None: # noqa: ANN001
|
||||
"""The row writer is the default paint; only an explicit 0 hands it back to pt."""
|
||||
from meshterm.ui.tui import fastrender
|
||||
|
||||
monkeypatch.delenv("MESHTERM_FASTRENDER", raising=False)
|
||||
assert not fastrender.enabled()
|
||||
monkeypatch.setenv("MESHTERM_FASTRENDER", "1")
|
||||
assert fastrender.enabled()
|
||||
monkeypatch.setenv("MESHTERM_FASTRENDER", "0")
|
||||
assert not fastrender.enabled()
|
||||
|
||||
|
||||
def test_fastrender_rewrites_only_the_rows_that_changed() -> None:
|
||||
|
||||
Reference in new issue
Block a user