Skip to content

Support Windows #3

Closed
Closed

Description

@sferik

Duel runs on Linux and macOS, but not on Windows. A maintainer reviewing the pg adoption PR asked whether it does (ged/ruby-pg#771 (comment)), since that's where they're least likely to notice a performance change themselves. Comparing two versions on a Windows runner would catch regressions in Windows-only code paths, such as a C extension's mingw build, which the Linux job can't see.

These are the parts that assume a Unix system:

  • Worker control. The runner talks to each worker over a Unix socket (UNIXServer in lib/duel/runner.rb, UNIXSocket in lib/duel/worker.rb). A TCP socket on localhost, or a pair of pipes as ProcessSample already uses for JRuby, would work everywhere.
  • Process groups. ProcessSample#start spawns with pgroup: true, and #kill kills the whole group with Process.kill("KILL", -pid). Windows has new_pgroup: and no group kill, so killing a sample and what it started needs something like a Job Object or taskkill /T.
  • Signals. Resource#end_process stops a resource's server with a signal, then KILL. Windows can't deliver TERM or INT to another process, so a server needs another way to be asked to stop.
  • Peak memory. Native::Child.wait calls wait4 through Fiddle for a child's peak resident memory. On Windows that's GetProcessMemoryInfo's PeakWorkingSetSize, or Duel could leave the peak out.
  • Available memory. Memory.available reads /proc/meminfo, a cgroup limit or vm_stat, so on Windows it says nothing and Runner#fit doesn't lower the workers. GlobalMemoryStatusEx would give it.
  • Paths. Runner.short_tmp falls back to /tmp when the temporary directory's path is too long for a socket.
  • Instructions. There's no instruction counter, so CPU time would judge alone, as it does on JRuby. That's fine to start with.

The plugins that start servers (postgresql, mysql, redis, memcached) would each need their own look, since they find and stop server programs the Unix way.

Duel's CI should run the tests on windows-latest once it works, and probably on macos-latest too, since macOS isn't tested in CI today either.

Activity

  1. self-assigned this
    on Nov 11, 2026
  2. larskanis commented on Nov 11, 2026

    @larskanis

    Some related ideas:

    Worker control. The runner talks to each worker over a Unix socket (UNIXServer in lib/duel/runner.rb, UNIXSocket in lib/duel/worker.rb)

    I implemented support for UnixSocket on Windows in ruby-3.2 some years ago. It works mostly the same way as on Unix. It has limited path length.

    Signals. Resource#end_process stops a resource's server with a signal, then KILL.

    This is similar possible on Windows. A trap can be defined in a Windows subprocess like so:

    trap(:SIGINT) do
      puts "SIGINT received"
    end

    And then this trap can be triggered by a kernel32.dll call like so:

    require "fiddle"
    kernel32 = Fiddle.dlopen('kernel32.dll')
    generateconsolectrlevent = Fiddle::Function.new(
        kernel32['GenerateConsoleCtrlEvent'], [Fiddle::TYPE_INT, Fiddle::TYPE_INT], Fiddle::TYPE_INT
    )
    # Send the Ctrl-C to all processes running on the same console
    generateconsolectrlevent.call(0, 0)

    The plugins that start servers (postgresql, mysql, redis, memcached) would each need their own look, since they find and stop server programs the Unix way.

    PostgreSQL should mostly work the same way as on Unix. It can be controlled by pg_ctl equally.

  3. 5 remaining items

  4. sferik commented on Nov 12, 2026

    @sferik
    OwnerAuthor

    Windows support is in main as of 443f61a. Duel's tests and every plugin's pass on Windows (CRuby) and macOS in CI now, and those jobs are required. Two things are left, which have issues of their own: running the tests on JRuby on Windows (#4), and a shell command that exits at once hanging ProcessSample on Windows (#5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions