Skip to content

Commit

Permalink
[Profile] threads here is wrong to use nthreads (#45547)
Browse files Browse the repository at this point in the history
Since the `data` argument possibly does not come from the current
configuration, we should not use `nthreads` here either to filter out
possibly significant data.

(cherry picked from commit b46c14e)
  • Loading branch information
vtjnash authored and KristofferC committed Jun 8, 2022
1 parent 6f0bfc2 commit 087ba27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ The keyword arguments can be any combination of:
`:flatc` does the same but also includes collapsing of C frames (may do odd things around `jl_apply`).
- `threads::Union{Int,AbstractVector{Int}}` -- Specify which threads to include snapshots from in the report. Note that
this does not control which threads samples are collected on.
this does not control which threads samples are collected on (which may also have been collected on another machine).
- `tasks::Union{Int,AbstractVector{Int}}` -- Specify which tasks to include snapshots from in the report. Note that this
does not control which tasks samples are collected within.
Expand All @@ -238,7 +238,7 @@ function print(io::IO,
sortedby::Symbol = :filefuncline,
groupby::Union{Symbol,AbstractVector{Symbol}} = :none,
recur::Symbol = :off,
threads::Union{Int,AbstractVector{Int}} = 1:Threads.nthreads(),
threads::Union{Int,AbstractVector{Int}} = 1:typemax(Int),
tasks::Union{UInt,AbstractVector{UInt}} = typemin(UInt):typemax(UInt))

pf = ProfileFormat(;C, combine, maxdepth, mincount, noisefloor, sortedby, recur)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Profile/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ end
iobuf = IOBuffer()
with_logger(NullLogger()) do
@testset for format in [:flat, :tree]
@testset for threads in [1:Threads.nthreads(), 1, 1:1, 1:2, [1,2]]
@testset for groupby in [:none, :thread, :task, [:thread, :task], [:task, :thread]]
@testset for threads in Any[1:typemax(Int), 1, 1:1, 1:2, [1,2]]
@testset for groupby in Any[:none, :thread, :task, [:thread, :task], [:task, :thread]]
Profile.print(iobuf; groupby, threads, format)
@test !isempty(String(take!(iobuf)))
end
Expand Down

0 comments on commit 087ba27

Please sign in to comment.