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

Wall-time/all tasks profiler (#55889) #193

Merged
merged 1 commit into from
Oct 29, 2024
Merged

Conversation

d-netto
Copy link
Member

@d-netto d-netto commented Oct 27, 2024

PR Description

Backports JuliaLang#55889.

Checklist

Requirements for merging:

@github-actions github-actions bot added port-to-v1.10 This change should apply to Julia v1.10 builds port-to-master This change should apply to all future Julia builds labels Oct 27, 2024
@d-netto d-netto removed the port-to-v1.10 This change should apply to Julia v1.10 builds label Oct 27, 2024
One limitation of sampling CPU/thread profiles, as is currently done in
Julia, is that they primarily capture samples from CPU-intensive tasks.

If many tasks are performing IO or contending for concurrency primitives
like semaphores, these tasks won’t appear in the profile, as they aren't
scheduled on OS threads sampled by the profiler.

A wall-time profiler, like the one implemented in this PR, samples tasks
regardless of OS thread scheduling. This enables profiling of IO-heavy
tasks and detecting areas of heavy contention in the system.

Co-developed with @nickrobinson251.
@d-netto d-netto force-pushed the dcn-all-task-profiler branch from 4cffeca to 2d764a2 Compare October 27, 2024 20:39
@d-netto d-netto added port-to-v1.10 This change should apply to Julia v1.10 builds and removed port-to-master This change should apply to all future Julia builds labels Oct 27, 2024
Copy link
Member

@NHDaly NHDaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run the tests on the branch locally, since we still don't have CI set up here yet. 😭

Otherwise, LGTM! :)

@d-netto
Copy link
Member Author

d-netto commented Oct 29, 2024

Tests are passing:

julia> Base.runtests(["Profile"])
Running parallel tests with:
  nworkers() = 1
  nthreads() = 1
  Sys.CPU_THREADS = 4
  Sys.total_memory() = 64.000 GiB
  Sys.free_memory() = 34.233 GiB

Test  (Worker) | Time (s) | GC (s) | GC % | Alloc (MB) | RSS (MB)
Profile    (1) |        started at 2024-10-29T16:18:42.098
Profile    (1) |    39.26 |   0.30 |  0.8 |    1768.34 |  1677.02

Test Summary: |  Pass  Total   Time
  Overall     | 17973  17973  39.9s
    SUCCESS

and:

julia> using Profile

julia> Profile.@profile_walltime sleep(1)

julia> Profile.print()
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
   ╎123 @REPL/src/REPL.jl:386; (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
   ╎ 123 ulia-RAI/usr/lib/julia/sys.dylib:?; run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLB123 ulia-RAI/usr/lib/julia/sys.dylib:?; run_interface(terminal::REPL.Terminals.TextTerminal, m::123 lia-RAI/usr/lib/julia/sys.dylib:?; (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103…
   ╎    123 …lia-RAI/usr/lib/julia/sys.dylib:?; eval_with_backend(ast::Any, backend::REPL.REPLBackendRe…
   ╎     123 …lia-RAI/usr/lib/julia/sys.dylib:?; take_buffered(c::Channel{Any})
   ╎    ╎ 123 …ia-RAI/usr/lib/julia/sys.dylib:?; wait(c::Base.GenericCondition{ReentrantLock}; first::B…
   ╎    ╎  123 @Base/task.jl:995; wait()
123╎    ╎   123 …a-RAI/usr/lib/julia/sys.dylib:?; try_yieldto(undo::typeof(Base.ensure_rescheduled))
Total snapshots: 769

@d-netto d-netto merged commit fc4ae84 into v1.10.2+RAI Oct 29, 2024
4 checks passed
@d-netto d-netto deleted the dcn-all-task-profiler branch October 29, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port-to-v1.10 This change should apply to Julia v1.10 builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants