Commit 9837cff
Cache pid via os.register_at_fork to spare aarch64 vDSO miss on hot path
os.getpid() is a vDSO syscall on x86-64 Linux (~30 ns/call) but not
on aarch64 Linux (~700 ns/call). Cycle 20's fork guard added the
syscall to every public method on Connection / DqliteConnection /
ConnectionPool / ClusterClient — on aarch64 each cursor.execute()
or pool.acquire() pays ~1.4 µs of pure syscall overhead.
Cache the pid in a module-level int (``dqliteclient.connection.
_current_pid``) and refresh on fork via
``os.register_at_fork(after_in_child=...)``, which Python guarantees
runs in the child before user code resumes. Public-method checks
become a Python int-equality (~10 ns) regardless of arch.
Migrate every fork-pid check site (DqliteConnection ×2,
ConnectionPool ×3, ClusterClient ×1) to read the cache. The dbapi
sync + async sides import the cache from the client module as the
single source of truth; that keeps a single register_at_fork hook
covering the whole stack and avoids drift if a future arch
refresher is needed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bb853ff commit 9837cff
3 files changed
Lines changed: 29 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
225 | | - | |
| 226 | + | |
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
39 | 60 | | |
40 | 61 | | |
41 | 62 | | |
| |||
1128 | 1149 | | |
1129 | 1150 | | |
1130 | 1151 | | |
1131 | | - | |
| 1152 | + | |
1132 | 1153 | | |
1133 | 1154 | | |
1134 | 1155 | | |
| |||
1311 | 1332 | | |
1312 | 1333 | | |
1313 | 1334 | | |
1314 | | - | |
| 1335 | + | |
1315 | 1336 | | |
1316 | 1337 | | |
1317 | 1338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
327 | 328 | | |
328 | 329 | | |
329 | 330 | | |
330 | | - | |
| 331 | + | |
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
| |||
679 | 680 | | |
680 | 681 | | |
681 | 682 | | |
682 | | - | |
| 683 | + | |
683 | 684 | | |
684 | 685 | | |
685 | 686 | | |
| |||
1330 | 1331 | | |
1331 | 1332 | | |
1332 | 1333 | | |
1333 | | - | |
| 1334 | + | |
1334 | 1335 | | |
1335 | 1336 | | |
1336 | 1337 | | |
| |||
0 commit comments