Skip to content

Exploration of Julia 1.6.1 for a simple optical simulation using FFTW v1.4.3 and GLMakie v0.4.2

License

Notifications You must be signed in to change notification settings

raghavchhetri/GaussianBeamLens

Repository files navigation

Transmission of a Gaussian Beam through a Lens

7-01-2021

About:

Exploration of Julia 1.6.1 for simple optical simulations

  • Using FFTW v1.4.3 and GLMakie v0.4.2
  • Platform: Windows 10 Pro

VS Code:

  • Navigate to the "GaussianBeamLens" folder, Right-click > Open with VS Code
  • Start a Julia REPL with ALT + J + O or Option + J + O in Mac
  • Create a Julia environment for the scripts in this folder as follows:
    Go to the package manager from Julia REPL with ], then
    (@v1.6) pkg> activate .
    (@v1.6) pkg> add GLMakie, FFTW
    (@v1.6) pkg> status -- this should show only two packages, GLMakie and FFTW
    Note that Manifest.toml and Project.toml are generated in this folder after the above steps

Verdict:

Gaussian Beam Lens

  • The interactive plot generated with GLMakie is nice. However, I've found that it takes a long time not only to initialize GLMakie, but once it's precompiled, the code itself takes a considerable amount of time to generate the output (2 minutes+ on my machine). Even the simple Test_GLMakie_Plots.jl took 2+ minutes.
    GaussianBeamLens + GLMakie heatmap + GLMakie labelslidergrid!
    3.239748 seconds (4.75 M allocations: 441.220 MiB, 4.99% gc time, 17.12% compilation time)
    59.421104 seconds (92.34 M allocations: 5.453 GiB, 4.02% gc time, 65.05% compilation time)
    9.986559 seconds (17.61 M allocations: 1.021 GiB, 4.72% gc time, 99.67% compilation time)

  • Since this code only needs to run once, the performance benefit of re-running it (numbers below) is practically irrelevant.
    0.463848 seconds (258.34 k allocations: 157.616 MiB, 7.76% gc time, 28.38% compilation time)
    0.125093 seconds (158.68 k allocations: 11.320 MiB, 26.83% gc time)
    0.237762 seconds (448.46 k allocations: 26.290 MiB, 94.47% compilation time)\

  • The issue at heart is that Julia doesn't save compiled code, so when a new session is started, everything needs to be compiled again. A workaround is to use PackageCompiler to create a custom Julia sysimage which saves the compiled state, thereby reducing the startup time. However, you'll be missing out on new udpates to the packages, which for active packages, such as GLMakie, happen frequently at the moment. Others have voiced a similar sentiment about this "time-to-first-plot" issue.

  • Overall, the visualization with GLMakie once you get it is pretty awesome, but the wait time sucks. Hopefully, GLMakie, the visualization landscape, and the startup latency issue in Julia will improve in the future, thereby making a switch to Julia from MATLAB/Python/Mathematica for these types of tasks more compelling.

rc

About

Exploration of Julia 1.6.1 for a simple optical simulation using FFTW v1.4.3 and GLMakie v0.4.2

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages