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

[WIP] Update for Julia 0.7 and 1.0 #96

Closed
wants to merge 10 commits into from

Conversation

GunnarFarneback
Copy link

Let's get ProfileView working in Julia 0.7 and 1.0. This PR is so far incomplete and fixes the more straightforward deprecations.

@@ -1,4 +1,4 @@
julia 0.5
julia 0.7
Copy link
Author

Choose a reason for hiding this comment

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

Is it fine to drop both Julia 0.5 and 0.6 support on master? Otherwise some compatibility additions are needed.

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, absolutely!

test/test.jl Outdated
@@ -4,10 +4,10 @@ function profile_test(n)
for i = 1:n
A = randn(100,100,20)
m = maximum(A)
Afft = fft(A)
Am = mapslices(sum, A, 2)
# Afft = fft(A)
Copy link
Author

Choose a reason for hiding this comment

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

I assume the fft call is only intended to provide some nontrivial amount of computations that can be profiled. With FFTW having been moved out of Base, it might be better to replace it with something that doesn't require a testing dependency. Or is it fine to just skip it?

Copy link
Owner

Choose a reason for hiding this comment

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

Agreed better not to use fft. You can either replace it or skip it, either is fine with me.

@GunnarFarneback
Copy link
Author

The current stumbling block is that the conditional loading and LOAD_PATH magic in __init__ needs to be updated.

function __init__()
    push!(LOAD_PATH, splitdir(@__FILE__)[1])
    if (isdefined(Main, :IJulia) && !isdefined(Main, :PROFILEVIEW_USEGTK)) || !have_display()
        eval(Expr(:import, :ProfileViewSVG))
        @eval begin
            view(data = Profile.fetch(); C = false, lidict = nothing, colorgc = true, fontsize = 12, combine = true, pruned = []) = ProfileViewSVG.view(data; C=C, lidict=lidict, colorgc=colorgc, fontsize=fontsize, combine=combine, pruned=pruned)
        end
    else
        eval(Expr(:import, :ProfileViewGtk))
        @eval begin
            view(data = Profile.fetch(); C = false, lidict = nothing, colorgc = true, fontsize = 12, combine = true, pruned = []) = ProfileViewGtk.view(data; C=C, lidict=lidict, colorgc=colorgc, fontsize=fontsize, combine=combine, pruned=pruned)
...

Any hints on how to proceed with this?

@GunnarFarneback
Copy link
Author

No idea whether that import fix is correct, but it's good enough to run into Gtk dependency errors instead. Some kind of progress.

Copy link
Owner

@timholy timholy left a comment

Choose a reason for hiding this comment

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

This looks great, thanks for doing it.

Gtk should come very soon, it will be exciting to be ready here.

@@ -1,4 +1,4 @@
julia 0.5
julia 0.7
Copy link
Owner

Choose a reason for hiding this comment

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

Yes, absolutely!

return haskey(ENV, "DISPLAY")
end

include("ProfileViewSVG.jl")
include("ProfileViewGtk.jl")
Copy link
Owner

Choose a reason for hiding this comment

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

So, these used to be loaded conditionally. The reason is that Gtk requires compilation, and not everyone has a compiler installed; with this design, they won't even be able to use the package with ProfileViewSVG because it will error when they issue using ProfileView.

If you changed this because you couldn't get it working, what was the error?

Copy link
Author

Choose a reason for hiding this comment

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

I'm certain there's a better solution, but I neither managed to understand the subtleties of how the code used to work nor more exactly why it was failing. Without the last commit the error is:

ERROR: LoadError: LoadError: UndefVarError: ProfileViewGtk not defined
Stacktrace:
 [1] #view#23(::Bool, ::Nothing, ::Bool, ::Int64, ::Bool, ::Array{Any,1}, ::Function, ::Array{UInt64,1}) at /tmp/ProfileView.jl/src/ProfileView.jl:54
 [2] view at /tmp/ProfileView.jl/src/ProfileView.jl:54 [inlined] (repeats 2 times)
 [3] top-level scope at none:0
 [4] include at ./boot.jl:317 [inlined]
 [5] include_relative(::Module, ::String) at ./loading.jl:1038
 [6] include(::Module, ::String) at ./sysimg.jl:29
 [7] include(::String) at ./client.jl:398
 [8] top-level scope at none:0
 [9] include at ./boot.jl:317 [inlined]
 [10] include_relative(::Module, ::String) at ./loading.jl:1038
 [11] include(::Module, ::String) at ./sysimg.jl:29
 [12] include(::String) at ./client.jl:398
 [13] top-level scope at none:0
in expression starting at /tmp/ProfileView.jl/test/test.jl:40
in expression starting at /tmp/ProfileView.jl/test/runtests.jl:6

src/tree.jl Outdated
data::T
parent::Node{T}
child::Node{T}
sibling::Node{T}

# Constructor for the root of the tree
function (::Type{Node{T}}){T}(data::T)
function (::Type{Node{T}})(data::T) where T
Copy link
Owner

Choose a reason for hiding this comment

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

These can change to the newer and much easier syntax, function Node{T})(data) where T.

src/tree.jl Outdated
Node{T}(data::T) = Node{T}(data)
Node{T}(data::T, parent::Node{T}) = Node{T}(data, parent)
Node(data::T) where {T} = Node{T}(data)
Node(data::T, parent::Node{T}) where {T} = Node{T}(data, parent)
Copy link
Owner

Choose a reason for hiding this comment

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

Now that I know more I'd write this as Node(data, parent::Node{T}) where T (dropping the ::T on data). Having the parent is enough to specify the T we need, and any data that can be converted to T will then work.

Completely optional, however.

src/tree.jl Outdated
@@ -50,7 +50,7 @@ function lastsibling(sib::Node)
sib
end

function addsibling{T}(oldersib::Node{T}, data::T)
function addsibling(oldersib::Node{T}, data::T) where T
Copy link
Owner

Choose a reason for hiding this comment

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

likewise here

src/tree.jl Outdated
n = new{T}(data)
n.parent = n
n.child = n
n.sibling = n
n
end
# Constructor for all others
function (::Type{Node{T}}){T}(data::T, parent::Node)
function (::Type{Node{T}})(data::T, parent::Node) where T
Copy link
Owner

Choose a reason for hiding this comment

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

here too

test/test.jl Outdated
@@ -4,10 +4,10 @@ function profile_test(n)
for i = 1:n
A = randn(100,100,20)
m = maximum(A)
Afft = fft(A)
Am = mapslices(sum, A, 2)
# Afft = fft(A)
Copy link
Owner

Choose a reason for hiding this comment

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

Agreed better not to use fft. You can either replace it or skip it, either is fine with me.

@GunnarFarneback
Copy link
Author

Review comments have been addressed except for the conditional loading, which is beyond my grasp for now. At this point I'm getting massive amounts of warnings from GtkReactive. It would help if JuliaGizmos/GtkReactive.jl#69 could be merged.

@GunnarFarneback
Copy link
Author

Reverted the conditional loading fix since it was buggy (had forgot to remove the pop! of LOAD_PATH), turned out not to solve the problem anyway, and destroyed the actual conditionality of the loading.

The loading issues still need to be fixed though.

@GunnarFarneback
Copy link
Author

GunnarFarneback commented Aug 17, 2018

Some progress. The immediate problem wasn't about changes to the code loading logic but that the import AST had changed. I.e.

eval(Expr(:import, :ProfileViewGtk))

wasn't actually doing anything (at least not visible) and should instead have been

eval(Expr(:import, Expr(:., :ProfileViewGtk)))

But as far as I can tell that's equivalent to

eval(:(import ProfileViewGtk))

and

@eval import ProfileViewGtk

so I'll assume the explicit construction of the Expr had historical reasons.

@GunnarFarneback
Copy link
Author

At this point the SVG backend might be functional. The GTK backend is blocked by GtkReactive.

@timholy
Copy link
Owner

timholy commented Aug 21, 2018

I don't have the bandwidth to look at this now. After the Interpolations rewrite is done and I get Rebugger announced, maybe I'll have time. Till then, sorry, and good luck!

@GunnarFarneback
Copy link
Author

Closing in slowly. With JuliaGizmos/GtkReactive.jl#72 I get ProfileView to pass its tests on 0.7, although there are still some warnings. And well, it doesn't actually work. It manages to draw the blocks but is somewhat less than useful without the annotations.

The main remaining warning is

┌ Warning: Package ProfileView does not have ProfileViewGtk in its dependencies:
│ - If you have ProfileView checked out for development and have
│   added ProfileViewGtk as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with ProfileView
└ Loading ProfileViewGtk into ProfileView from project dependency, future warnings for ProfileView are suppressed.

Apparently the package manager (or maybe more accurate the code loader) is not impressed by the LOAD_PATH trickery for optional dependencies, so some improvement is needed on that front.

@timholy
Copy link
Owner

timholy commented Aug 28, 2018

Yes, we might have to split it out as a separate package. Or perhaps we can add a toml file that provides the path?

@timholy
Copy link
Owner

timholy commented Aug 30, 2018

Integrated into #99

@timholy timholy closed this Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants