Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/core/base/harbor/harbor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,11 @@ module Make (T : Transport_t) : T with type socket = T.socket = struct
(fun cur bind_addr -> if bind_addr <> "" then bind_addr :: cur else cur)
[] conf_harbor_bind_addrs#get
in
let in_s, out_s = Unix.pipe ~cloexec:true () in
(* A socket pair rather than a pipe: on Windows, a single non-socket fd in
the scheduler forces [Unix.select] into its worker-thread emulation for
every call, which leaks native memory (see #5245). With sockets only,
select uses the plain winsock fast path. *)
let in_s, out_s = Unix_utils.socketpair ~cloexec:true () in
let events = `Read in_s :: List.map (open_socket port) bind_addrs in
Task.add Tutils.scheduler
{
Expand Down
6 changes: 5 additions & 1 deletion src/modules/duppy/duppy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,11 @@ module Monad = struct
module Control = Control

let tmp = Bytes.create 1024
let x, y = Unix.pipe ()

(* A socket pair rather than a pipe: on Windows, a single non-socket fd
in the scheduler forces [Unix.select] into its worker-thread emulation
for every call, which leaks native memory. See [create] above. *)
let x, y = Unix_utils.socketpair ()
let stop = ref false
let wake_up () = ignore (Unix_utils.write y (Bytes.of_string " ") 0 1)
let ctl_m = Mutex_o.create ()
Expand Down
Loading