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

Precompilation error when loading BifurcationKit and GLMakie in a fresh environment #178

Closed
BambOoxX opened this issue Sep 30, 2024 · 6 comments

Comments

@BambOoxX
Copy link
Contributor

BambOoxX commented Sep 30, 2024

Hello,
I'm trying to use BifurcationKit along with GLMakie, but that fails during precompilation.

The following

] activate --temp
add BifurcationKit
add GLMakie

gives

Precompiling project...
? BifurcationKit → GLMakieExt
1 dependency successfully precompiled in 19 seconds. 313 already precompiled.
1 dependency failed but may be precompilable after restarting julia
1 dependency had output during precompilation:
┌ BifurcationKit → GLMakieExt
│ WARNING: Method definition get_plot_backend() in module BifurcationKit at .julia\packages\BifurcationKit\tOafK\src\Utils.jl:10 overwritten in module GLMakieExt at .julia\packages\BifurcationKit\tOafK\ext\GLMakieExt\GLMakieExt.jl:29.
│ ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.

Is this an intended behavior ?

This is with

[0f109fa4] BifurcationKit v0.4.2
[e9467ef8] GLMakie v0.10.12

under

Julia Version 1.10.4
Commit 48d4fd4843 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

@rveltz
Copy link
Member

rveltz commented Oct 1, 2024

It is a design issue coming from my implementation. I do not know how to support plots and Makie without forcing recompilation. If you have ideas, please PR!

@BambOoxX
Copy link
Contributor Author

BambOoxX commented Oct 1, 2024

Given that both Plots and Makie are loaded through extensions, I'm wondering if something like

function get_plot_backend()
!isnothing(Base.get_extension(BifurcationKit,:MakieExt)) && return BK_Makie()
!isnothing(Base.get_extension(BifurcationKit,:PlotsExt)) && return BK_Plots()
return BK_NoPlot()
end

could work...

@BambOoxX
Copy link
Contributor Author

BambOoxX commented Oct 2, 2024

Ok, I just tested that and it works fine. Benchmarking on my PC returns

julia> @benchmark BifurcationKit.get_plot_backend()
BenchmarkTools.Trial: 10000 samples with 429 evaluations.
 Range (min … max):  235.664 ns …  1.343 μs  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     316.783 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   326.307 ns ± 49.399 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

                ▄█▅▂▁
  ▂▁▁▁▁▁▁▁▃▅▅▅▆▇█████▆▄▄▃▃▃▂▂▂▂▂▁▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂
  236 ns          Histogram: frequency by time          538 ns <

 Memory estimate: 192 bytes, allocs estimate: 6.

Clearly this is worse than your initial solution in terms of runtime : x316 speed-down :).
But that still remains very fast.

I've also tested using a const to avoid using get_plot_backend() each time a plot is called.
It works fine, as long as the plotting package is loaded before or in the same call as BifurcationKit which already seems to be the convention, but without precompilation problem.

Let me know what you think about this. I'll try to push this later today.

@rveltz
Copy link
Member

rveltz commented Oct 2, 2024

I'll try to push this later today.

I will try when you push but if it removes the warning, it is already a step

@BambOoxX
Copy link
Contributor Author

BambOoxX commented Oct 2, 2024

I just pushed my ideas, let me know which is better... or worse :)

@BambOoxX
Copy link
Contributor Author

BambOoxX commented Oct 4, 2024

Closed by #179

@BambOoxX BambOoxX closed this as completed Oct 4, 2024
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

No branches or pull requests

2 participants