-
-
Notifications
You must be signed in to change notification settings - Fork 59
opt-level and max-methods = 1 #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Try to reduce latency by changing settings.
Codecov ReportBase: 72.23% // Head: 72.23% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## master #244 +/- ##
=======================================
Coverage 72.23% 72.23%
=======================================
Files 23 23
Lines 940 940
=======================================
Hits 679 679
Misses 261 261
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
Some performance benchmarks on a big file of latexify tests: julia> using Latexify, Pumas, Test, StaticArrays
WARNING: using StaticArrays.pop in module Main conflicts with an existing identifier.
julia> @time include("latexify_recipes.jl")
326.492189 seconds (335.92 M allocations: 15.622 GiB, 42.37% gc time, 57.01% compilation time: <1% of which was recompilation)
Test PassedJulia master, latexify 0.15.13: julia> @time include("latexify_recipes.jl")
1104.623542 seconds (1.15 G allocations: 78.342 GiB, 29.51% gc time, 88.57% compilation time: 2% of which was recompilation)
Test PassedNote that this Julia branch has no negative performance impact on fast, type stable, code. I was hoping the tweaks in this PR would also give a 2 or 3x improvement, but alas, we'll have to wait for some form of this branch to make it into Julia, or improve this library. |
|
julia> @time include("latexify_recipes.jl")
327.410396 seconds (337.46 M allocations: 15.694 GiB, 42.77% gc time, 56.58% compilation time: <1% of which was recompilation)Master with this PR: julia> @time include("latexify_recipes.jl")
WARNING: using StaticArrays.pop in module Main conflicts with an existing identifier.
1519.625729 seconds (1.20 G allocations: 82.093 GiB, 24.20% gc time, 91.87% compilation time: 1% of which was recompilation)So, this PR seems to have regressed a lot. |
|
Latest Latexify release: julia> @time include("latexify_recipes.jl")
330.552732 seconds (337.50 M allocations: 15.696 GiB, 42.14% gc time, 58.56% compilation time: <1% of which was recompilation)
Test PassedJulia master: julia> @time include("latexify_recipes.jl")
1124.050085 seconds (1.15 G allocations: 78.384 GiB, 31.80% gc time, 87.93% compilation time: 2% of which was recompilation)
Test Passed |
|
Is there somewhere we can read about this? Is the myb branch "official" in that these commands are guaranteed to not mean something else in an upcoming Julia release? Or is there maybe a pull request this should wait for?
|
|
These commands have been around for years. It's what helped Plots.jl improve its load time in like 2020. opt-level=1 is just the same as forcing -O1 on the module, and max-methods=1 is just disabling union splitting optimizations. Just search and you'll find tons about this because they are not new options, just Yingbo's branch improves a few things with them. |
|
@gustaphe runtime is usually not a problem but there are some real latency issues. The worst ones I've seen is about 30 seconds where there are recipes calling other recipes. That absolutely precludes latexify from being used in the |
|
Okay, as far as I knew this was related to the If it's that stable and gives these speedups, LGTM. |
|
This package is missing snoopprecompile: that seems to be a major oversight given its mostly a compile time burdened library? |
|
I have tried these macros myself, probably back in julia 1.6, but with no tangible effect so I never pushed them. I was hoping that my rewrite (which has been stalled for like 2 years) would fix the issue but I'm not entirely sure that it does either. That rewrite would incur a massive amount of downstream work since it's breaking the current recipe system, hence my tardiness of getting it done. |
|
Yeah, SnoopPreCompile would certainly be worth a shot. I suspect that much of the bad performance is coming from the recipes which I don't think would be fixed by this. But it could still make an impact and it's worth adding. |
|
No, I was noting that the myb/concrete_only Julia branch tweaked inference heuristics, leading to a 3x+ improvement for Latexify. However, tweaking the options we have available in an official release (which this PR does) didn't really seem to help much at all. |
I don't think so, because this package seems to always compile for every new thing it has to do. I'm speaking in complete ignorance about the internals of this library. |
Oh that's not good 😅 . I would assume that something based around printing like this would just use one set of unparameterized types over symbols, similar to writing a compiler. If that's not the case, I guess the good thing is that there is big room for improvement. |
@korsbo has been working on a rewrite that hopefully improves this, but it breaks the recipe system, and updating all downstream packages would be an ordeal... |
|
I think That's not the case for setting the opt-level to So, I think these are all reasonable options with respect to this PR:
|
|
Yeah, let's merge this. It might not do all the magic one would have hoped for but latency is painful while runtime is insignificant so anything that tries to balance the two more favourably is a good step. |
Trying to reduce latency.
After:
Before:
I was hoping for more.