Repository navigation
Precompile displaying N0f8, which also accelerates the other types - #352
PatrickHaecker wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #352 +/- ##
==========================================
+ Coverage 96.75% 96.78% +0.03%
==========================================
Files 7 7
Lines 800 808 +8
==========================================
+ Hits 774 782 +8
Misses 26 26 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Personally, I believe this is worthwhile. |
|
BTW, I am considering registering the TTFX benchmark snippet for Colors.jl. Displaying |
2a403a1 to
9b952ff
Compare
I am not sure whether I understood what you have asked for here. However, I let the agent check whether we can do something to accelerate the use case and indeed we can. Turns out that precompiling 🤖:
👨: |
|
I feel like While I'm opposed to targeting pipes solely for CI purposes, the reality is that many people use a variety of tools for coding. So, it's worth considering that end-users may (indirectly) use pipes. |
Showing a value or a vector for the first time was the slowest first use of the package. Precompiling `show` and `print` for the terminal and for buffers cuts the first display in the terminal from 302 to 82 ms on Julia 1.10 and from 913 to 88 ms on Julia 1.13, and the first `repr` from 438 to 113 ms and from 553 to 107 ms. Loading becomes 8 ms (1.10) and 2 ms (1.13) slower, and the package image grows by about 1 MiB. Invalidations do not change, neither from loading the package nor from loading ColorTypes and Colors afterwards.
Scripts whose output is piped, such as CI jobs and TTFX benchmarks, print
through `IOContext{Base.PipeEndpoint}`. Without these directives, the first
display of an `RGB{N0f8}` vector takes about 2 s on Julia 1.13 and 1.4 s on
1.10, with them about 0.4 s.
It turns out that compiling only `N0f8` covers enough generic code so that the latency of the other methods for the other types is acceptable on typical REPL usage. A one-time delay of half a second is okay on the REPL. A delay of 2.5 seconds feels sluggish. Within package usage, the packages can and should precompile for their specific use cases. ---- :robot: | | master | previous PR | current PR | |---|---:|---:|---:| | image (KiB) | 2653 | 4016 | 3277 | | display `N0f8` | 2511 | 274 | 261 | | display `N0f16` | 2144 | 196 | 444 | | display `Q0f7` | 2510 | 473 | 485 | | display `Q0f15` | 2500 | 607 | 537 | | core `N0f16` | 155 | 106 | 207 | | core `Q0f7` | 363 | 271 | 257 | | core `Q0f15` | 327 | 220 | 275 | Julia 1.13.1, time in ms of the first use in a fresh process, fastest of 5, pinned to one core. "display" is the first `show` of a value and of a 2-element vector plus `print`, into a terminal (pipes give the same numbers within noise). "core" is the first arithmetic, rounding, conversion and `rand`.
9b952ff to
d7c9e8b
Compare
It turns out that compiling only Within package usage, the packages can and should precompile for their So removing 🤖:
Julia 1.13.1, time in ms of the first use in a fresh process, fastest of 5, pinned to one core. "display" is the first |
|
Although the policy hasn't been finalized yet, we'll at least need to review the PR title before merging. |
N0f8 and N0f16N0f8
N0f8N0f8, which also accelerates the other types
|
Good point. I changed the PR title. Ready to merge now, or what kind of policy needs to be finalized? Your last suggestion, which is implemented in this PR, seems to be the best compromise we have found so far. If we find a better one in the future, we can do another PR. |
Showing a value or a vector for the first time was slow. Precompiling
showandprintfor the terminal and for buffers cuts the first display in the terminal from 302 to 82 ms on Julia 1.10 and from 913 to 88 ms on Julia 1.13, and the firstreprfrom 438 to 113 ms and from 553 to 107 ms. Loading becomes 8 ms (1.10) and 2 ms (1.13) slower, and the package image grows by about 1 MiB. Invalidations do not change, neither from loading the package nor from loading ColorTypes and Colors afterwards.