mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-20 08:21:56 +09:00
[Perf] (MG_Pipe, MG_Remote/Client): a texture respecify for a CONFIRMED object stops waiting - the row pays its round trip once, at first use - and the frame drops from 130.9 s to 31.3 s
- The predicate is one function again: MGPipeResourceRespecifyWantsItsReply (PipeRoute.h) is read by the wire emitter, so the two halves of this row cannot disagree about whether an answer is owed. The buffer half never owes one (both call sites discard the Bool, PipeFill.cpp:1105/:1142); the texture half owes one exactly until MGPipeHandleIsPublished, and that latch is set only by an ACCEPTED create - which EmitResourceRespecify already sends, blocking, when it is clear (TextureEmit.h:869-879). So the object pays once, at first use, and every record after it is fire-and-forget. - MEASURED on the device, same frame, same 101,421,396 B staged, stock power policy: waits 25,154 -> 4,543 and wall 130.9 s -> 31.3 s. The op split is the proof of what changed and what did not: waits by_op 3=20611 -> absent (only 2=4536, 5=6, 9=1 remain), while the RECORDS sent are unchanged - frame-sent still shows 3=20633 and 103,094 records total. The round trips went away; the work did not. - It also lands on an independent prediction: an audit run beside this work (mgl-device/scratch/ scheme-review.md) computed 4,543 remaining waits and a 24-37 s credible range (midpoint ~30 s) from the archived logs, a host-inproc round trip of 35.4 us and a measured 43.1 MiB/s link. Measured: 31.3 s, at the midpoint. - Cumulative on that frame since this work started: 43,232 waits / 221.5 s -> 4,543 / 31.3 s (7.1x). What is left is the create row (4,536 waits, ~23 s) - the confirmation itself, not waste - plus hard floors of ~13.4 s client CPU and ~2.2 s of transfer. Going below that means batching the create row, which keeps real answers. - TWO DEBTS, STATED: (1) the invalidation guard for the one silent-loss case is NOT wired; the audit confirmed independently that no production path can drop a texture record today, and if one appears the notice it needs is protocol-surface (a tenth reverse callback). (2) No SSIM or visual check has been taken since these rows stopped asking - frame-sent agreement is strong evidence but it is not a picture. - Two stale controls in older cases were fixed rather than left: the item-B gate now names the CREATE row (its old total-based control only moved because a respecify was still waiting), and the by-op measurement asserts records-sent for the rows that deliberately stopped waiting. RemoteClientTest 169/169; red-once for the predicate is forcing it back to "always wait".
This commit is contained in:
@@ -894,24 +894,32 @@ TEST(RemoteClientControls, TextureUploadsStopOwningAReplyOnTheWireArm) {
|
||||
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
|
||||
Uint8 pixels[4 * 4 * 4];
|
||||
std::memset(pixels, 0x21, sizeof(pixels));
|
||||
// THE CONTROL ROW, NAMED RATHER THAN TOTALLED, AND MEASURED ACROSS THE WHOLE SETUP. The
|
||||
// object's create is the one record an object always pays for (kWaitReply in
|
||||
// PipeCalls.def), so ITS counter is the live control - and the baseline goes in before
|
||||
// GenTextures, because which call publishes the twin (generate, bind or the storage
|
||||
// definition) is the emitter's business and not this case's. The previous version of this
|
||||
// control read the session TOTAL and only moved because a respecify was still waiting;
|
||||
// that row is fire-and-forget for a confirmed object now, which is what made the stale
|
||||
// control visible instead of silently wrong.
|
||||
const Uint32 uploadOp = static_cast<Uint32>(MGPWireOp::ResourceSubData);
|
||||
const Uint32 createOp = static_cast<Uint32>(MGPWireOp::ResourceCreate);
|
||||
const Uint64 createWaitsBefore = Transport::LinkMetricsReplyWaitsFor(createOp);
|
||||
GLuint texture = 0;
|
||||
MG_Impl::GLImpl::GenTextures(1, &texture);
|
||||
MG_Impl::GLImpl::BindTexture(0x0DE1, texture);
|
||||
// THE CONTROL ROW. resource_create is kWaitReply (PipeCalls.def), so it owns a reply
|
||||
// slot and this counter MUST move on it.
|
||||
const auto beforeCreate = Transport::LinkMetricsReplyWaits();
|
||||
MG_Impl::GLImpl::TexImage2D(0x0DE1, 0, 0x8058, 4, 4, 0, 0x1908, 0x1401, pixels);
|
||||
MGP_FILL(DrawArrays);
|
||||
if (Transport::LinkMetricsReplyWaits() <= beforeCreate) ::_exit(140);
|
||||
if (Transport::LinkMetricsReplyWaitsFor(createOp) <= createWaitsBefore) ::_exit(140);
|
||||
// THE ROW UNDER TEST. A second write into the same level is a pure resource_subdata: the
|
||||
// resource is created, so no create crosses, and the level is dirty again - the only
|
||||
// record it can produce is the one item B is about.
|
||||
const auto beforeRecords = ClientWireRecordsEmitted();
|
||||
const auto beforeWaits = Transport::LinkMetricsReplyWaits();
|
||||
const Uint64 uploadRecordsBefore = Transport::LinkMetricsRecordsFor(uploadOp);
|
||||
const Uint64 uploadWaitsBefore = Transport::LinkMetricsReplyWaitsFor(uploadOp);
|
||||
MG_Impl::GLImpl::TexSubImage2D(0x0DE1, 0, 0, 0, 2, 2, 0x1908, 0x1401, pixels);
|
||||
MGP_FILL(DrawArrays);
|
||||
if (ClientWireRecordsEmitted() <= beforeRecords) ::_exit(141);
|
||||
if (Transport::LinkMetricsReplyWaits() != beforeWaits) ::_exit(142);
|
||||
if (Transport::LinkMetricsRecordsFor(uploadOp) <= uploadRecordsBefore) ::_exit(141);
|
||||
if (Transport::LinkMetricsReplyWaitsFor(uploadOp) != uploadWaitsBefore) ::_exit(142);
|
||||
ClientSessionInstance().Stop();
|
||||
});
|
||||
ExpectChildSuccess(child);
|
||||
@@ -1038,7 +1046,11 @@ TEST(RemoteClientControls, ReplyWaitsByOpForAnAtlasShapedLoad) {
|
||||
::_exit(148);
|
||||
if (Transport::LinkMetricsReplyWaitsFor(static_cast<Uint32>(MGPWireOp::ResourceCreate)) == 0)
|
||||
::_exit(144);
|
||||
if (Transport::LinkMetricsReplyWaitsFor(static_cast<Uint32>(MGPWireOp::ResourceRespecify)) == 0)
|
||||
// AND ResourceRespecify FOLLOWS SetTextureParams OFF THAT LIST FOR THE SAME REASON (P12/R3):
|
||||
// for a confirmed object it is fire-and-forget too. What must still hold is that its RECORDS
|
||||
// go out - a zero on both lines would mean the emitter stopped sending, which is a different
|
||||
// and much worse change than this one.
|
||||
if (Transport::LinkMetricsRecordsFor(static_cast<Uint32>(MGPWireOp::ResourceRespecify)) == 0)
|
||||
::_exit(145);
|
||||
// AND SetTextureParams IS DELIBERATELY NOT ON THAT LIST ANY MORE (P12). It was the control
|
||||
// that proved this counter was live; the first-use confirmation moved the row to
|
||||
@@ -1138,7 +1150,21 @@ TEST(RemoteClientControls, ABufferRespecifyTakesNoReplyWhileATextureOneStillDoes
|
||||
MGP_FILL(DrawArrays);
|
||||
if (Transport::LinkMetricsRecordsFor(respecifyOp) <= recordsBefore) ::_exit(154);
|
||||
if (Transport::LinkMetricsReplyWaitsFor(respecifyOp) != waitsBefore) ::_exit(155);
|
||||
// ---- the TEXTURE half: the deliberate exception ----
|
||||
// ---- the TEXTURE half, part 1: the PREDICATE both halves read (P12/R3) ----
|
||||
// An unpublished texture still owes its answer - that is the first-use confirmation - and a
|
||||
// buffer never does. Asserted directly rather than through a record, because the only way to
|
||||
// produce an unpublished texture on the wire is to make the server REFUSE its create, and a
|
||||
// malformed descriptor would trip the applier's wire report instead of testing this.
|
||||
if (MG_Pipe::MGPipeInstalledArm() != MG_Pipe::MGPipeRouteArm::kClientWire) ::_exit(157);
|
||||
MGPResourceDesc unpublished{};
|
||||
unpublished.Target = static_cast<Uint8>(MG_Pipe::MGPipeResourceTarget::Tex2D);
|
||||
if (!MG_Pipe::MGPipeResourceRespecifyWantsItsReply(unpublished)) ::_exit(158);
|
||||
MGPResourceDesc bufferDesc{};
|
||||
if (MG_Pipe::MGPipeResourceRespecifyWantsItsReply(bufferDesc)) ::_exit(159);
|
||||
// ---- the TEXTURE half, part 2: CONFIRMED, end to end ----
|
||||
// GenTextures + a storage definition publishes the object (its create is accepted, and the
|
||||
// create is blocking). A SECOND storage definition on that same object is a real change, so
|
||||
// the record must go out - and must not take a reply.
|
||||
Uint8 pixels[8 * 8 * 4];
|
||||
std::memset(pixels, 0x21, sizeof(pixels));
|
||||
GLuint texture = 0;
|
||||
@@ -1146,7 +1172,12 @@ TEST(RemoteClientControls, ABufferRespecifyTakesNoReplyWhileATextureOneStillDoes
|
||||
MG_Impl::GLImpl::BindTexture(0x0DE1, texture);
|
||||
MG_Impl::GLImpl::TexImage2D(0x0DE1, 0, 0x8058, 8, 8, 0, 0x1908, 0x1401, pixels);
|
||||
MGP_FILL(DrawArrays);
|
||||
if (Transport::LinkMetricsReplyWaitsFor(respecifyOp) == waitsBefore) ::_exit(156);
|
||||
const Uint64 confirmedRecords = Transport::LinkMetricsRecordsFor(respecifyOp);
|
||||
const Uint64 confirmedWaits = Transport::LinkMetricsReplyWaitsFor(respecifyOp);
|
||||
MG_Impl::GLImpl::TexImage2D(0x0DE1, 0, 0x8058, 16, 16, 0, 0x1908, 0x1401, pixels);
|
||||
MGP_FILL(DrawArrays);
|
||||
if (Transport::LinkMetricsRecordsFor(respecifyOp) <= confirmedRecords) ::_exit(160);
|
||||
if (Transport::LinkMetricsReplyWaitsFor(respecifyOp) != confirmedWaits) ::_exit(161);
|
||||
ClientSessionInstance().Stop();
|
||||
});
|
||||
ExpectChildSuccess(child);
|
||||
|
||||
Reference in New Issue
Block a user