Skip to content

feat: Query ranked/aggregate group compile stats via getattribute - #2147

Open
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-stats
Open

feat: Query ranked/aggregate group compile stats via getattribute#2147
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-stats

Conversation

@lgritz

@lgritz lgritz commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Post-optimization group metrics active_layers, network_depth, texture_ops, and noise_ops were queryable per group, but the "top N" lists and min/max/median that getstats() prints were computed inline and discarded. Renderers had no way to get them short of scraping the text, and no way to enumerate groups to recompute them.

Add system-level getattribute keys:

stat:compiled_<metric>:top_count    int       # groups with value > 0
stat:compiled_<metric>:top_names    string[n] # ranked, "" padded
stat:compiled_<metric>:top_values   int[n]    # ranked, 0 padded
stat:compiled_<metric>:min|max|median  int    # zero-valued included

Caller's array size picks N; stat:rank_groups still governs only the printed report. Only optimized groups count, and querying never forces optimization.

The gather/sort/aggregate logic moves into gather_group_stats(), which getstats() now also uses, so the report and the queries cannot drift. Keys dispatch before m_mutex is taken, since gather_group_stats() needs only m_all_shader_groups_mutex.

oslexec.h gains documentation only, so there is no API or ABI change.

Testing: testrender gains --print-group-stats, and compstats renders a three-group scene, which testshade cannot do with one group per process. That covers ranking order, the name-ascending tie-break, and exclusion of zero-valued groups from the ranked list while they still count toward min/max/median. The test's filter_re was also dropping the individual ranked entries from both sides of the diff, so the printed top-N was never actually compared; widened to include them.

Assisted-by: Claude Code / Claude Opus 5

Post-optimization group metrics active_layers, network_depth,
texture_ops, and noise_ops were queryable per group, but the "top N"
lists and min/max/median that getstats() prints were computed inline
and discarded. Renderers had no way to get them short of scraping the
text, and no way to enumerate groups to recompute them.

Add system-level getattribute keys:

    stat:compiled_<metric>:top_count    int       # groups with value > 0
    stat:compiled_<metric>:top_names    string[n] # ranked, "" padded
    stat:compiled_<metric>:top_values   int[n]    # ranked, 0 padded
    stat:compiled_<metric>:min|max|median  int    # zero-valued included

Caller's array size picks N; stat:rank_groups still governs only the
printed report. Only optimized groups count, and querying never forces
optimization.

The gather/sort/aggregate logic moves into gather_group_stats(), which
getstats() now also uses, so the report and the queries cannot drift.
Keys dispatch before m_mutex is taken, since gather_group_stats() needs
only m_all_shader_groups_mutex.

oslexec.h gains documentation only, so there is no API or ABI change.

Testing: testrender gains --print-group-stats, and compstats renders a
three-group scene, which testshade cannot do with one group per process.
That covers ranking order, the name-ascending tie-break, and exclusion of
zero-valued groups from the ranked list while they still count toward
min/max/median. The test's filter_re was also dropping the individual
ranked entries from both sides of the diff, so the printed top-N was
never actually compared; widened to include them.

Assisted-by: Claude Code / Claude Opus 5

Signed-off-by: Larry Gritz <lg@larrygritz.com>
@lgritz
lgritz requested a review from cmstein August 16, 2026 21:18
@lgritz

lgritz commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

I have no idea why the icx test is failing, but it is certainly not related to the contents of this PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant