Skip to content

Test: probe macOS runners' shared memory - #4

Closed
sferik wants to merge 5 commits into
shm-probe-basefrom
shm-probe
Closed

sferik wants to merge 5 commits into
shm-probe-basefrom
shm-probe

Conversation

@sferik

@sferik sferik commented Nov 20, 2026

Copy link
Copy Markdown
Owner

A throwaway test of the macOS runner's System V shared memory limits. I'll close it once it runs.

Duel (https://github.com/sferik/duel-ruby) runs the benchmarks in duel/
on the branch and on master side by side, and fails a pull request that
is slower or allocates more. The 44 benchmarks cover queries over a
socket to a PostgreSQL server of each worker's own (exec, exec_params,
exec_prepared, COPY in and out), reading results in memory (values,
getvalue, each, each_row, tuples, field names), the type maps, the text
and binary coders on their own, escaping, and parsing connection
parameters.

Each version compiles its own extension (c.build). The duel-postgresql
plugin needs a released pg, so Duel is in an optional Gemfile group.

Checked by comparing master with itself three times, and with planted
regressions: the Integer decoder without its fast path failed 6
benchmarks on instructions, and an extra rb_str_dup in the String
decoder failed 13 on allocations.
pg's code paths differ by system, and Linux's was the only one Duel
measured. The Perf workflow runs on Linux, macOS and Windows now, each
saying what it found in a report of its own, and the Perf comment
workflow comments with all three.

On Linux and macOS, it calls Duel 0.2.0's reusable workflow, so the
copy of its steps is gone. It grants contents: write, which GitHub
checks every job of the reusable workflow against, though none of the
jobs that write is turned on here, and the Duel job still only reads.
The reusable workflow's steps are Unix shell's, so the Windows job runs
the same ones itself, in bash, with what pg's build needs there as
source-gem.yml has it (MSYS2's gcc, and PostgreSQL's binaries, for
libpq). Its servers are the runner's own PostgreSQL's, whose initdb
drops the rights of the runner's user, an administrator, as postgres
needs: the binaries' doesn't. The Perf comment workflow calls Duel's
reusable one too.
Duel 0.3.0's reusable workflow runs on Windows (its steps in bash,
with setup-after-ruby for what needs Ruby's devkit), so the Windows
job is a call of it like Linux's and macOS's, in place of a copy of
its steps: setup downloads PostgreSQL's binaries, for libpq, and
names the runner's own postgres, in PGBIN, for the servers
(DUEL_POSTGRESQL_SERVER, as duel-postgresql 0.3.0 names what was
DUEL_POSTGRESQL_BIN, a directory), and setup-after-ruby installs
MSYS2's gcc and puts the devkit's directories, then libpq's, on the
PATH.

Each Duel job grants contents: read alone, now that the jobs that
write for a push are a reusable workflow of Duel's own, which each
platform's push calls, with its report. And the Duel jobs no longer
take accept-label, as Duel reads it from .duel.rb itself. The
Gemfile's optional group asks for Duel 0.3.0 and duel-postgresql
0.3.0.

.duel.rb leaves the build (bundle exec rake compile, which Duel 0.3.0
runs by default for a project with ext/ and a Rakefile) and the accept
label (duel: accept, its default too) to Duel, showing each commented
out, as the .duel.rb duel init writes now does. And the README shows
Duel's badge with the other build badges, linked to the Perf
workflow's runs.
Each worker's PostgreSQL server takes a System V shared memory
segment, and macOS allows 32 in all. With Duel's 12 workers of each
version, 24 servers, and those that build their clusters, are at that
limit, and a server that can't make its segment doesn't start: the
macOS job failed before measuring with "could not create shared memory
segment: No space left on device":
https://github.com/ged/ruby-pg/actions/runs/44777546632/job/136595330712

With 6 workers of each version (DUEL_PROCESSES), the macOS job runs 12
servers, well under the limit.
@sferik

sferik commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Done: it ran.

@sferik sferik closed this Nov 20, 2026
@sferik
sferik deleted the shm-probe branch November 20, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant