[Perf] (MG_Remote/Client): The create window's shipped depth is 6, and its ceiling 8.

This commit is contained in:
BZLZHH
2026-09-26 11:26:54 +08:00
parent 1f1ece8a33
commit 102f2ca7d5
8 changed files with 123 additions and 40 deletions
+17 -14
View File
@@ -1232,24 +1232,27 @@ TEST(RemoteClientControls, TheWindowRefusesToDeferOnALinkThatCannotRetainAnswers
Uint8 pixels[4 * 4 * 4];
std::memset(pixels, 0x21, sizeof(pixels));
// ---- the clamp and the ceiling, before a single record goes out ----
// THE WINDOW IS OPT-IN AND THE DEFAULT IS OFF (Config.h: the deferral was measured on the
// device and the drain cannot collect it), so both arms of this case SET the knob rather
// than inheriting it - the ON half below is the mechanism being exercised, not a claim
// about what ships.
// BOTH ARMS SET THE KNOB rather than inheriting it: this case is about what the code does
// with a configured window, and not a claim about which value ships (the default is 2 -
// Config.h carries the device numbers).
// WHAT THE OPERATOR WROTE IS NOT WHAT THE CODE MAY USE. With the clamp gone a configured
// window of 99 is compared against a count that the ring keeps below its own size, so the
// fallback never fires and the push index runs off the array.
MG_Config::Ipc.CreateWindow = 99;
if (ClientCreateWindowEffective() != ClientCreateWindowArraySize()) ::_exit(170);
MG_Config::Ipc.CreateWindow = 4;
if (ClientCreateWindowEffective() != 4u) ::_exit(171);
// AND THE ARRAY IS SIZED FROM THE POOL IT SHARES, not from a second literal: the pool is
// Transport::kDefaultReplySlotCount slots addressed seq % count, and every reply-owning row
// (fence, query, the blocking rows themselves) needs one. Raising the window to the whole
// pool is the change the handoff names, and it is red here as well as at the static_assert
// in WireTables.cpp - deliberately twice, because the compile-time one is the guard and
// this one is the statement of what the guard is for.
if (ClientCreateWindowArraySize() > Transport::kDefaultReplySlotCount / 2) ::_exit(172);
MG_Config::Ipc.CreateWindow = 8;
if (ClientCreateWindowEffective() != 8u) ::_exit(171);
// AND THE ARRAY IS SIZED FROM THE STORE IT SHARES, not from a second literal (P12). This
// line used to read "at most half the REPLY POOL", which was true while an answer was read
// back out of a slot pool addressed seq % slotCount - and the window does not run on such
// a link: CreateWindowEffective() is gated on ILink::RetainsReplies, false for ShmLink, so
// the pool-addressed transport holds a window of 1. On the link where it does run, an
// answer waits in the declared-answer store instead, so the bound that matters is the
// store's - read from the constant rather than restated, for the reason the pool version
// read kDefaultReplySlotCount. WireTables.cpp's static_assert is the compile-time half of
// the same sentence, deliberately twice: that one is the guard, this one is what it is for.
if (ClientCreateWindowArraySize() > Transport::StreamLink::kRetainedAnswersMax / 2)
::_exit(172);
// TWELVE OBJECTS, ONE CREATE EACH, AND THE INVARIANT READ AFTER EVERY ONE. This is the
// reading a silent overwrite cannot fake: the count stays at the ceiling while an entry is
@@ -1268,7 +1271,7 @@ TEST(RemoteClientControls, TheWindowRefusesToDeferOnALinkThatCannotRetainAnswers
};
// ---- THE KNOB IS AS HIGH AS IT GOES, AND THE ROW MUST STILL BLOCK ----
MG_Config::Ipc.CreateWindow = 4;
MG_Config::Ipc.CreateWindow = ClientCreateWindowArraySize();
const Uint64 recordsBefore = Transport::LinkMetricsRecordsFor(createOp);
const Uint64 waitsBefore = Transport::LinkMetricsReplyWaitsFor(createOp);
burst(12);
@@ -37,6 +37,9 @@
#include <MG_Remote/Client/CapsMirror.h>
#include <MG_Remote/Transport/ReplySlot.h>
#include <MG_Remote/Transport/LinkMetrics.h>
// P12: StreamLink::kRetainedAnswersMax, the store capacity RemoteClientControls' window-ceiling
// case reads instead of restating it.
#include <MG_Remote/Transport/StreamLink.h>
#include <MG_Pipe/PipeRoute.h>
#include <MG_Remote/Client/EmitTables.h>
#include <MG_Remote/Client/WireTables.h>
@@ -262,7 +262,11 @@ namespace {
TEST_F(StreamClientWindow, EveryDeferredCreateAnswerComesBackOnTheShippingArm) {
const Uint32 savedWindow = MG_Config::Ipc.CreateWindow;
MG_Config::Ipc.CreateWindow = 4;
// THE DEEPEST WINDOW THE CODE SUPPORTS, so the case exercises the ceiling rather than a
// comfortable middle: more deferred answers outstanding means more of the store spent, and
// the crowding below is what has to survive it. (The CAP itself is pinned by
// RemoteClientControls' window-ceiling case; this one pins that the answers come back.)
MG_Config::Ipc.CreateWindow = 8;
StartServo();
const std::uint64_t takenBefore = Client::ClientCreateWindowTaken();
constexpr Int32 kCreates = 24;
@@ -331,7 +335,7 @@ namespace {
EXPECT_LE(pending, Client::ClientCreateWindowEffective());
// AND THE ROW REALLY IS DEFERRING HERE, so the case cannot pass by taking the blocking
// path on every create (which is what a link the window refuses to run on looks like).
EXPECT_EQ(Client::ClientCreateWindowEffective(), 4u);
EXPECT_EQ(Client::ClientCreateWindowEffective(), 8u);
EXPECT_TRUE(client.LinkRetainsReplies());
MG_Config::Ipc.CreateWindow = savedWindow;
}