Skip to content

Routing bake 2/4: roads as flat columns #3239

Closed

Description

@timohueser

Status: done

Part of #3228. Depends on #3238. The words of #3228 apply.

TL;DR

Goal: The road graph of the bake is a set of flat columns. A road then needs no heap objects of its own, and #3241 can move the roads into files.
Problem: Graph.roads is a Vec<model::Road>: 64 B per road, plus one heap shape per road at 12 B per point, and freed import objects fragment the heap around these shapes.
Decision: Graph.roads becomes Roads: one column per field of model::Road and one list of shape points per road. The cost code keeps taking &Road: Roads::get fills a reused Road.
Rejected: one shape for both directions of a road. It needs more API, for little gain once the tables live on disk.
Systems: routing
Contracts: none
Size: M (one system, about 500 changed lines)

Plan

  1. lib.rs: Graph.roads becomes Roads, with a Column for each field of model::Road and Lists<Point> for the shapes. Roads::push(Road) appends a road. Roads::get(i, &mut Road) fills a reused road. Roads::len() counts them. Accessors (from, to, way) serve the loops that read one field.
  2. The code that indexes graph.roads reads through Roads: lib.rs (prepare), base.rs (edges), cost.rs, landmarks.rs, connectivity.rs, layout.rs, terrain.rs, and osm.rs (emit_run, the turn restrictions).
  3. prepare writes each geometry page from up to ROADS_PER_PAGE roads that it reads into one reused Vec<Road>. geometry::encode does not change.
  4. layout::spatial_order sorts a permutation, then writes new columns in that order. It no longer swaps road structs.
  5. terrain::apply writes the heights into the shape list and the climb into its columns.
  6. The tests that build a Graph push their roads: tests/routing.rs, planner/service/tests/http.rs and the unit tests.

Done when

  • obc test -p planner-router-build, obc test -p planner-service and clippy on both crates pass.
  • A Switzerland bake gives the same manifest ID as before.
  • The pull request records the live memory after the Switzerland import, before and after.

Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions