Commit ce07c11
committed
Add daemon proxy for php-fpm multi-process support
Stoolap uses exclusive file locking, so only one OS process can open a
database at a time. This adds a transparent daemon proxy that auto-forks
when loaded under php-fpm/CGI/Apache, allowing all worker processes to
share database access through shared memory IPC.
Architecture:
- Daemon auto-forks from php-fpm master on first load
- Per-connection 8MB shared memory (request + response buffers)
- Cache-line-split control block eliminates false sharing
- Spin-then-wait: fast spin phase catches sub-μs responses,
futex (Linux) / __ulock (macOS) for blocking without CPU burn
- Elastic thread pool (8 initial, grows to 64) with 256KB stacks
- Per-PID socket paths for isolation between fpm instances
- Auto-lifecycle: daemon exits when php-fpm master dies
IPC overhead (bare-metal Linux x86_64):
- 0.2μs bare roundtrip (futex)
- 0.9μs SELECT by primary key through daemon
- Sub-2μs for prepared statement execute/query
Zero configuration required - works out of the box.
139 tests pass in both direct and daemon modes.1 parent e4b8b73 commit ce07c11
File tree
7 files changed
+3760
-347
lines changed- ext
- tests
7 files changed
+3760
-347
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
362 | 397 | | |
363 | 398 | | |
364 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 40 | + | |
43 | 41 | | |
44 | 42 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 28 | + | |
64 | 29 | | |
65 | 30 | | |
0 commit comments