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 support for 32-bit systems #30

Merged
merged 1 commit into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ julia:
- 1.0
- 1
- nightly
# matrix:
# allow_failures:
# - julia: nightly
# fast_finish: true
notifications:
email: false
after_success:
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
jobs:
include:
- julia: 1
os: linux
arch: x86
- stage: "Documentation"
julia: 1
os: linux
Expand Down
9 changes: 5 additions & 4 deletions src/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const defaultpruned = Tuple{Symbol,Symbol}[]
# This allows Revise to correct the location information in profiles
if VERSION >= v"1.5.0-DEV.9"
# ref https://github.com/JuliaLang/julia/pull/34235
lineinfodict(data::Vector{UInt64}) = Profile.getdict(data)
lineinfodict(data::Vector{<:Unsigned}) = Profile.getdict(data)
else
# Use the definition of Profile.getdict from Julia 1.5.0-DEV.9+
function lineinfodict(data::Vector{UInt64})
function lineinfodict(data::Vector{<:Unsigned})
# Lookup is expensive, so do it only once per ip.
udata = unique(data)
dict = Profile.LineInfoDict()
Expand Down Expand Up @@ -97,14 +97,15 @@ function flamegraph(data=Profile.fetch(); lidict=nothing, C=false, combine=true,
if lidict === nothing
lidict = lineinfodict(unique(data))
end
data_u64 = convert(Vector{UInt64}, data)
root = combine ? StackFrameTree{StackFrame}() : StackFrameTree{UInt64}()
# Build the tree with C=true, regardless of user setting. This is because
# we need the C frames to set the status flag. They will be omitted by `flamegraph!`
# as needed.
if VERSION >= v"1.4.0-DEV.128"
root = Profile.tree!(root, data, lidict, #= C =# true, recur)
root = Profile.tree!(root, data_u64, lidict, #= C =# true, recur)
else
root = Profile.tree!(root, data, lidict, #= C =# true)
root = Profile.tree!(root, data_u64, lidict, #= C =# true)
end
if isempty(root.down)
Profile.warning_empty()
Expand Down
7 changes: 4 additions & 3 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ If you just supply a string filename ending with this extension,
you must pass `data` and `lidict` explicitly, because
FileIO has its own interpretation of the meaning of `save` with no arguments.
"""
function save(f::File{format"JLPROF"}, data::AbstractVector{UInt64}, lidict::Profile.LineInfoDict)
function save(f::File{format"JLPROF"}, data::AbstractVector{<:Unsigned}, lidict::Profile.LineInfoDict)
data_u64 = convert(AbstractVector{UInt64}, data)
open(f, "w") do io
write(io, magic(format"JLPROF"))
# Write an endianness revealer
write(io, 0x01020304)
# Write an indicator that this is data/lidict format
write(io, 0x01)
write(io, Int64(length(data)))
write(io, data)
write(io, Int64(length(data_u64)))
write(io, data_u64)
write(io, Int64(length(lidict)))
for (k, v) in lidict
write(io, k)
Expand Down
25 changes: 13 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using Test, Profile
# useful for testing
stackframe(func, file, line; C=false) = StackFrame(Symbol(func), Symbol(file), line, nothing, C, false, 0)

Profile.init(n=10000) # prevent stack overflow

@testset "flamegraph" begin
backtraces = UInt64[0, 4, 3, 2, 1, # order: calles then caller
Expand Down Expand Up @@ -406,18 +407,18 @@ end
end

@testset "Profiling" begin
A = randn(100, 100, 200)
Profile.clear()
@profile mapslices(sum, A; dims=2)
g = flamegraph()
@test FlameGraphs.depth(g) > 10
img = flamepixels(StackFrameCategory(), flamegraph(C=true))
@test any(img .== colorant"orange")
A = [1,2,3]
sum(A)
Profile.clear()
@profile sum(A)
Sys.islinux() && @test_logs (:warn, r"There were no samples collected.") flamegraph() === nothing
A = randn(100, 100, 200)
Profile.clear()
@profile mapslices(sum, A; dims=2)
g = flamegraph()
@test FlameGraphs.depth(g) > 10
img = flamepixels(StackFrameCategory(), flamegraph(C=true))
@test any(img .== colorant"orange")
A = [1,2,3]
sum(A)
Profile.clear()
@profile sum(A)
Sys.islinux() && @test_logs (:warn, r"There were no samples collected.") flamegraph() === nothing
end

@testset "IO" begin
Expand Down