perf(render): tessellate a GPU scene's layers on several threads
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- backend, performance
Research direction
Start by reading the GPU branch in crates/render/src/lib.rs, then inspect mesh::collect_layer in crates/render/src/mesh.rs and the threaded mesh building in tile_mesh.rs. Check AGENTS.md for the threading guidance and use the vector_layers_bench command in the issue to establish the GPU baseline. Done means the one-thread and multi-thread scenes match, the vertex-room fallback matches, and the GPU benchmark sequences improve.
Written by the indexing model from the issue text.
Description
With the GPU backend on (the status bar's CPU/GPU switch, or RUSTGIS_GPU), each full redraw tessellates every layer's geometry into meshes on one thread. Zoomed out, that makes a GPU redraw slower than drawing the frame on the CPU.
Measured
vector_layers_bench (#2525, with BENCH_BACKEND=gpu, #2539) on swisstopo's swiss-map-vector25, one map sheet (66 layers, 335,000 features, 3.0 million vertices). This is the CPU side of a GPU frame (the scene render_backend(.., Backend::Gpu) builds), not the device's upload and draw. Median frame, one build, CPU backend drawing in bands on 16 threads:
| Sequence | CPU 1× | GPU 1× | CPU 2× | GPU 2× |
|---|---|---|---|---|
| whole sheet | 336 ms | 322 ms | 828 ms | 613 ms |
| zoom | 166 ms | 250 ms | 293 ms | 278 ms |
| pan 10 m | 120 ms | 211 ms | 293 ms | 283 ms |
| pan 3 m | 54 ms | 38 ms | 158 ms | 49 ms |
The GPU wins zoomed in and at 2×: its cost doesn't grow with the pixels. Zoomed out at 1× it is up to 75% slower. A zoomed-out scene holds 3.2–4.9 million vertices (about 130–195 MB at 40 bytes a vertex).
While the map moves, the app moves the last scene's meshes without building anything (the camera fast path). These numbers are the redraw when it stops, or when the view leaves the meshes' reach.
Where
render_frame's GPU branch (crates/render/src/lib.rs, mesh::collect_layer for each layer) and crates/render/src/mesh.rs. Each layer's tessellation is independent of the others. Vector tiles already build their meshes on several threads (tile_mesh.rs).
Proposal
Tessellate the layers, or a big layer's features in chunks, on rustgis_data::threads::max() threads (AGENTS.md "Use the threads"):
- the same scene as one thread, command for command, in layer order;
- the layer's vertex room (
MAX_LAYER_VERTICES) decided as one thread decides it; - one thread below a size threshold and in the browser;
- scratch within
memory::thread_scratch; - a thread the system refuses costs speed only.
The CPU parts of the scene (layers drawn as pictures) stay where they are in the order.
Keeping a layer's meshes between redraws is #1057's step 2.4, and goes with it.
Tests
- A scene built on 1 and several threads is the same.
- A layer over its vertex room falls back as on one thread.
- The benchmark's GPU sequences before and after.
Related
- The benchmark's GPU option is merged (#2539):
BENCH_BACKEND=gpu cargo run --release -p rustgis-render --example vector_layers_bench -- map.gpkg. - #2540's second step decides before tessellating whether a layer is worth a mesh (features in view and their size on screen) instead of after
MAX_LAYER_VERTICESis reached. That takes the biggest zoomed-out layers out of tessellation altogether, so it comes before this and changes what is left to split; measure again after it. - Keeping a layer's meshes between redraws is #1057's step 2.4 (measurements posted there).
- Dominant language
- Rust
- Stars
- 1.9k
- Forks
- 268
- Avg merge
- 11h 1m
- Merged PRs (30d)
- 942
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from opengeos/RustGIS
-
[Bug]: layer.move to the place a layer already has fails and stops a script; with several layers it leaves an empty undo stepPossibly taken @jgregoriorincon claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
opengeos/RustGIS#2621 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
opengeos/RustGIS#1446 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
Maintainers usually reply within 1 day
All issues in opengeos/RustGIS
Similar issues
-
postgresql-rules / queue-rules: implicit KEY SHARE before a parent key update, and job self-overlapOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jonathanong/no-mistakes#3879 ·
Maintainers usually reply within 1 day
-
area:index v0.35.0
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
nautechsystems/nautilus_trader#5741 ·
Maintainers usually reply within 1 day
-
RunPlugin derives Hash over all fields while PartialEq compares only location and configurationOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
zellij-org/zellij#5969 ·
Maintainers usually reply within 1 day
-
eth_get_proof reports another account's fields for an absent accountPossibly taken @Indian-boult claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day