Skip to content

Commit 2a197c2

Browse files
committed
extend sysimg:
1. more of the 'slowest' imports in MyTB (the ones with ~0.4 s. The remaining all have <0.02 s or so). 2. JLD2 precompile of jldsave and load of a tempfile. both helped, but just a little (load cached sim went from 13s to 10s. MyTB import a lick faster)
1 parent 791be6c commit 2a197c2

File tree

7 files changed

+82
-94
lines changed

7 files changed

+82
-94
lines changed

Manifest.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,9 @@ version = "1.0.0"
566566

567567
[[deps.JLD2]]
568568
deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "Pkg", "Printf", "Reexport", "TranscodingStreams", "UUIDs"]
569-
git-tree-sha1 = "81b9477b49402b47fbe7f7ae0b252077f53e4a08"
569+
git-tree-sha1 = "6c38bbe47948f74d63434abed68bdfc8d2c46b99"
570570
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
571-
version = "0.4.22"
571+
version = "0.4.23"
572572

573573
[[deps.JLLWrappers]]
574574
deps = ["Preferences"]

Project.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@ ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
44
Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f"
55
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
66
DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964"
7+
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
78
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
89
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
10+
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
911
LsqFit = "2fda8390-95c7-5789-9bda-21331edee243"
1012
MyToolbox = "54cd1024-cafd-4d62-948d-ced4874502bf"
1113
PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d"
14+
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
1215
ProfileView = "c46f51b8-102a-5cf2-8d2c-8597cb0e0da7"
13-
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
1416
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
1517
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
1618
Sciplotlib = "61be95e5-9550-4d5f-a203-92a5acbc3116"
19+
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1720
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
1821
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
1922
TerminalLoggers = "5d786b92-1e48-4d6f-9151-6b4477ca9bed"

nb/2022-09-15__Two-pass_conntest_ptp-then-cor.ipynb

Lines changed: 29 additions & 69 deletions
Large diffs are not rendered by default.

nb/2022-09-15__Two-pass_conntest_ptp-then-cor.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ using VoltoMapSim
3030

3131
# ## Params
3232

33-
using ProfileView
34-
3533
p = get_params(
3634
duration = 10minutes,
3735
p_conn = 0.04,
@@ -48,14 +46,14 @@ p = get_params(
4846

4947
@time s = cached(sim, [p.sim]);
5048

51-
@profview s = augment(s, p);
49+
s = augment(s, p);
5250

5351
using PyPlot
5452
using VoltoMapSim.Plot
5553

56-
@profview plotSTA(1=>1,s,p);
57-
plotSTA(2=>2,s,p);
58-
plotSTA(801=>801,s,p);
59-
plotSTA(802=>802,s,p);
54+
@time plotSTA(1=>1,s,p);
55+
# plotSTA(2=>2,s,p);
56+
# plotSTA(801=>801,s,p);
57+
# plotSTA(802=>802,s,p);
6058

6159

sysimg/ReadMe.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,33 @@ The goal is to have to wait less long for package imports and first function cal
55
fresh Julia session.
66

77

8-
### Build
9-
To build the image, run, in the repo root:
8+
## Build
9+
10+
To build the image, run, in this directory:
1011
```
11-
julia sysimg/build.jl
12+
julia build.jl
1213
```
1314
This takes a few minutes.
1415

1516

16-
### Use
17+
## Use
1718

1819
To use the generated system image:
19-
- On the command line:
20+
21+
- On the command line, in the repo root:
2022
```
2123
julia --sysimg=sysimg/mysis.dll
2224
```
23-
- As a 'kernel' in Jupyter: [relevant IJulia docs](
24-
https://julialang.github.io/IJulia.jl/stable/manual/installation/#Installing-additional-Julia-kernels)
25-
- Make sure to also add the flag `"--project=@."`.
26-
- For me, the generated kernel definition file is located at:
27-
`C:\Users\tfiers\AppData\Roaming\jupyter\kernels\julia-preloaded-1.7\kernel.json`
25+
26+
- As a 'kernel' in Jupyter: see the
27+
[relevant IJulia docs](
28+
https://julialang.github.io/IJulia.jl/stable/manual/installation/#Installing-additional-Julia-kernels).
29+
Make sure to also add the flag `--project=@.`.
30+
31+
32+
## Notes
33+
34+
- If on Linux or MacOS, you can replace the `.dll` extension inside these scripts with `.so` or `.dylib` respectively (though leaving it as is will also just work).
35+
36+
- For me, the generated Jupyter kernel definition file is located at:
37+
`C:\Users\tfiers\AppData\Roaming\jupyter\kernels\julia-preloaded-1.7\kernel.json`

sysimg/build.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
using PackageCompiler
1+
using Pkg
2+
Pkg.activate("..")
23

4+
using PackageCompiler
35
create_sysimage(
46
[
57
:Revise,
6-
:PyCall,
78
:IJulia,
89
:PyPlot,
910
:DataFrames,
1011
:ComponentArrays,
12+
:DataStructures,
13+
:Parameters,
14+
:StatsBase,
15+
:JLD2,
1116
];
12-
sysimage_path = "sysimg/mysys.dll",
13-
precompile_execution_file = "sysimg/to_precompile.jl",
14-
script = "sysimg/pyplot_delay_init.jl",
17+
sysimage_path = "mysys.dll",
18+
precompile_execution_file = "to_precompile.jl",
19+
script = "pyplot_delay_init.jl",
1520
)

sysimg/to_precompile.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
using DataStructures, Parameters, StatsBase
2+
13
using PyPlot, DataFrames, ComponentArrays
24

35
df = DataFrame([(a=1, b=2), (a=2, b=2)])
46
cv = ComponentVector(a=3, b=8)
57

68
fig, ax = plt.subplots()
79
ax.plot(df.a, collect(cv))
10+
11+
12+
using JLD2
13+
14+
fn = tempname()*".jld2"
15+
struct MyType
16+
x::String
17+
end
18+
jldsave(fn; somedata=(; a=2, b=""), p=MyType("yo"))
19+
load(fn)

0 commit comments

Comments
 (0)