Skip to content

p6-f4: asset lookups are linear scans — measure them against a project with hundreds of imported assets #510

Description

@JArmandoAnaya

Split out of #322 (p6-s8).

Observation

Both asset lookups are linear scans with a string compare per entry, and both are
now on paths a user can grow without limit:

  • props::model(std::string_view) — scans the model table
    (core/src/assets/prop_meshes.gen.cpp:882-890, and after p6-s8 the project
    overlay ahead of it in core/src/assets/prop_registry.cpp). Called per
    object, per mesh build
    from core/src/mesh/mesh_builder.cpp:651, and again
    per batch from editor/src/render/scene_builder.cpp:228-253 — which carries
    its own note that a linear scan is fine for "~14 bundled models".
  • MaterialCatalog::find_material — scans the definition vector, after stripping
    one of three accepted prefixes (editor/src/render/material_catalog.cpp:79-92).

With 26 bundled props and 5 bundled materials this is not worth a hash map. With
a project that has imported a few hundred assets, build_object_instances over
an OSM district becomes O(objects × models) in string compares.

Why this is deliberately not urgent

Nothing here is known to be slow. This issue exists so the trade-off is
recorded rather than rediscovered, and it should be closed by a measurement even
if the measurement says "no change needed".

p7-s4 taught the governing lesson the expensive way: the OSM import's
super-linear build cost (#502)
was found by a scale bench, not by reading the code, and the fix is still gated
on profiling first. Apply the same order here.

Scope

  1. Measure first. Extend an existing scale harness with a project carrying
    ~500 imported prop models and ~100 materials, and report where the time goes.
  2. Only if the scans are material: an id → index map behind both lookups, rebuilt
    when the project overlay is replaced. Neither public signature changes —
    props::model() returns the same pointer with the same lifetime, and
    find_material keeps accepting all three spellings.
  3. If the scans are not material, close this with the numbers in a comment.
    That is a successful outcome, not a wasted issue.

Activity

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

    enhancementNew feature or requestpillar:P6Road to Parity pillar P6

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions