From f71c1fcb721f3e5c52955252ffc62b99ebc17b93 Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sun, 7 May 2023 18:23:34 -0500 Subject: [PATCH] Add precompilation (#224) * Add precompilation On my machine this drops the time required for the "workload" from about 0.25s to about 0.025s (factor of 10). While the absolute times are not large, the aim is to reduce the startup time for IJulia kernels. * Add [compat] * fix indentation --- Project.toml | 2 ++ src/ZMQ.jl | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Project.toml b/Project.toml index 4f5b456..7a85619 100644 --- a/Project.toml +++ b/Project.toml @@ -4,10 +4,12 @@ version = "1.2.2" [deps] FileWatching = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" +PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a" Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" ZeroMQ_jll = "8f1865be-045e-5c20-9c9f-bfbfb0764568" [compat] +PrecompileTools = "1" ZeroMQ_jll = "4" julia = "1.3" diff --git a/src/ZMQ.jl b/src/ZMQ.jl index f57be26..348a2a2 100644 --- a/src/ZMQ.jl +++ b/src/ZMQ.jl @@ -43,4 +43,32 @@ function __init__() end end +using PrecompileTools +@compile_workload begin + __init__() + # The ZMQ scoping below isn't necessary, but it makes it easier to copy/paste + # the workload to test impact. + s=Socket(PUB) + ZMQ.close(s) + + s1=Socket(REP) + s1.sndhwm = 1000 + s1.linger = 1 + s1.routing_id = "abcd" + + s2=Socket(REQ) + + ZMQ.bind(s1, "tcp://*:5555") + ZMQ.connect(s2, "tcp://localhost:5555") + + msg = Message("test request") + + ZMQ.send(s2, msg) + unsafe_string(ZMQ.recv(s1)) + ZMQ.send(s1, Message("test response")) + unsafe_string(ZMQ.recv(s2)) + ZMQ.close(s1) + ZMQ.close(s2) +end + end