pfitzseb / ProfileCanvas.jl

MIT License
88 stars 6 forks source link

Seeing blank flame graphs on julia 1.9? #29

Closed charleskawczynski closed 1 year ago

charleskawczynski commented 1 year ago
git checkout https://github.com/CliMA/ClimaCore.jl
cd ClimaCore.jl
git checkout ck/profile_canvas_issue

julia -O0 --check-bounds=yes --project=test

then

using Revise
import ClimaCore
include(joinpath(pkgdir(ClimaCore), "test", "Operators", "finitedifference", "implicit_stencils_utils.jl"))
(s, parsed_args) = parse_commandline()

const FT = parsed_args["float_type"] == "Float64" ? Float64 : Float32

center_space = get_space(FT);
all_ops = get_all_ops(center_space);

ctr = Int[0]

import Profile
@time begin
    prof = Profile.@profile begin
        compose_single(ctr, all_ops.a_FS, all_ops.a_FV, all_ops.a_CV, all_ops.ops_F2C_V2S[5], all_ops.ops_C2F_V2S[2], 5, 2, 14)
    end
end

import ProfileCanvas
ProfileCanvas.html_file(joinpath("flame.html"))

Note: you may need to add ProfileCanvas/Profile to your environment.

The flame graph in flame.html is empty :(

info:

julia> versioninfo()
Julia Version 1.9.0
Commit 8e630552924 (2023-05-07 11:25 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores
Environment:
charleskawczynski commented 1 year ago

This same script works perfectly fine on julia 1.8.5

charleskawczynski commented 1 year ago

(note that I'm profiling compile time and note runtime)

pfitzseb commented 1 year ago

Your reproducer doesn't seem to work (anymore?):

❯ julia -O0 --check-bounds=yes --project=test
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.1 (2023-06-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Revise

julia> import ClimaCore

julia> include(joinpath(pkgdir(ClimaCore), "test", "Operators", "finitedifference", "implicit_stencils_utils.jl"))
test_pointwise_stencils_compose (generic function with 1 method)

julia> (s, parsed_args) = parse_commandline()
(ArgParseSettings(
  prog=
  description=
  epilog=
  usage=
  version=Unspecified version
  add_help=true
  add_version=false
  fromfile_prefix_chars=Set{Char}()
  autofix_names=false
  error_on_conflict=true
  suppress_warnings=false
  allow_ambiguous_opts=false
  commands_are_required=true
  default_group=
  exc_handler=default_handler
  preformatted_description=false
  preformatted_epilog=false
  exit_after_help=false
  >> usage: <PROGRAM> [--float_type FLOAT_TYPE]
  ), Dict{String, Any}("float_type" => "Float32"))

julia> const FT = parsed_args["float_type"] == "Float64" ? Float64 : Float32
Float32

julia> center_space = get_space(FT);

julia> all_ops = get_all_ops(center_space);

julia> ctr = Int[0]
1-element Vector{Int64}:
 0

julia> import Profile

julia> @time begin
           prof = Profile.@profile begin
               compose_single(ctr, all_ops.a_FS, all_ops.a_FV, all_ops.a_CV, all_ops.ops_F2C_V2S[5], all_ops.ops_C2F_V2S[2], 5, 2, 14)
           end
       end
ERROR: UndefVarError: `compose_single` not defined

I tried this with the example function from the readme and things work fine, so it's possible this is a upstream issue (potentially ARM related?).

charleskawczynski commented 1 year ago

It looks like you may not have checked out the correct branch? git checkout ck/profile_canvas_issue

pfitzseb commented 1 year ago

No, I am on that branch:

ClimaCore.jl on  ck/profile_canvas_issue
❯ julia -O0 --check-bounds=yes --project=test
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.1 (2023-06-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Revise

julia> import ClimaCore

julia> include(joinpath(pkgdir(ClimaCore), "test", "Operators", "finitedifference", "implicit_stencils_utils.jl"))
test_pointwise_stencils_compose (generic function with 1 method)

julia> (s, parsed_args) = parse_commandline()
(ArgParseSettings(
  prog=
  description=
  epilog=
  usage=
  version=Unspecified version
  add_help=true
  add_version=false
  fromfile_prefix_chars=Set{Char}()
  autofix_names=false
  error_on_conflict=true
  suppress_warnings=false
  allow_ambiguous_opts=false
  commands_are_required=true
  default_group=
  exc_handler=default_handler
  preformatted_description=false
  preformatted_epilog=false
  exit_after_help=false
  >> usage: <PROGRAM> [--float_type FLOAT_TYPE]
  ), Dict{String, Any}("float_type" => "Float32"))

julia> const FT = parsed_args["float_type"] == "Float64" ? Float64 : Float32
Float32

julia> center_space = get_space(FT);

julia> all_ops = get_all_ops(center_space);

julia> ctr = Int[0]
1-element Vector{Int64}:
 0

julia> import Profile

julia> @time begin
           prof = Profile.@profile begin
               compose_single(ctr, all_ops.a_FS, all_ops.a_FV, all_ops.a_CV, all_ops.ops_F2C_V2S[5], all_ops.ops_C2F_V2S[2], 5, 2, 14)
           end
       end
ERROR: UndefVarError: `compose_single` not defined
Stacktrace:
 [1] macro expansion
   @ ./REPL[10]:3 [inlined]
 [2] macro expansion
   @ ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/Profile/src/Profile.jl:27 [inlined]
 [3] macro expansion
   @ ./REPL[10]:2 [inlined]
 [4] top-level scope
   @ ./timing.jl:273 [inlined]
 [5] top-level scope
   @ ./REPL[10]:0

shell> git status
On branch ck/profile_canvas_issue
Your branch is up to date with 'origin/ck/profile_canvas_issue'.

nothing to commit, working tree clean
charleskawczynski commented 1 year ago

Apologies, I must have checked out this branch without needed local changes and, unfortunately, I ended up deleting that branch because my issue was resolved. I'll close for now and reopen if I come across this.