Skip to content
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

Add invalidations script #673

Merged
merged 1 commit into from
Dec 22, 2021
Merged

Add invalidations script #673

merged 1 commit into from
Dec 22, 2021

Conversation

charleskawczynski
Copy link
Member

@charleskawczynski charleskawczynski commented Dec 22, 2021

For now, this script grabs invalidations and plots the number (and percentage) of children per method invalidation.

It seems that DiffEq.jl's Base.mapreduce_empty is triggering ~1k invalidations (almost 50% of all invalidations). It is recommended to tackle expensive invalidations before moving on to improving inferrability / profile-guided despecialization to improve latency.

Screen Shot 2021-12-22 at 11 15 54 AM

@charleskawczynski
Copy link
Member Author

cc @jakebolewski / @simonbyrne, this could be affecting ClimaCore, too, since we have many overlapping deps.

@charleskawczynski
Copy link
Member Author

bors r+

@jakebolewski
Copy link

I'm not sure what we can do if it is caused by a dependency?

@jakebolewski
Copy link

There are some patched diffeq support functions that are no longer necessary now that we support FieldVector's, if we get rid of some of those and only support Diffeq operations on FieldVectors and not fields that might help.

@bors
Copy link
Contributor

bors bot commented Dec 22, 2021

Build succeeded:

@bors bors bot merged commit 6f4cc73 into main Dec 22, 2021
@bors bors bot deleted the ck/invalidations branch December 22, 2021 19:39
bors bot added a commit that referenced this pull request Dec 22, 2021
674: Add explicit show to last tree element r=charleskawczynski a=charleskawczynski

Missed in #673. I'm not sure how to suppress the output in the `SnoopCompile.invalidation_trees(invalidations)` call.

Co-authored-by: Charles Kawczynski <[email protected]>
@charleskawczynski
Copy link
Member Author

This was fixed by DiiffEqBase.jl's 723 🎉

@ChrisRackauckas
Copy link

How did you get the number of invalidations to see the priority? I want to run that on all of DiffEq and just do a bunch of quick PRs like this.

@charleskawczynski
Copy link
Member Author

charleskawczynski commented Dec 23, 2021

How did you get the number of invalidations to see the priority? I want to run that on all of DiffEq and just do a bunch of quick PRs like this.

@ChrisRackauckas, Everything is actually in this PR, here's a short pseudo-code summary:

# From: https://timholy.github.io/SnoopCompile.jl/stable/snoopr/
using SnoopCompileCore
invalidations = @snoopr begin
    # load packages & do representative work
end;

import SnoopCompile
trees = SnoopCompile.invalidation_trees(invalidations);

@show length(SnoopCompile.uinvalidated(invalidations)) # show total invalidations

show(trees[end]) # show the most invalidated method

# Count number of children (number of invalidations per invalidated method)
n_invalidations = map(trees) do methinvs
    SnoopCompile.countchildren(methinvs)
end

import Plots
Plots.plot(
    1:length(trees),
    n_invalidations;
    markershape = :circle,
    xlabel = "i-th method invalidation",
    label = "Number of children per method invalidations",
)

bors bot added a commit to CliMA/ReportMetrics.jl that referenced this pull request Jan 21, 2022
12: Add script for tabulating method invalidations r=charleskawczynski a=charleskawczynski

This is to replace [these plots](CliMA/TurbulenceConvection.jl#673 (comment)).

Co-authored-by: Charles Kawczynski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants