[Perf] (MG_Remote/Client): the buffer half of resource_respecify stops waiting - its answer is discarded at both call sites - and the measurement says the texture half is where the other 20,611 waits live

- The two halves of this row are not the same row. PipeFill.cpp:1105 and :1142 both call
  MGPipeRouteResourceRespecify(desc, nullptr) and drop the Bool, so for a buffer the wait bought a
  value that was thrown away. It goes fire-and-forget with the provisional-accept shape
  resource_subdata has had since item B.
- The texture half keeps its answer ON PURPOSE: there the Bool is the self-heal trigger AND the
  gate on the acceptance mirror, and TextureEmit.h:885-888 (ID-18 M3) says advancing that mirror on
  an unconfirmed answer is how the next identical call gets suppressed "against a record that was
  never stored". That half needs the provisional/really-accepted distinction plumbed through the
  reply mailbox before it can stop waiting; it is not a flag flip.
- MEASURED, same frame, same 101,421,396 B staged: waits 25,176 -> 25,154 and by_op 3=20633 ->
  3=20611. So the buffer half is worth 22 waits (0.1%) and the remaining 20,611 are texture
  respecifies - which is what says the next step is the mirror design, not another flag. Wall
  134.4 s -> 130.9 s.
- The ERROR-is-not-a-decline case moves to the texture half: a row that reads no answer cannot fold
  ERROR into a decision, so the rule it exists for belongs to the half that still waits (the
  transport fault is caught at the next row that does). New case
  ABufferRespecifyTakesNoReplyWhileATextureOneStillDoes pins both directions; red-once with the
  branch removed is exit 155. RemoteClientTest 169/169.
This commit is contained in:
BZLZHH
2026-09-25 22:53:38 +08:00
parent 5ad8370b37
commit f2b55b9d2d
3 changed files with 86 additions and 6 deletions
@@ -296,11 +296,18 @@ TEST(RemoteClientControls, LongFenceWaitBudgetStillWakesOnShutdown) {
}
TEST(RemoteClientControls, ResourceRespecifyErrorIsNotADecline) {
// THE TEXTURE HALF, WHICH IS THE HALF THAT STILL READS ITS ANSWER (P12). This case used a
// zeroed descriptor, which is a BUFFER target - and the buffer half is now fire-and-forget
// because both of its call sites discard the Bool (PipeFill.cpp:1105, :1142). A row that reads
// no answer cannot fold ERROR into a decision, so the rule this case exists for moved to the
// half that does read one: the transport fault is caught here, at the next row that waits,
// instead of at a record whose verdict nobody ever looked at.
const auto child = RunInChild([] {
StartControlSession();
ErrorPeer peer;
peer.Install();
MGPResourceDesc desc{};
desc.Target = static_cast<Uint8>(MG_Pipe::MGPipeResourceTarget::Tex2D);
(void)MGPipeRouteResourceRespecify(desc, nullptr);
});
ExpectNamedAbort(child, "Fatal{ReplyError, \"resource_respecify\"}");
@@ -1094,4 +1101,54 @@ TEST(RemoteClientControls, AParameterChangeForAConfirmedObjectTakesNoReply) {
});
ExpectChildSuccess(child);
}
// =====================================================================================
// P12: a BUFFER respecify takes no reply; a TEXTURE one still does (deliberately)
// =====================================================================================
//
// The two halves of resource_respecify are not the same row. The buffer half's Bool is discarded
// at BOTH call sites (PipeFill.cpp:1105, :1142), so its wait bought a value that was thrown away -
// fire-and-forget costs nothing and saves a round trip per glBufferData, which is the shape a
// chunk uploader produces thousands of times per frame. The texture half's Bool is load-bearing:
// it triggers the self-heal AND gates the acceptance mirror, and advancing that mirror on a
// provisional accept is ID-18 M3 (TextureEmit.h:885-888). So this case asserts BOTH directions -
// the asymmetry is the design, not an oversight.
//
// THE RED, RUN ONCE: take the bufferHalf branch out of Wire_Escape_ResourceRespecify and exit 155
// fires (the buffer respecify starts waiting again).
TEST(RemoteClientControls, ABufferRespecifyTakesNoReplyWhileATextureOneStillDoes) {
const auto child = RunInChild([] {
::setenv("MOBILEGL_PIPE_STATS", "1", 1);
CapsPeer backend;
StartControlSession(&backend);
MG_Config::Features.PipePush |= kMGPipeSubsystemResources |
kMGPipeSubsystemTextureResources | kMGPipeSubsystemSamplers;
MG_State::pGLContext = MakeUnique<MG_State::GLState::GLContext>();
const Uint32 respecifyOp = static_cast<Uint32>(MGPWireOp::ResourceRespecify);
Uint8 seed[64];
std::memset(seed, 0x5a, sizeof(seed));
// ---- the BUFFER half: records out, replies not taken ----
GLuint buffer = 0;
MG_Impl::GLImpl::GenBuffers(1, &buffer);
MG_Impl::GLImpl::BindBuffer(0x8892, buffer);
MG_Impl::GLImpl::BufferData(0x8892, sizeof(seed), seed, 0x88E4);
MGP_FILL(DrawArrays);
const Uint64 recordsBefore = Transport::LinkMetricsRecordsFor(respecifyOp);
const Uint64 waitsBefore = Transport::LinkMetricsReplyWaitsFor(respecifyOp);
MG_Impl::GLImpl::BufferData(0x8892, sizeof(seed) * 2, seed, 0x88E4);
MGP_FILL(DrawArrays);
if (Transport::LinkMetricsRecordsFor(respecifyOp) <= recordsBefore) ::_exit(154);
if (Transport::LinkMetricsReplyWaitsFor(respecifyOp) != waitsBefore) ::_exit(155);
// ---- the TEXTURE half: the deliberate exception ----
Uint8 pixels[8 * 8 * 4];
std::memset(pixels, 0x21, sizeof(pixels));
GLuint texture = 0;
MG_Impl::GLImpl::GenTextures(1, &texture);
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);
ClientSessionInstance().Stop();
});
ExpectChildSuccess(child);
}
#endif