Skip to content

PERF: SegmentFeatures driver re-initializes the voxel worklist for every feature #1690

Description

@imikejackson

In src/simplnx/Utilities/SegmentFeatures.cpp::execute(), after each feature finishes bursting, the driver runs voxelsList.assign(size + 1, -1). At that point size == 0 (the inner while(size > 0) loop guarantees it), so the vector's size shrinks to 1 while capacity is retained. The first accepted neighbor of every subsequent multi-cell feature then trips the growth guard (size >= voxelsList.size()), triggering a resize(size + 100000) plus an explicit loop writing 100k -1 sentinels — roughly 1.6 MB of memory writes per feature that do no useful work. The -1 sentinel values are never read anywhere (only indices below size, all previously written, are consumed).

At high feature counts (e.g. 1M features on a large EBSD volume) this is on the order of terabytes of wasted write traffic in the shared driver, affecting ScalarSegmentFeatures, EBSDSegmentFeatures, and CAxisSegmentFeatures alike.

Suggested cleanup:

  • Drop the assign(size + 1, -1) entirely (size = 0 is already reset at the top of each burst) and keep the vector's size stable across features.
  • Drop both -1 sentinel fill loops (initial construction and the growth path); the sentinels are write-only.

The write-before-grow indexing invariant (size < voxelsList.size() at every voxelsList[size] write) holds independently of the sentinel values, so this is a pure performance cleanup with no behavior change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions