perf(sheet): reduce repeated inventory description work #129

Merged
Athemis merged 2 commits from perf/sheet-description-display into main 2026-03-16 09:00:55 +00:00
Owner

Summary

  • cache prepared item description HTML and plain-text display fields in actor sheet item list entries
  • reuse the prepared description fields for inventory rendering and live DOM sorting instead of repeated inline conversions
  • add regression coverage for sheet display preparation, description sorting, and consume-flow compatibility

Test Plan

  • pnpm test:vitest spec/apps/actor/base-sheet-item-display.spec.ts spec/apps/actor/inventory-consumables-regressions.spec.ts spec/apps/actor/consume-flow.spec.ts
  • pnpm format:check
  • pnpm lint

Closes #127
Closes #128

## Summary - cache prepared item description HTML and plain-text display fields in actor sheet item list entries - reuse the prepared description fields for inventory rendering and live DOM sorting instead of repeated inline conversions - add regression coverage for sheet display preparation, description sorting, and consume-flow compatibility ## Test Plan - pnpm test:vitest spec/apps/actor/base-sheet-item-display.spec.ts spec/apps/actor/inventory-consumables-regressions.spec.ts spec/apps/actor/consume-flow.spec.ts - pnpm format:check - pnpm lint Closes #127 Closes #128
test(sheet): cover prepared item description rendering
All checks were successful
renovate/stability-days Not a Renovate PR - check skipped
ci/woodpecker/pr/auto-approve-renovate-checks Pipeline was successful
ci/woodpecker/pr/checks Pipeline was successful
3ad9684b27
Author
Owner

Benchmark Results

A local benchmark was run to verify the performance impact of this PR. Since _buildItemListEntry is introduced by this PR, a direct branch-to-branch comparison was not possible.

Cold vs Warm (Cache Effect)

Items Cold Mean (ms) Warm Mean (ms) Speedup
25 0.93 0.07 ~13x
100 8.56 0.09 ~95x

Invalidation Costs

Scenario Mean (ms) Description
warm-100-long 0.08 Cache hit, optimal case
item-invalidation-100-long 0.21 One item changed, rest from cache
actor-invalidation-100-long 5.13 Actor context changed, full cache rebuild

Interpretation

  • Happy path (reopening same inventory): 13-95x faster due to cache
  • Item edit (name/description changed): minimal overhead, only affected item rebuilds
  • Actor edit (rare): cache invalidates and rebuilds once

Conclusion

The optimization provides significant performance gains for the common case of repeated inventory viewing. Cache invalidation is correctly implemented - item changes only affect that item, actor changes invalidate the full cache.

PR #130's lazy consume-flow behavior is preserved - we only cache in sheet rendering, not in the consume dialog path.

Recommended for merge.

## Benchmark Results A local benchmark was run to verify the performance impact of this PR. Since `_buildItemListEntry` is introduced by this PR, a direct branch-to-branch comparison was not possible. ### Cold vs Warm (Cache Effect) | Items | Cold Mean (ms) | Warm Mean (ms) | Speedup | |-------|----------------|-----------------|----------| | 25 | 0.93 | 0.07 | **~13x** | | 100 | 8.56 | 0.09 | **~95x** | ### Invalidation Costs | Scenario | Mean (ms) | Description | |------------------------------|-----------|------------------------------------------------| | warm-100-long | 0.08 | Cache hit, optimal case | | item-invalidation-100-long | 0.21 | One item changed, rest from cache | | actor-invalidation-100-long | 5.13 | Actor context changed, full cache rebuild | ### Interpretation - Happy path (reopening same inventory): 13-95x faster due to cache - Item edit (name/description changed): minimal overhead, only affected item rebuilds - Actor edit (rare): cache invalidates and rebuilds once ### Conclusion The optimization provides significant performance gains for the common case of repeated inventory viewing. Cache invalidation is correctly implemented - item changes only affect that item, actor changes invalidate the full cache. PR #130's lazy consume-flow behavior is preserved - we only cache in sheet rendering, not in the consume dialog path. Recommended for merge.
Merge branch 'main' into perf/sheet-description-display
All checks were successful
renovate/stability-days Not a Renovate PR - check skipped
ci/woodpecker/pr/auto-approve-renovate-checks Pipeline was successful
ci/woodpecker/pr/checks Pipeline was successful
a9171028df
Athemis force-pushed perf/sheet-description-display from a9171028df
All checks were successful
renovate/stability-days Not a Renovate PR - check skipped
ci/woodpecker/pr/auto-approve-renovate-checks Pipeline was successful
ci/woodpecker/pr/checks Pipeline was successful
to 175815bda3
All checks were successful
renovate/stability-days Not a Renovate PR - check skipped
ci/woodpecker/pr/auto-approve-renovate-checks Pipeline was successful
ci/woodpecker/pr/checks Pipeline was successful
2026-03-16 08:59:49 +00:00
Compare
Athemis deleted branch perf/sheet-description-display 2026-03-16 09:00:56 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Athemis/ds4!129
No description provided.