-
Notifications
You must be signed in to change notification settings - Fork 250
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
Time-to-first-plot improvements #1278
base: master
Are you sure you want to change the base?
Conversation
Just noticed some other miscellaneous refactoring accidentally made it into the first commit other than its stated purpose of eliminating splatting. I think they're all changes for the good, but I can rebase them out if you'd prefer a cleaner review here. |
Codecov Report
@@ Coverage Diff @@
## master #1278 +/- ##
==========================================
+ Coverage 85.83% 85.86% +0.03%
==========================================
Files 36 36
Lines 4158 4161 +3
==========================================
+ Hits 3569 3573 +4
+ Misses 589 588 -1
Continue to review full report at Codecov.
|
src/geom/point.jl
Outdated
@@ -67,7 +67,7 @@ function render(geom::PointGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics | |||
for (x, y, color, size, shape, alpha) in Compose.cyclezip(aes.x, aes.y, aes.color, aes.size, aes.shape, aes_alpha) | |||
shapefun = typeof(shape) <: Function ? shape : theme.point_shapes[shape] | |||
sizeval = typeof(size) <: Int ? interpolate_size(size) : size | |||
strokecolor = aes.color_key_continuous != nothing && aes.color_key_continuous ? | |||
strokecolor = issomething(aes.color_key_continuous) && aes.color_key_continuous ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note PR #1258 which rewrites render
for PointGeometry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How close is that PR to merging? I can either rebase this on top of it, you can rebase on top of this, or we can wait and see whichever gets merged first. I did notice you used != nothing
a few times in your rewrite; whatever we do, we should make sure that those are changed to issomething
before they make it to master.
thanks for you work on this dire problem! i'd been assuming it was hopeless from a pkg dev point of view and that only changes to julia base could fix it. |
Well, I'm down to 7 that are different now (all but one entirely new from the previous list):
and to be honest for some of them I'm not seeing the difference. Any thoughts? I'll keep working. Examples: colorful_hist (fixed)No idea what's going on here. masterdeveldiffhexbin_dark (fixed)something different about the colors maybe? masterdeveldiffstacked_continuous_histogram (fixed)no idea masterdeveldiffsubplot_grid_free_y_2Scales are off on this one. Weird that it's the only one that seems to have this problem. masterdeveldiff |
da4a328
to
c5a6136
Compare
All regression tests now pass. I'm gonna run some stuff to make pretty graphs showing the improvement as is only proper when working on Gadfly. |
So the results weren't as dramatic for these particular changes running on my desktop versus running on my laptop. Still a nice little ~4% bump though. I threw the data from running through all the testscripts up on Github if anyone is curious enough to take a closer look. Or perhaps more telling (I think the cluster around 10 seconds is because I had forgotten to make CSV or some other test dependency available): So to get below 10 seconds or so for most plots, I only need to make similar improvements another (0.95^28 * 40 seconds = 9.5 seconds)... 27 times... Hopefully some of my other ideas will be a bit more fruitful. |
Both |
Force pushed with changes mentioned above to |
This gives a marginal improvement on speed and memory use during first plot, but the biggest benefit is that it makes the code easier to read and the profiling significantly easier to grok.
45f7b14
to
3470acc
Compare
CI failure is unrelated. I'll try to PR a version bump of Documenter in the next few days to fix doc building failure. |
perhaps CI failure for docs is due to forgetting to fold docs/Project.toml into ./Project.toml in #1277 ? |
Comparing nothing by value (==, =!) rather than by identity (===, !==) or by type (isnothing) can have negative consequences on code speed. This commit changes all nothing comparisons to use the isnothing utility added in Julia 1.1 and Compat 2.1.
docs/Project.toml doesn't have a way to be folded into ./Project.toml unfortunately. The problem is that Documenter 0.20 has a hard version cap on DocumentStringExtensions of 0.2 which conflicts with current requirements in ./Project.toml. Should be fixable by bumping Documenter to 0.22. |
src/Gadfly.jl
Outdated
@@ -388,14 +388,14 @@ function render_prepare(plot::Plot) | |||
# they are missing. | |||
datas = Array{Data}(undef, length(plot.layers)) | |||
for (i, layer) in enumerate(plot.layers) | |||
if layer.data_source === nothing && isempty(layer.mapping) | |||
if isnothing(layer.data_source) && isempty(layer.mapping) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be willing to bet === nothing
is more efficient. The compiler loves ===
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply changing occurrences of == nothing
to use ===
(and likewise for the negative) should provide a nice improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, this issue applies: JuliaLang/julia#27681
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know. I'll update with straight ===
and see if it makes a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would also resolve the isnothing
name qualification discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed a commit changing from isnothing
to === nothing
. Still need to get back to the computer I've benchmarked on before to see if it makes a difference.
Per comment from @ararslan, the Julia compiler may prefer === versus isnothing; improvements to be confirmed with benchmarking.
These two changes give close to a 20% speedup in time-to-first-plot in
my informal bench-marking. Unfortunately, this produces different
output on some of the regression suite (thus the WIP); things aren't
getting drawn in the same order as before (see below). A total of 17
images are different, and more svgs than that are structured
differently without actually having visible differences. Don't worry;
I'll figure it out.
The changes here are just my first fumbling attempts to address the
profiling in #1275. I honestly expected the first commit in this pack
to have a bigger effect than it did, and I expected the nothing
comparisons to be negligible when in reality they were more important
than getting rid of the splatting. Pushing this now as WIP since I
don't know when I'll be able to get back to this: could be tomorrow,
or it could be weeks.
Contributor checklist:
NEWS.md
squash
'ed orfixup
'ed junk commits with git-rebaseProposed changes