• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #38011

17 Feb 2025 06:24AM UTC coverage: 20.248% (-5.6%) from 25.839%
#38011

push

local

web-flow
bpart: Track whether any binding replacement has happened in image modules (#57433)

This implements the optimization proposed in #57426 by keeping track of
whether any bindings were replaced in image modules (excluding `Main` as
facilitated by #57426). In addition, we augment serialization to keep
track of whether a method body contains any GlobalRefs that point to a
loaded (system or package) image. If both of these flags are true, we
can skip scanning the body of the method, since we know that we neither
need to add any additional backedges nor were any of the referenced
bindings invalidated. The performance impact on end-to-end load time is
small, but measurable. Overall `@time using ModelingToolkit`
consistently improves about 5% using this PR. However, I should note
that using time is still about 40% slower than 1.11. This is not
necessarily an Apples-to-Apples comparison as there were substantial
other changes on 1.12 (as well as current load-time-tunings targeting
older versions), but I wanted to put the number context.

2 of 15 new or added lines in 5 files covered. (13.33%)

2655 existing lines in 108 files now uncovered.

9867 of 48731 relevant lines covered (20.25%)

107722.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/stdlib/Sockets/src/PipeServer.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
mutable struct PipeServer <: LibuvServer
4
    handle::Ptr{Cvoid}
5
    status::Int
6
    cond::Base.ThreadSynchronizer
7
    function PipeServer(handle::Ptr{Cvoid}, status)
×
8
        p = new(handle,
×
9
                status,
10
                Base.ThreadSynchronizer())
11
        associate_julia_struct(p.handle, p)
×
12
        finalizer(uvfinalize, p)
×
13
        return p
×
14
    end
15
end
16

17
function PipeServer()
×
18
    pipe = PipeServer(Libc.malloc(Base._sizeof_uv_named_pipe), StatusUninit)
×
19
    iolock_begin()
×
20
    err = ccall(:uv_pipe_init, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Cint), eventloop(), pipe.handle, 0)
×
21
    uv_error("failed to create pipe server", err)
×
22
    pipe.status = StatusInit
×
23
    iolock_end()
×
24
    return pipe
×
25
end
26

27
## server functions ##
28

29
accept(server::PipeServer) = accept(server, PipeEndpoint())
×
30

UNCOV
31
function accept_nonblock(server::PipeServer, client::PipeEndpoint)
×
32
    iolock_begin()
×
33
    if client.status != StatusInit
×
34
        error("client is already in use or has been closed")
×
35
    end
36
    err = ccall(:uv_accept, Int32, (Ptr{Cvoid}, Ptr{Cvoid}), server.handle, client.handle)
×
37
    if err == 0
×
38
        client.status = StatusOpen
×
39
    end
40
    iolock_end()
×
41
    return err
×
42
end
43

44
function accept_nonblock(server::PipeServer)
×
45
    client = PipeEndpoint()
×
46
    uv_error("accept", accept_nonblock(server, client) != 0)
×
47
    return client
×
48
end
49

50
function bind(server::PipeServer, name::AbstractString)
×
51
    iolock_begin()
×
52
    @assert server.status == StatusInit
×
53
    err = ccall(:uv_pipe_bind, Int32, (Ptr{Cvoid}, Cstring),
×
54
                server, name)
55
    if err != 0
×
56
        iolock_end()
×
57
        if err != UV_EADDRINUSE && err != UV_EACCES
×
58
            #TODO: this codepath is currently not tested
59
            throw(_UVError("bind", err))
×
60
        else
61
            return false
×
62
        end
63
    end
64
    server.status = StatusOpen
×
65
    iolock_end()
×
66
    return true
×
67
end
68

69
"""
70
    listen(path::AbstractString) -> PipeServer
71

72
Create and listen on a named pipe / UNIX domain socket.
73

74
!!! note
75
    Path length on Unix is limited to somewhere between 92 and 108 bytes (cf. `man unix`).
76
"""
77
function listen(path::AbstractString)
×
78
    sock = PipeServer()
×
79
    bind(sock, path) || throw(ArgumentError("could not listen on path $path"))
×
80
    return listen(sock)
×
81
end
82

83
function connect!(sock::PipeEndpoint, path::AbstractString)
×
84
    iolock_begin()
×
85
    @assert sock.status == StatusInit
×
86
    req = Libc.malloc(Base._sizeof_uv_connect)
×
87
    uv_req_set_data(req, C_NULL)
×
88
    ccall(:uv_pipe_connect, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}), req, sock.handle, path,
×
89
          @cfunction(uv_connectcb, Cvoid, (Ptr{Cvoid}, Cint)))
×
90
    sock.status = StatusConnecting
×
91
    iolock_end()
×
92
    return sock
×
93
end
94

95
"""
96
    connect(path::AbstractString) -> PipeEndpoint
97

98
Connect to the named pipe / UNIX domain socket at `path`.
99

100
!!! note
101
    Path length on Unix is limited to somewhere between 92 and 108 bytes (cf. `man unix`).
102
"""
103
connect(path::AbstractString) = connect(PipeEndpoint(), path)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc