Commit 824265a
authored
feat(ipc): Implement Backpressure Detection with Unit Tests (#68)
* feat(ipc): Implement backpressure detection and warnings
This commit introduces a backpressure detection mechanism across all IPC transport types to provide better diagnostics during long-running or high-throughput benchmarks.
When a transport's underlying buffer becomes full, send operations can block or slow down, impacting performance metrics. This feature detects such scenarios and issues a one-time warning to the user, helping them understand if their benchmark is measuring pure transport speed or a backpressure-limited scenario.
Implementation Details:
- The IpcTransport::send method signature has been changed to return a Result<bool>, where true indicates that backpressure was detected during the send operation.
- For Shared Memory, backpressure is detected when the ring buffer is full, causing the send operation to retry.
- For TCP and Unix Domain Sockets, backpressure is detected heuristically by timing the send call. An unusually long duration suggests the OS send buffer is full and the call was blocked.
- For POSIX Message Queues, backpressure is detected when a send operation returns an EAGAIN error, indicating a full queue.
- The benchmark runner has been updated to handle the new send signature.
AI-assisted-by: Gemini 2.5 Pro
feat(ipc): Add unit tests for backpressure detection
This commit introduces unit tests for the backpressure detection
feature across all IPC transport types. These tests validate that
backpressure is correctly identified when buffers or queues become full.
Key changes:
- Added `test_shared_memory_backpressure` to verify backpressure
detection in the shared memory transport.
- Added `test_tcp_socket_backpressure` to test the heuristic-based
backpressure detection in TCP sockets.
- Added `test_uds_backpressure` for Unix Domain Sockets, which uses a
similar heuristic to TCP.
- Added `test_pmq_backpressure` to ensure backpressure is detected
when the POSIX Message Queue is full.
Additionally, the core logic for stream-based transports (TCP and UDS)
has been improved to use timeouts on send operations. This prevents
tests from hanging and provides a more robust backpressure signal. A
custom `IpcError::BackpressureTimeout` is now returned when a send
operation times out due to a full buffer, making the behavior
consistent across all transport types.
AI-assisted-by: Gemini 2.5 Pro
docs(ipc): Document backpressure detection feature
This commit
updates the documentation to reflect the new backpressure detection and warning
mechanism.
Key changes include:
- Updated doc comments for the \IpcTransport::send\ method and the new
\IpcError::BackpressureTimeout\ variant to explain the behavior.
- Added doc comments to each transport's \send\ implementation detailing its specific
backpressure detection strategy.
- Added a "Backpressure Warnings" section to the \README.md\ to help users interpret
benchmark results correctly.
- Updated \CONTRIBUTING.md\ to require that new transport implementations include
backpressure detection logic.
AI-assisted-by: Gemini 2.5 Pro
* remove errant added AGENTS.md file1 parent a3fa17d commit 824265a
10 files changed
Lines changed: 634 additions & 60 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
123 | 132 | | |
124 | 133 | | |
125 | 134 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
349 | 363 | | |
350 | 364 | | |
351 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | | - | |
| 685 | + | |
686 | 686 | | |
687 | 687 | | |
688 | 688 | | |
| |||
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
719 | | - | |
| 719 | + | |
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
862 | | - | |
| 862 | + | |
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
| |||
911 | 911 | | |
912 | 912 | | |
913 | 913 | | |
914 | | - | |
| 914 | + | |
915 | 915 | | |
916 | 916 | | |
917 | 917 | | |
| |||
1231 | 1231 | | |
1232 | 1232 | | |
1233 | 1233 | | |
1234 | | - | |
| 1234 | + | |
1235 | 1235 | | |
1236 | 1236 | | |
1237 | 1237 | | |
| |||
1292 | 1292 | | |
1293 | 1293 | | |
1294 | 1294 | | |
1295 | | - | |
| 1295 | + | |
1296 | 1296 | | |
1297 | 1297 | | |
1298 | 1298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
71 | 87 | | |
72 | 88 | | |
73 | 89 | | |
| |||
471 | 487 | | |
472 | 488 | | |
473 | 489 | | |
474 | | - | |
| 490 | + | |
475 | 491 | | |
476 | 492 | | |
477 | 493 | | |
478 | 494 | | |
479 | 495 | | |
480 | 496 | | |
481 | 497 | | |
482 | | - | |
| 498 | + | |
483 | 499 | | |
484 | 500 | | |
485 | 501 | | |
| |||
644 | 660 | | |
645 | 661 | | |
646 | 662 | | |
647 | | - | |
| 663 | + | |
| 664 | + | |
648 | 665 | | |
649 | 666 | | |
650 | 667 | | |
| |||
0 commit comments