performance: distrname: use @generated#2050
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2050 +/- ##
==========================================
- Coverage 86.46% 86.46% -0.01%
==========================================
Files 147 147
Lines 8837 8836 -1
==========================================
- Hits 7641 7640 -1
Misses 1196 1196 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Generally, IMO we should rather try to keep the amount of |
|
There's one obvious inefficiency here, namely constructing a string that is only every used in Apart from that, I would usually consider performance of Last but not least, this change breaks tests. |
|
Hi! I tested your PR #2051 and in my case it does not increase performance. My app still has 90% of CPU time spent on the type-to-string mechanism. I believe that the PR still converts types to strings, but it gets delegated to Could you say a bit more about why you don't want to use Performance of |
Hi! This is my first contribution to Distributions.jl :)
This PR improves the performance of
distrname(and other display methods that use it). By using@generated, the result can be computed at JIT time for each input type and cached, making the function instant and non-allocating.In my logging application, I found that calls to
Distributions.distrnamewere a bottleneck. This PR improves my logging performance 7x.Benchmark
Example distributions:
Benchmark before the PR:
After the PR:
First call time
The first call time also improve. The benchmarks above, with
@timeinstead of@benchmarkon a cold system:Before the PR:
After the PR: