Skip to content

Avoid allocating a String when hashing a lazy tensor - #252

Merged
mtfishman merged 1 commit into
mainfrom
mf/lazy-hash-typename
Sep 11, 2026
Merged

mtfishman merged 1 commit into
mainfrom
mf/lazy-hash-typename

Conversation

@mtfishman

Copy link
Copy Markdown
Member

Summary

Makes hashing a lazy tensor allocation-free. hash_lazy built its type discriminator with Symbol(Base.typename(typeof(a)).wrapper), and Symbol has no method taking a type, so it fell back to rendering the type through an IOBuffer on every call. nameof gives the same discriminator as a Symbol for free.

Symbol has no method taking a type, so Symbol(typename(T).wrapper) fell back
to rendering the type through an IOBuffer on every call. nameof gives the
same discriminator as a Symbol for free.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@mtfishman
mtfishman enabled auto-merge (squash) September 10, 2026 23:24
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.33%. Comparing base (2d41139) to head (b9a0ccf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #252      +/-   ##
==========================================
+ Coverage   75.20%   75.33%   +0.12%     
==========================================
  Files          29       29              
  Lines        1799     1800       +1     
==========================================
+ Hits         1353     1356       +3     
+ Misses        446      444       -2     
Flag Coverage Δ
docs 26.29% <0.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtfishman
mtfishman disabled auto-merge September 11, 2026 14:14
@mtfishman
mtfishman merged commit 9217ef6 into main Sep 11, 2026
12 of 18 checks passed
@mtfishman
mtfishman deleted the mf/lazy-hash-typename branch September 11, 2026 14:14
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