Skip to content

Comments

Add get_erased helper to reduce get/touch monomorphization#50

Merged
fasterthanlime merged 1 commit intomainfrom
fix-49-more-monomorphization
Jan 26, 2026
Merged

Add get_erased helper to reduce get/touch monomorphization#50
fasterthanlime merged 1 commit intomainfrom
fix-49-more-monomorphization

Conversation

@fasterthanlime
Copy link
Contributor

Summary

Follow-up to PRs #47 and #48, addressing more monomorphization opportunities identified in #49.

  • Add get_erased() to DerivedCore that returns BoxFuture<ArcAny>, moving the async block out of the generic DerivedIngredient::get method
  • Update DerivedIngredient::get to use get_erased, reducing the async state machine size in the generic wrapper
  • Update DerivedIngredient::touch to use the existing touch_erased helper

Expected savings

Based on the analysis in #49:

  • get::{{closure}}: 21k × 50 copies → much smaller wrapper + one copy per DB type

The remaining high-impact items are:

  • TypedCompute::compute::{{closure}} (14k × 60) - This is unavoidable as it calls the user's compute function with concrete types
  • Persistence callbacks using facet_postcard - Would need reflection-based serialization

Test plan

  • All 66 tests pass
  • No clippy warnings

Part of #49

- Add get_erased() to DerivedCore that returns BoxFuture<ArcAny>, moving
  the async block out of the generic DerivedIngredient::get method
- Update DerivedIngredient::get to use get_erased, reducing the async
  state machine size in the generic wrapper
- Update DerivedIngredient::touch to use touch_erased (already existed)

Expected savings:
- get::{{closure}}: 21k × 50 copies → much smaller wrapper + one copy per DB
- touch: now delegates to existing touch_erased helper

Part of #49
Copilot AI review requested due to automatic review settings January 26, 2026 13:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces code bloat from monomorphization in the derived ingredient query path by moving more async state-machine logic into type-erased helpers on DerivedCore.

Changes:

  • Added DerivedCore::get_erased() returning BoxFuture<PicanteResult<ArcAny>> to avoid a larger generic async block in DerivedIngredient::get.
  • Updated DerivedIngredient::get to delegate to get_erased and downcast at the boundary.
  • Updated DerivedIngredient::touch to delegate to the existing touch_erased helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fasterthanlime fasterthanlime merged commit 91a2fea into main Jan 26, 2026
10 checks passed
@fasterthanlime fasterthanlime deleted the fix-49-more-monomorphization branch January 26, 2026 13:52
@github-actions github-actions bot mentioned this pull request Jan 26, 2026
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