Investigating large latency on a constrained Windows environment

julia> write("add.zig",
              """
              export fn add(a: i32, b: i32) i32 {
                  return a + b;
              }
              """)

julia> run(`$zig build-lib -dynamic -lc add.zig`);

julia> using Libdl

julia> @time dlopen("./add.dll")
  1.021884 seconds
Ptr{Nothing} @0x0000000002720000

julia> libadd = :add
:add

julia> @ccall libadd.add(5::Int32, 5::Int32)::Int32
10
1 Like

I’m guessing that if you repeat loading libadd.dll in a new Julia instance that it takes less time within the same Windows session?

using Libdl
@time dlopen("./libadd.dll")

It looks like you got zig working! Did winget do it? I will revise the exe instructions above.

Same command window:

julia> @time dlopen("./add.dll")
  0.005680 seconds
Ptr{Nothing} @0x0000000002720000

Yes, winget worked.

1 Like

I updated the code in

1 Like
julia> run(`testdll.exe`)
ERROR: IOError: could not spawn `testdll.exe`: permission denied (EACCES)
Stacktrace:
 [1] _spawn_primitive(file::String, cmd::Cmd, stdio::Vector{Union{RawFD, Base.Libc.WindowsRawSocket, IO}})
   @ Base .\process.jl:128
 [2] #784
   @ .\process.jl:139 [inlined]
 [3] setup_stdios(f::Base.var"#784#785"{Cmd}, stdios::Vector{Union{RawFD, Base.Libc.WindowsRawSocket, IO}})
   @ Base .\process.jl:223
 [4] _spawn
   @ .\process.jl:138 [inlined]
 [5] run(::Cmd; wait::Bool)
   @ Base .\process.jl:479
 [6] run(::Cmd)
   @ Base .\process.jl:477
 [7] top-level scope
   @ REPL[25]:1

testdll.exe exists. If I double click, I get:

image

I’m also getting similar issues on my corporate Windows machine, which is curious. Let me see if playing with permissions might help.

I think Matt is right though. Ultimately management has to make a decision whether they want to slow you down or not.