duel-postgresql 0.2.0 → 0.3.0
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 +4 -4
- data/CHANGELOG.md +32 -1
- data/README.md +31 -27
- data/lib/duel/postgresql/version.rb +1 -1
- data/lib/duel/postgresql.rb +49 -47
- data/sig/duel/postgresql.rbs +14 -13
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bef0bbe4c1ac2f94456bac51aaec91704c843192e5455ad9e8df674deb81dea3
|
|
4
|
+
data.tar.gz: c66d907b9d22d687e425c5e4078465e7ec19c2155d1a457403d54fd3831e381a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: adeee8f3edcd810eda25673621c6019ecee27a17d6fb0ce4ecc82e2a85a249df315413743b59deca573076ffd657fe73422f526549986f498b799ac19ee7d502
|
|
7
|
+
data.tar.gz: 46503043f91a56cd3554b415ed3d479fa7b25cc9da2b8175da134ff493e68c1f571e81ea8515c7576c56379f25e0333d57a7fd6dffbde29224d12edbc7841780
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-11-20
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `postgresql_blocks`' settings say `size_samples: false`, as Duel 0.3.0
|
|
15
|
+
names `sizes_samples:`.
|
|
16
|
+
- Its measures are named after the plugin, as every other Duel
|
|
17
|
+
plugin's are (`mysql_*`, `redis_*`): `postgresql_queries`,
|
|
18
|
+
`postgresql_rows`, `postgresql_blocks` and `postgresql_time`, in
|
|
19
|
+
place of `postgres_queries`, `postgres_rows`, `postgres_blocks` and
|
|
20
|
+
`postgres_time`. A `.duel.rb` that tunes one
|
|
21
|
+
(`c.measure("postgres_time", limit: 1.1)`) needs the new name.
|
|
22
|
+
- `sql:` is what each worker's database runs once its server starts
|
|
23
|
+
(a schema, say), in place of `setup:`, which is a hook's name
|
|
24
|
+
everywhere else in Duel.
|
|
25
|
+
- `server:` names the server to run, its `postgres` (a path, or a name
|
|
26
|
+
on the `PATH`), as the other server plugins' `server:` does, in place
|
|
27
|
+
of `bin:`, its directory, and `DUEL_POSTGRESQL_SERVER` in place of
|
|
28
|
+
`DUEL_POSTGRESQL_BIN`. Its other programs (`initdb`, `pg_ctl`) are
|
|
29
|
+
next to it.
|
|
30
|
+
- `tcp: true` starts each worker's server on a port of 127.0.0.1's
|
|
31
|
+
alone, with no Unix socket, as the other server plugins' does, and is
|
|
32
|
+
the default on Windows. It was a side effect of `pg_ctl: true`, which
|
|
33
|
+
only says what starts the server now.
|
|
34
|
+
- `server:` is found by Duel's `Duel.find_program`, as duel-mysql's
|
|
35
|
+
is: one with a `\` in it is a path off Windows too, and a name on the
|
|
36
|
+
`PATH` is taken as it is as well as with `.exe`.
|
|
37
|
+
- It requires Duel 0.3.0 or later (`~> 0.3.0`), the release it's
|
|
38
|
+
tested with, as Duel 0.3.0 changes what plugins and benchmarks call.
|
|
39
|
+
|
|
10
40
|
## [0.2.0] - 2026-11-16
|
|
11
41
|
|
|
12
42
|
### Added
|
|
@@ -128,7 +158,8 @@ later, with `pg_stat_statements`.
|
|
|
128
158
|
CI.
|
|
129
159
|
- RBS signatures in sig/, checked with Steep.
|
|
130
160
|
|
|
131
|
-
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.
|
|
161
|
+
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.3.0...HEAD
|
|
162
|
+
[0.3.0]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.2.0...duel-postgresql-v0.3.0
|
|
132
163
|
[0.2.0]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.8...duel-postgresql-v0.2.0
|
|
133
164
|
[0.1.8]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.7...duel-postgresql-v0.1.8
|
|
134
165
|
[0.1.7]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.6...duel-postgresql-v0.1.7
|
data/README.md
CHANGED
|
@@ -10,10 +10,10 @@ every benchmark is judged on what PostgreSQL did for it too.
|
|
|
10
10
|
|
|
11
11
|
| Metric | What it is | A regression |
|
|
12
12
|
|---|---|---|
|
|
13
|
-
| `
|
|
14
|
-
| `
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
13
|
+
| `postgresql_queries` | the statements it ran (`BEGIN` and `COMMIT` too) | any increase |
|
|
14
|
+
| `postgresql_rows` | the rows they returned or changed | any increase |
|
|
15
|
+
| `postgresql_blocks` | the shared buffer blocks they touched, cached or not | judged like CPU time |
|
|
16
|
+
| `postgresql_time` | the time it spent planning and running them, in µs | judged like CPU time |
|
|
17
17
|
|
|
18
18
|
So a change that adds a query per record (an N+1), or fetches rows it
|
|
19
19
|
doesn't use, fails even when its CPU time on the Ruby side doesn't
|
|
@@ -25,19 +25,19 @@ on paired ratios, not counted.
|
|
|
25
25
|
A regression says which statements did it: under each version's
|
|
26
26
|
numbers, the three that did the most of that measure (Duel's
|
|
27
27
|
`details`), with how many times each ran an iteration for
|
|
28
|
-
`
|
|
28
|
+
`postgresql_queries`, and their shares of it for the rest:
|
|
29
29
|
|
|
30
30
|
```
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
postgresql_queries: 2 queries → 6 queries an iteration
|
|
32
|
+
postgresql_queries (candidate): an iteration: 5× SELECT count(*) FROM comments WHERE post_id = $1; 1× SELECT * FROM posts
|
|
33
|
+
postgresql_queries (baseline): an iteration: 1× SELECT * FROM comments WHERE post_id = ANY($1); 1× SELECT * FROM posts
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
They're of the sample the numbers came from, but for its `untimed`
|
|
37
37
|
blocks, if it has any. Queries, rows and blocks are counted in their
|
|
38
38
|
units (`1 query`, `12 rows`, though the summary line leaves out the one
|
|
39
|
-
a name ends in: `
|
|
40
|
-
(`
|
|
39
|
+
a name ends in: `postgresql_rows 12→40`), and `postgresql_time` is
|
|
40
|
+
shown as time (`postgresql_time: 412µs → 1.31ms an iteration`).
|
|
41
41
|
|
|
42
42
|
## Installation
|
|
43
43
|
|
|
@@ -63,10 +63,11 @@ Duel.configure { |c| c.use :postgresql }
|
|
|
63
63
|
`c.use` requires the plugin, so `.duel.rb` doesn't need to.
|
|
64
64
|
|
|
65
65
|
Each worker's server listens only on a Unix socket in the worker's own
|
|
66
|
-
directory (or with `
|
|
67
|
-
|
|
68
|
-
won't run with an administrator's rights, which
|
|
69
|
-
nothing written to disk that needn't be,
|
|
66
|
+
directory (or with `tcp: true`, as by default on Windows, on a port of
|
|
67
|
+
127.0.0.1's alone). On Windows, `pg_ctl` starts and stops it, as
|
|
68
|
+
`postgres` won't run there with an administrator's rights, which
|
|
69
|
+
`pg_ctl` drops. It runs with nothing written to disk that needn't be,
|
|
70
|
+
and no
|
|
70
71
|
autovacuum (which would change what a query reads, and its plan, while
|
|
71
72
|
it's measured). Its URL is in `DUEL_POSTGRESQL_URL`, and in
|
|
72
73
|
`DATABASE_URL` too, and libpq's `PGHOST`, `PGPORT`, `PGUSER` and
|
|
@@ -96,11 +97,12 @@ Options:
|
|
|
96
97
|
|
|
97
98
|
```ruby
|
|
98
99
|
c.use :postgresql,
|
|
99
|
-
|
|
100
|
-
settings: {work_mem: "64MB"},
|
|
101
|
-
|
|
102
|
-
env: %w[DATABASE_URL PRIMARY_URL],
|
|
103
|
-
|
|
100
|
+
server: "/usr/lib/postgresql/17/bin/postgres", # its postgres, initdb next to it (default: DUEL_POSTGRESQL_SERVER, or postgres)
|
|
101
|
+
settings: {work_mem: "64MB"}, # more of its settings, as work_mem=64MB (they win)
|
|
102
|
+
sql: File.read("db/structure.sql"), # SQL each worker's database runs first
|
|
103
|
+
env: %w[DATABASE_URL PRIMARY_URL], # variables given its URL besides DUEL_POSTGRESQL_URL (default: DATABASE_URL)
|
|
104
|
+
tcp: true, # on a port of 127.0.0.1's, not a Unix socket (default: on Windows only)
|
|
105
|
+
pg_ctl: true # started by pg_ctl (default: on Windows only)
|
|
104
106
|
```
|
|
105
107
|
|
|
106
108
|
> [!WARNING]
|
|
@@ -109,16 +111,18 @@ c.use :postgresql,
|
|
|
109
111
|
> fail, so give one of them other names (`env: %w[PRIMARY_URL]`, or
|
|
110
112
|
> `env: []`).
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
Its other programs (`initdb`, `pg_ctl`) are the ones in the directory
|
|
115
|
+
of its `postgres` (`server:`, found as every Duel plugin finds its
|
|
116
|
+
server, by `Duel.find_program`), links followed (Homebrew's `initdb` on
|
|
117
|
+
the `PATH` may be libpq's, of another version). For a name that isn't
|
|
118
|
+
on the `PATH`, they're Debian's newest, under `/usr/lib/postgresql`.
|
|
115
119
|
|
|
116
120
|
A database cluster takes `initdb`, and that's slow, so it's done once
|
|
117
121
|
(Duel's `w.cached`): the first worker to start makes one, with the
|
|
118
122
|
`duel` database and `pg_stat_statements` created in it, in your
|
|
119
123
|
project's `tmp/duel/cache`, and every worker (in that run and the next
|
|
120
124
|
ones) starts with a copy. One is made for each server's programs (and
|
|
121
|
-
version of the plugin): another PostgreSQL gets its own. `duel
|
|
125
|
+
version of the plugin): another PostgreSQL gets its own. `duel clean`
|
|
122
126
|
deletes them.
|
|
123
127
|
|
|
124
128
|
The metrics come from `pg_stat_statements`, which PostgreSQL updates as
|
|
@@ -128,17 +132,17 @@ over a connection of the plugin's own, opened as each worker starts
|
|
|
128
132
|
`c.metric`). `c.use` returns that connection, for a `.duel.rb` that
|
|
129
133
|
reads the server too (`connection.value`, in a worker only). The
|
|
130
134
|
reading's own statement is left out (by its query id), so there's
|
|
131
|
-
nothing to take away (`calibrate: false`). `
|
|
135
|
+
nothing to take away (`calibrate: false`). `postgresql_time` counts
|
|
132
136
|
planning too (`pg_stat_statements.track_planning`), as a change that
|
|
133
137
|
stops reusing prepared statements plans every time. Up to 10,000
|
|
134
138
|
distinct statements are kept: a benchmark that makes more (with `IN`
|
|
135
139
|
lists of every length, say) loses the oldest, and its counts with them.
|
|
136
140
|
|
|
137
|
-
`
|
|
141
|
+
`postgresql_time` is the server's time on the clock, not CPU time, and
|
|
138
142
|
another process's, so what else the machine does shows in it: it's
|
|
139
143
|
judged for each benchmark, but left out of Duel's across-the-board
|
|
140
144
|
check (`across: false`), whose margin is a quarter of its limit.
|
|
141
145
|
|
|
142
146
|
Like any measure, each can be tuned or left out in `.duel.rb`:
|
|
143
|
-
`c.measure("
|
|
144
|
-
`c.measure("
|
|
147
|
+
`c.measure("postgresql_time", limit: 1.1)`,
|
|
148
|
+
`c.measure("postgresql_rows", skip: true)`.
|
data/lib/duel/postgresql.rb
CHANGED
|
@@ -3,19 +3,18 @@
|
|
|
3
3
|
require "duel"
|
|
4
4
|
require "digest"
|
|
5
5
|
require "fileutils"
|
|
6
|
-
require "rbconfig"
|
|
7
6
|
require_relative "postgresql/version"
|
|
8
7
|
|
|
9
8
|
module Duel
|
|
10
9
|
# A PostgreSQL server of each worker's own, and what it did for each
|
|
11
10
|
# benchmark, from pg_stat_statements:
|
|
12
11
|
#
|
|
13
|
-
# -
|
|
14
|
-
# -
|
|
15
|
-
# -
|
|
12
|
+
# - postgresql_queries: the statements it ran (counted)
|
|
13
|
+
# - postgresql_rows: the rows they returned or changed (counted)
|
|
14
|
+
# - postgresql_blocks: the shared buffer blocks they touched, from the
|
|
16
15
|
# cache or not (judged like CPU time: nearly steady, but a table
|
|
17
16
|
# that grows, say, takes more)
|
|
18
|
-
# -
|
|
17
|
+
# - postgresql_time: the time it spent planning and running them, in
|
|
19
18
|
# microseconds (judged like CPU time)
|
|
20
19
|
#
|
|
21
20
|
# Where one regressed, it says which statements did the most of it, on
|
|
@@ -65,51 +64,51 @@ module Duel
|
|
|
65
64
|
TCP = {"listen_addresses" => "127.0.0.1", "unix_socket_directories" => ""}.freeze
|
|
66
65
|
|
|
67
66
|
# Configures Duel for the plugin (c.use :postgresql): the server and
|
|
68
|
-
# its metrics. +
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
#
|
|
67
|
+
# its metrics. +server+ is its postgres (a name on the PATH, or a
|
|
68
|
+
# path), whose directory has its other programs (initdb and pg_ctl),
|
|
69
|
+
# +settings+ more of its settings, +sql+ what each worker's database
|
|
70
|
+
# runs when it's started (a schema, say), and +env+ the variables
|
|
71
|
+
# given its URL besides DUEL_POSTGRESQL_URL. A cluster is initdb'd
|
|
72
|
+
# once (Resource#cached), and each worker's is a copy.
|
|
74
73
|
#
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
#
|
|
78
|
-
#
|
|
74
|
+
# Each worker's server listens on a Unix socket in its directory, or
|
|
75
|
+
# with +tcp+ (by default where there are no Unix sockets: Windows), on
|
|
76
|
+
# a port of 127.0.0.1's alone. With +pg_ctl+ (by default on Windows),
|
|
77
|
+
# it's started (and stopped) by pg_ctl: on Windows, postgres won't run
|
|
78
|
+
# with an administrator's rights (CI's runners have them), which
|
|
79
|
+
# pg_ctl drops.
|
|
79
80
|
#
|
|
80
81
|
# Returns the plugin's own connection to it, a worker's (see
|
|
81
82
|
# Config#in_worker, and in tests, Duel::Testing.in_worker).
|
|
82
|
-
def self.configure(config,
|
|
83
|
-
pg_ctl: Duel.windows?)
|
|
83
|
+
def self.configure(config, server: ENV.fetch("DUEL_POSTGRESQL_SERVER", "postgres"), settings: {}, sql: nil, env: %w[DATABASE_URL],
|
|
84
|
+
tcp: !Duel.unix_sockets?, pg_ctl: Duel.windows?)
|
|
84
85
|
config.prepare(:worker) do |w|
|
|
85
86
|
require_pg
|
|
86
|
-
programs =
|
|
87
|
-
w.
|
|
87
|
+
programs = Cluster.programs(server) ||
|
|
88
|
+
w.fail!("no #{server}#{" on the PATH" unless Duel.path?(server)} (give postgres's path as server:, or DUEL_POSTGRESQL_SERVER)")
|
|
88
89
|
data = w.path("data")
|
|
89
90
|
cluster = Cluster.new(w, programs, pg_ctl: pg_ctl)
|
|
90
91
|
cluster.create(data)
|
|
92
|
+
host, port, listen = tcp ? ["127.0.0.1", w.free_port, TCP] : [w.dir, PORT, {"unix_socket_directories" => w.dir}]
|
|
93
|
+
# (+settings+' last: of a setting given twice, postgres takes the
|
|
94
|
+
# last.)
|
|
95
|
+
all = SETTINGS.merge(listen, "port" => port).merge(settings)
|
|
91
96
|
if pg_ctl
|
|
92
|
-
host = "127.0.0.1"
|
|
93
|
-
port = w.port
|
|
94
97
|
# (Its settings in its postgresql.conf, as pg_ctl takes no
|
|
95
|
-
# others whole.
|
|
96
|
-
cluster.start(data,
|
|
98
|
+
# others whole.)
|
|
99
|
+
cluster.start(data, all)
|
|
97
100
|
w.at_stop { cluster.stop(data) }
|
|
98
101
|
else
|
|
99
|
-
host = w.dir
|
|
100
|
-
port = PORT
|
|
101
102
|
# (Stopped by INT: its clients are disconnected, not waited for, as
|
|
102
103
|
# TERM would.)
|
|
103
|
-
|
|
104
|
-
w.spawn(File.join(programs, "postgres"), "-D", data, "-k", w.dir, "-p", PORT.to_s,
|
|
105
|
-
*SETTINGS.merge(settings).flat_map { |name, value| ["-c", "#{name}=#{value}"] }, stop_signal: "INT")
|
|
104
|
+
w.spawn(File.join(programs, "postgres"), "-D", data, *all.flat_map { |name, value| ["-c", "#{name}=#{value}"] }, stop_signal: "INT")
|
|
106
105
|
end
|
|
107
106
|
# (The user in the query, with no authority at all: Ruby's URI, which
|
|
108
107
|
# Rails parses DATABASE_URL with, takes a user without a host for
|
|
109
108
|
# a malformed host.)
|
|
110
109
|
url = "postgres:///#{DATABASE}?host=#{host}&port=#{port}&user=#{USER}"
|
|
111
110
|
w.wait_until { PG::Connection.ping(url) == PG::PQPING_OK }
|
|
112
|
-
run(url,
|
|
111
|
+
run(url, sql) if sql
|
|
113
112
|
{URL => url, "PGHOST" => host, "PGPORT" => port.to_s, "PGUSER" => USER, "PGDATABASE" => DATABASE}
|
|
114
113
|
.merge(env.to_h { |name| [name, url] })
|
|
115
114
|
end
|
|
@@ -151,10 +150,10 @@ module Duel
|
|
|
151
150
|
# too small for it. Its readings leave themselves out (STATEMENTS), so
|
|
152
151
|
# there's nothing to take away.
|
|
153
152
|
METRICS = {
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
153
|
+
"postgresql_queries" => {kind: :counted, unit: %w[query queries], calibrate: false},
|
|
154
|
+
"postgresql_rows" => {kind: :counted, unit: %w[row rows], calibrate: false},
|
|
155
|
+
"postgresql_blocks" => {kind: :timed, unit: %w[block blocks], floor: 100, size_samples: false},
|
|
156
|
+
"postgresql_time" => {kind: :timed, unit: "µs", floor: 300, across: false}
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
# What the worker's server has done so far, by statement (query id),
|
|
@@ -286,7 +285,7 @@ module Duel
|
|
|
286
285
|
# A statement's numbers, or several's added up, by measure (time in
|
|
287
286
|
# µs).
|
|
288
287
|
def self.by_measure(numbers)
|
|
289
|
-
NAMES.each_with_index.to_h { |name, i| [name, (name == "
|
|
288
|
+
NAMES.each_with_index.to_h { |name, i| [name, (name == "postgresql_time") ? numbers.fetch(i).fdiv(1000) : numbers.fetch(i)] }
|
|
290
289
|
end
|
|
291
290
|
|
|
292
291
|
# Read over +connection+, the plugin's own (a worker's).
|
|
@@ -393,18 +392,20 @@ module Duel
|
|
|
393
392
|
# A worker's database cluster: a copy of one initdb'd once, with the
|
|
394
393
|
# database and pg_stat_statements created in it.
|
|
395
394
|
class Cluster
|
|
396
|
-
#
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
# The
|
|
400
|
-
# the
|
|
401
|
-
#
|
|
402
|
-
#
|
|
403
|
-
|
|
404
|
-
|
|
395
|
+
# Debian's programs, by version (/usr/lib/postgresql/17/bin).
|
|
396
|
+
DEBIAN = "/usr/lib/postgresql/*/bin"
|
|
397
|
+
|
|
398
|
+
# The directory of +server+'s programs (see PostgreSQL.configure):
|
|
399
|
+
# the real directory, links followed, of the postgres
|
|
400
|
+
# Duel.find_program finds, a path's or a name's on +path+ (where its
|
|
401
|
+
# initdb is: the one on the PATH may be another version's, libpq's,
|
|
402
|
+
# say), or for a name it doesn't find, the newest Debian's
|
|
403
|
+
# (+debian+). Nil if there's none.
|
|
404
|
+
def self.programs(server, path = ENV.fetch("PATH", ""), debian: DEBIAN)
|
|
405
|
+
postgres = Duel.find_program(server, path)
|
|
405
406
|
return File.dirname(File.realpath(postgres)) if postgres
|
|
406
407
|
|
|
407
|
-
Dir[debian].max_by { |dir| File.basename(File.dirname(dir)).to_i }
|
|
408
|
+
Dir[debian].max_by { |dir| File.basename(File.dirname(dir)).to_i } unless Duel.path?(server)
|
|
408
409
|
end
|
|
409
410
|
|
|
410
411
|
# Where pg_ctl's cluster is in its build (see #make).
|
|
@@ -447,7 +448,7 @@ module Duel
|
|
|
447
448
|
begin
|
|
448
449
|
run("pg_ctl", "start", "-D", data, "-w", "-l", log)
|
|
449
450
|
rescue Failed
|
|
450
|
-
@resource.
|
|
451
|
+
@resource.fail!("postgres didn't start", log: log)
|
|
451
452
|
end
|
|
452
453
|
end
|
|
453
454
|
|
|
@@ -460,7 +461,8 @@ module Duel
|
|
|
460
461
|
# What a cluster is good for: these programs (until they change),
|
|
461
462
|
# this version of the plugin, and how it's made (with pg_ctl or not).
|
|
462
463
|
def key
|
|
463
|
-
postgres
|
|
464
|
+
# (postgres.exe, on Windows: there's one, as .programs found it.)
|
|
465
|
+
postgres = File.realpath(Duel.find_program("postgres", @bin)) # steep:ignore ArgumentTypeMismatch
|
|
464
466
|
made = [postgres, File.mtime(postgres).to_f, *(PG_CTL if @pg_ctl)]
|
|
465
467
|
"postgresql-#{VERSION}-#{Digest::SHA256.hexdigest(made.join("\0"))[0, 16]}"
|
|
466
468
|
end
|
|
@@ -483,7 +485,7 @@ module Duel
|
|
|
483
485
|
def make_with_pg_ctl(dir)
|
|
484
486
|
data = File.join(dir, PG_CTL)
|
|
485
487
|
initdb(data)
|
|
486
|
-
port = @resource.
|
|
488
|
+
port = @resource.free_port
|
|
487
489
|
start(data, TCP.merge("port" => port))
|
|
488
490
|
begin
|
|
489
491
|
url = "postgres://#{USER}@127.0.0.1:#{port}"
|
data/sig/duel/postgresql.rbs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Duel
|
|
2
2
|
# A PostgreSQL server of each worker's own, and what it did for each
|
|
3
|
-
# benchmark (
|
|
4
|
-
#
|
|
3
|
+
# benchmark (postgresql_queries, postgresql_rows, postgresql_blocks,
|
|
4
|
+
# postgresql_time).
|
|
5
5
|
module PostgreSQL
|
|
6
6
|
VERSION: String
|
|
7
7
|
|
|
@@ -39,14 +39,14 @@ module Duel
|
|
|
39
39
|
type numbers = Array[Integer]
|
|
40
40
|
|
|
41
41
|
# Configures Duel for the plugin (c.use :postgresql): the server
|
|
42
|
-
# (+
|
|
43
|
-
# settings, +
|
|
44
|
-
# +env+ the variables besides DUEL_POSTGRESQL_URL given
|
|
45
|
-
# its metrics. Returns the plugin's own connection to it, a worker's.
|
|
42
|
+
# (+server+ its postgres, its other programs next to it, +settings+
|
|
43
|
+
# more of its settings, +sql+ what each worker's database runs when
|
|
44
|
+
# it's started, +env+ the variables besides DUEL_POSTGRESQL_URL given
|
|
45
|
+
# its URL) and its metrics. Returns the plugin's own connection to it, a worker's.
|
|
46
46
|
# +pg_ctl+: started and stopped by pg_ctl, on a port of 127.0.0.1's
|
|
47
47
|
# (by default on Windows).
|
|
48
|
-
def self.configure: (Config config, ?
|
|
49
|
-
?env: Array[String], ?pg_ctl: bool) -> InWorker[::PG::Connection]
|
|
48
|
+
def self.configure: (Config config, ?server: String, ?settings: Hash[String | Symbol, String | Integer], ?sql: String?,
|
|
49
|
+
?env: Array[String], ?tcp: bool, ?pg_ctl: bool) -> InWorker[::PG::Connection]
|
|
50
50
|
|
|
51
51
|
# Runs SQL on a connection of its own to +url+; returns the last
|
|
52
52
|
# statement's result.
|
|
@@ -157,12 +157,13 @@ module Duel
|
|
|
157
157
|
# Where pg_ctl's cluster is in its build.
|
|
158
158
|
PG_CTL: String
|
|
159
159
|
|
|
160
|
-
#
|
|
161
|
-
|
|
162
|
-
# A program's file ends with +EXE+ (.exe, on Windows).
|
|
163
|
-
EXE: String
|
|
160
|
+
# Debian's programs, by version.
|
|
161
|
+
DEBIAN: String
|
|
164
162
|
|
|
165
|
-
|
|
163
|
+
# The directory of a server's programs: the real directory of the
|
|
164
|
+
# postgres at a path, or by a name on +path+, or the newest
|
|
165
|
+
# Debian's. Nil if there's none.
|
|
166
|
+
def self.programs: (String server, ?String path, ?debian: String) -> String?
|
|
166
167
|
|
|
167
168
|
def initialize: (Resource resource, String bin, ?pg_ctl: bool) -> void
|
|
168
169
|
|
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.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Berlin
|
|
@@ -16,7 +16,7 @@ dependencies:
|
|
|
16
16
|
-
|
|
17
17
|
- ~>
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 0.3.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -24,7 +24,7 @@ dependencies:
|
|
|
24
24
|
-
|
|
25
25
|
- ~>
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version:
|
|
27
|
+
version: 0.3.0
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: pg
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|