duel-postgresql 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bef0bbe4c1ac2f94456bac51aaec91704c843192e5455ad9e8df674deb81dea3
4
- data.tar.gz: c66d907b9d22d687e425c5e4078465e7ec19c2155d1a457403d54fd3831e381a
3
+ metadata.gz: efb68757315133b5c6babbf6d316c42903ecacacd647d06bcf3d8a21348fb2cd
4
+ data.tar.gz: b9799a52a06341d5b4c28ed7bd604cee3e618032c9a24b9be79d6532b1ae610d
5
5
  SHA512:
6
- metadata.gz: adeee8f3edcd810eda25673621c6019ecee27a17d6fb0ce4ecc82e2a85a249df315413743b59deca573076ffd657fe73422f526549986f498b799ac19ee7d502
7
- data.tar.gz: 46503043f91a56cd3554b415ed3d479fa7b25cc9da2b8175da134ff493e68c1f571e81ea8515c7576c56379f25e0333d57a7fd6dffbde29224d12edbc7841780
6
+ metadata.gz: 8140e55bb75620e90460132955beeb6d354da031e43e2106cc8b25718e81b21f06d31392bb2133628056ac90b6b75fe71132544f09592f6a6c3161faba5cd00c
7
+ data.tar.gz: f35d48e929952393bc44216dac73d6383b4dbc92bfcbd417c667dd2c606b83c79be093d52d99fea5001e8e56b131db0c8120731d6835f812307bb88e242fc786
data/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.1] - 2026-11-22
11
+
12
+ ### Fixed
13
+
14
+ - On macOS, a comparison no longer runs more workers' servers at once
15
+ than there are System V shared memory segments for. Each postgres
16
+ takes one, and macOS allows 32 in all, so Duel's 12 workers of each
17
+ version, 24 servers, failed now and then with "could not create
18
+ shared memory segment: No space left on device" before measuring
19
+ anything (on a GitHub Actions macOS runner, say). The plugin tells
20
+ Duel (as its `worker_limit`, with Duel 0.3.1 or later) to run no
21
+ more of them at once than half of the segments not in use: 16 on a
22
+ machine with none in use, so 1 benchmark at a time of 8 workers of
23
+ each version. That's a margin, not a count: 24 servers fit, as a
24
+ rule, but the servers that start and stop beside them took the rest
25
+ once. Where a worker's server can't make its segment anyway, it fails
26
+ saying to run fewer workers (`--processes`, `DUEL_PROCESSES` or
27
+ `c.processes`, and `--jobs`), not only that postgres exited before it
28
+ was ready.
29
+
10
30
  ## [0.3.0] - 2026-11-20
11
31
 
12
32
  ### Changed
@@ -158,7 +178,8 @@ later, with `pg_stat_statements`.
158
178
  CI.
159
179
  - RBS signatures in sig/, checked with Steep.
160
180
 
161
- [Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.3.0...HEAD
181
+ [Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.3.1...HEAD
182
+ [0.3.1]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.3.0...duel-postgresql-v0.3.1
162
183
  [0.3.0]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.2.0...duel-postgresql-v0.3.0
163
184
  [0.2.0]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.8...duel-postgresql-v0.2.0
164
185
  [0.1.8]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.7...duel-postgresql-v0.1.8
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Duel
4
4
  module PostgreSQL
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
@@ -41,6 +41,10 @@ module Duel
41
41
  # It names the socket (.s.PGSQL.5432): the server listens on no port.
42
42
  PORT = 5432
43
43
 
44
+ # What a postgres logs where it can't make its System V shared memory
45
+ # segment (see .worker_limit).
46
+ NO_SEGMENT = "could not create shared memory segment"
47
+
44
48
  # The server's settings: nothing to disk that needn't be, nothing
45
49
  # running on its own (autovacuum would change what a query touches,
46
50
  # and its plan, while it's measured), and pg_stat_statements.
@@ -107,7 +111,16 @@ module Duel
107
111
  # Rails parses DATABASE_URL with, takes a user without a host for
108
112
  # a malformed host.)
109
113
  url = "postgres:///#{DATABASE}?host=#{host}&port=#{port}&user=#{USER}"
110
- w.wait_until { PG::Connection.ping(url) == PG::PQPING_OK }
114
+ begin
115
+ w.wait_until { PG::Connection.ping(url) == PG::PQPING_OK }
116
+ rescue Failed
117
+ # (Its log, which pg_ctl writes too, is there by then.)
118
+ log = w.path("postgres.log")
119
+ raise unless File.read(log).include?(NO_SEGMENT)
120
+
121
+ w.fail!("postgres couldn't make its System V shared memory segment, which each server takes one of (macOS allows 32 in all): " \
122
+ "run fewer workers at once (--processes, DUEL_PROCESSES or c.processes, and --jobs)", log:)
123
+ end
111
124
  run(url, sql) if sql
112
125
  {URL => url, "PGHOST" => host, "PGPORT" => port.to_s, "PGUSER" => USER, "PGDATABASE" => DATABASE}
113
126
  .merge(env.to_h { |name| [name, url] })
@@ -122,6 +135,30 @@ module Duel
122
135
  connection
123
136
  end
124
137
 
138
+ # The most workers whose servers can run at once (see Duel.plugin),
139
+ # where there are few System V shared memory segments to go around: a
140
+ # postgres takes one (to tell whether another runs on its data), and
141
+ # one that can't make one doesn't start. macOS allows 32 in all
142
+ # (kern.sysv.shmmni), so it's half of those not in use: the servers
143
+ # that start and stop beside the workers' (the one that builds the
144
+ # cluster, those Runner#fit starts to see what a worker takes, one
145
+ # stopping, or killed, whose segment stays) can take more than a few,
146
+ # and 24 servers of 32 segments ran out on a GitHub runner. nil
147
+ # elsewhere: Linux's sysctl has no kern.sysv.shmmni (it allows
148
+ # thousands), and Windows' postgres takes none.
149
+ def self.worker_limit
150
+ segments = Integer(command(%w[sysctl -n kern.sysv.shmmni]), exception: false) or return
151
+ used = command(%w[ipcs -m]).lines.count { |line| line.start_with?("m ") }
152
+ (segments - used) / 2
153
+ end
154
+
155
+ # What +command+ printed, or nothing where it isn't there to run.
156
+ def self.command(command)
157
+ IO.popen(command, err: File::NULL, &:read)
158
+ rescue SystemCallError
159
+ ""
160
+ end
161
+
125
162
  # Loads pg, once Duel has loaded the worker's version: not as the
126
163
  # plugin loads, in .duel.rb, before it. In pg's own repository, pg is
127
164
  # what's measured, and the worker would load whichever pg the load
@@ -12,6 +12,10 @@ module Duel
12
12
  # It names the socket: the server listens on no port.
13
13
  PORT: Integer
14
14
 
15
+ # What a postgres logs where it can't make its System V shared memory
16
+ # segment.
17
+ NO_SEGMENT: String
18
+
15
19
  # The server's settings.
16
20
  SETTINGS: Hash[String, String]
17
21
 
@@ -29,6 +33,14 @@ module Duel
29
33
 
30
34
  def self.column_types: () -> ::PG::TypeMapByColumn
31
35
 
36
+ # The most workers whose servers can run at once, where there are few
37
+ # System V shared memory segments (macOS's 32): half of those not in
38
+ # use. nil elsewhere.
39
+ def self.worker_limit: () -> Integer?
40
+
41
+ # What +command+ printed, or nothing where it isn't there to run.
42
+ def self.command: (Array[String] command) -> String
43
+
32
44
  # Loads pg, once Duel has loaded the worker's version.
33
45
  def self.require_pg: () -> bool
34
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duel-postgresql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Berlin