mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-16 06:23:23 +09:00
[MG_Remote, MG_Pipe, MG_Impl, MG_State, MG_Backend, MG_Test, MG_IntegrationTest] (Disaggregated): P5d round 3 - the profile-directed cuts on both roles
- The round-2 report guessed the apply thread's ~48% mutex time was the backend
pendingMutex; the symbolized call graph at 56a77348 says it is the idle poll in
ServerLoop::ApplyThreadMain taking m_controlMutex twice per iteration
(ControlIsPending in the ready lambda, PumpControlRequest), with DrainRing at
29% of the thread. Every package below is cut from that graph, not from self%.
- T (transport): the control mailbox gets an atomic shadow bit m_controlPosted so
the idle poll takes no lock (handshake, C2 critical section and the
NOT_INITIALIZED answer unchanged); Doorbell::Wait spins on a once-calibrated
iteration budget and reads no clock in steady state (the park phase alone
computes deadlines); client/server wait and park counts ride the stats line
as wait[srv= srvpark= cli= clipark=] and the wire ledger as cliwait=/clipark=.
- D (role guards): OnApplyThread() is inline - one relaxed atomic key against the
caller's thread pointer (aarch64 __builtin_thread_pointer, else
std::this_thread::get_id) - and m_applyThreadId, the function-static guard and
the pthread_equal call are gone; the three scope depth counters stop being
thread_local (their only reader is the apply-thread guard, so they count only
when OnApplyThread() is true; a GL-thread scope no longer exempts the apply
thread, pinned by a new case); the guard chains are ordered cheapest-first.
- B (persistent maps): the shadow allocator rounds the SIZE to a page multiple, so
TrackWriteMap aligns OUTWARD when the shadow is page-granular - a sub-page map
is one protected page, edges and their per-draw XXH3 disappear; the inward arm
stays as the fallback. Review found a hole the edge hashes had hidden since
round 1: a map that faulted but was not consumed by the walk that advanced the
epoch was never pushed. The walk now drains every marked member before the
binding walk, registration bumps the epoch so a fresh map ships once on the
draw path, and a non-4 KB kernel page refuses the mprotect arm by name.
- C (client per verb): an image-unit high-water mark (push build only, fed by
glBindImageTexture) replaces the 192-unit sweep per draw; the residual fill's
7-term supplied conjunction is a memo keyed on its four inputs; the server's
63-field stamp per verb is a constexpr per-class mask table.
- generate_mipmap no longer skips its wait under MOBILEGL_IPC_BATCH_WAITS: its sink
is the backend GenerateMipmap, which reads MGB_CTX->GetActiveTextureUnit(), and
a batched publish let the next validate move the serial under it -
Fatal{UnmigratedPipeInput, "GetActiveTextureUnit@ReadPixels"} on the gate tree.
The rule is written at the site: a record may skip its wait only if its apply
reads nothing the residual fill writes. The texture-death scenario gets the
framebuffer case's fence before it reads the object_death tally.
- Redmi 2f7cbe2e, FCL + Minecraft 26.3-rc-3, VD12, CPU pinned: inproc 64.3 fps
(client 15.0 ms/frame, apply 12.4) -> 103-114 fps (client 8.7-9.2 ms/frame on a
mid core, apply 7.0-7.4); monolith 115 (120 Hz vsync-capped runs) / 206 (one
uncapped run, 5.0 ms/frame on the big core). Gates: unit 2203/2203,
integration-split 111/111 (the two formerly flaky cases 6/6 on repeat),
generators, include closure, dirty surface and doc citations green.
This commit is contained in:
@@ -166,6 +166,9 @@ TEST(FieldOwnershipTest, TheSevenStickyForwardsAgreeWithTheirFieldRows) {
|
||||
TEST(FieldOwnershipTest, VerbBoundaryOpsCoverEveryVerbShapedCall) {
|
||||
GTEST_SKIP() << "push not compiled in (MOBILEGL_PIPE_PUSH=OFF)";
|
||||
}
|
||||
TEST(FieldOwnershipTest, TheResidualFillsSuppliedMemoReKeysOnEveryInputThatMovesAnAnswer) {
|
||||
GTEST_SKIP() << "push not compiled in (MOBILEGL_PIPE_PUSH=OFF)";
|
||||
}
|
||||
|
||||
#else // MOBILEGL_PIPE_PUSH
|
||||
|
||||
@@ -387,6 +390,124 @@ TEST_F(FieldOwnershipTest, VerbBoundaryOpsCoverEveryVerbShapedCall) {
|
||||
// that arms all of it, and nothing in a monolith lane stamps.
|
||||
// ---------------------------------------------------------------------------------------
|
||||
|
||||
// P5d round 3 (package C): THE RESIDUAL FILL's SUPPLIED-SET MEMO, and the one thing about it
|
||||
// that can be wrong. The predicate is the same expression step 4 used to spell once per field
|
||||
// per verb, so the change carries no new verdict - what it carries is a KEY, and a key that
|
||||
// misses one of its inputs answers the PREVIOUS environment's question at the new one. In the
|
||||
// direction that loses that means the fill SKIPS a field no call supplied - and that is SILENT,
|
||||
// not an abort: the walk stamps FilledGen from the verb serial whether or not it copied, so the
|
||||
// field reads FRESH with the previous verb's value and the draw goes out with a stale binding
|
||||
// slot. Poison catches an UNSTAMPED read; it cannot catch a stamped-but-uncopied one. That is
|
||||
// exactly why this case exists - there is no second line of defence behind it.
|
||||
//
|
||||
// So each input is moved on its own with the answer read back in between, and in an order where
|
||||
// a memo that ignored that input would have to return the stale answer rather than the right one
|
||||
// by luck. This case lives outside the split-only block because the memo is in the push build
|
||||
// too (PipeFill.cpp is compiled at MOBILEGL_PIPE_PUSH), and the fields it names are the same
|
||||
// three in both.
|
||||
//
|
||||
// THE FOURTH KEY INPUT - the P4a consumer signal - GETS STEP 4 AND A DIFFERENT SHAPE, because
|
||||
// it cannot move an answer today and no honest case can pretend otherwise: every field whose
|
||||
// emitter belongs to a P4a family is also a field the applier cannot supply whole (its storage
|
||||
// is a frontend pointer), so that conjunct is DOMINATED and the mask is identical either way.
|
||||
// Step 4 moves the signal for real and pins the domination instead, so that the day a P4a row
|
||||
// gains a twin the case goes red and says what to write - the same day PipeFill.cpp's
|
||||
// NoP4aFamilyFieldIsWhollySupplied() static_assert fires.
|
||||
TEST_F(FieldOwnershipTest, TheResidualFillsSuppliedMemoReKeysOnEveryInputThatMovesAnAnswer) {
|
||||
constexpr Uint64 kNoSubsystems = 0;
|
||||
constexpr Uint64 kEverySubsystem = ~Uint64{0};
|
||||
|
||||
// 1. THE PUSH MASK. create_render_state carries GetRenderStateParameters whole and the
|
||||
// applier writes it without deriving, so at a mask that carries the render-state bit the
|
||||
// fill skips it - and at 0, which is what a unit lane runs at (Features.PipePush defaults
|
||||
// to 0), nothing is emitted and every field is pulled.
|
||||
EXPECT_FALSE(MGPipeResidualFillSuppliesField(MGPipeInputField::GetRenderStateParameters,
|
||||
kNoSubsystems, true, false));
|
||||
EXPECT_TRUE(MGPipeResidualFillSuppliesField(MGPipeInputField::GetRenderStateParameters,
|
||||
kEverySubsystem, true, false));
|
||||
EXPECT_FALSE(MGPipeResidualFillSuppliesField(MGPipeInputField::GetRenderStateParameters,
|
||||
kNoSubsystems, true, false))
|
||||
<< "the memo answered the previous mask: MOBILEGL_PIPE_PUSH is not in its key, and a "
|
||||
"per-subsystem A/B would then fill from the wrong subsystem set";
|
||||
|
||||
// 2. THE DERIVATION LATCH. GetViewport reaches PipeInputs only through
|
||||
// MGPipeDeriveRenderStateFields, so a build whose derivation is a stub must keep PULLING
|
||||
// it - skipping it there leaves the mirror unwritten and the backend reading a default.
|
||||
EXPECT_TRUE(MGPipeResidualFillSuppliesField(MGPipeInputField::GetViewport, kEverySubsystem,
|
||||
true, false));
|
||||
EXPECT_FALSE(MGPipeResidualFillSuppliesField(MGPipeInputField::GetViewport, kEverySubsystem,
|
||||
false, false))
|
||||
<< "the memo answered the previous latch: ApplierDerivesRenderStateFields is not in its key";
|
||||
|
||||
// 3. P5c rv's WIRE GATE (CONTRACT-P5C.md §5.3). set_context_values has no producer without a
|
||||
// live wire, so its eight value-class fields keep being pulled under monolith - G1's
|
||||
// byte-for-byte rule - and are skipped only when the record really crosses.
|
||||
EXPECT_FALSE(MGPipeResidualFillSuppliesField(MGPipeInputField::GetActiveTextureUnit,
|
||||
kEverySubsystem, true, false));
|
||||
EXPECT_TRUE(MGPipeResidualFillSuppliesField(MGPipeInputField::GetActiveTextureUnit,
|
||||
kEverySubsystem, true, true))
|
||||
<< "the memo answered the previous wire state: contextValuesWireLive is not in its key, "
|
||||
"and the emission's half of the gate and the fill's half would then disagree";
|
||||
|
||||
// 4. THE P4a CONSUMER SIGNAL, which is in the key and is DOMINATED, so this step pins the
|
||||
// domination rather than pretending to move an answer. Under monolith the signal IS "did
|
||||
// a backend register the resource op table" (P4aFamilyHasItsConsumer, PipeFill.cpp), and
|
||||
// MG_Config::Transport is a constexpr Monolith in every lane but a split one - so the
|
||||
// signal really moves here, at a mask that carries all four P4a bits, which is the only
|
||||
// mask at which the fill reads it at all.
|
||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) {
|
||||
const MGPipeResourceOps* const savedOps = MGPipeGetResourceOps();
|
||||
MGPipeResourceOps ops{};
|
||||
MGPipeFieldMask withConsumer{};
|
||||
MGPipeFieldMask withoutConsumer{};
|
||||
|
||||
// An EMPTY table is enough: the predicate only asks whether ONE IS REGISTERED, which is
|
||||
// how MG_Test/Pipe arms this subsystem everywhere else.
|
||||
MGPipeSetResourceOps(&ops);
|
||||
ASSERT_NE(MGPipeGetResourceOps(), nullptr)
|
||||
<< "the fixture did not move the signal it names, so this step observes nothing";
|
||||
for (SizeT i = 0; i < kMGPipeInputFieldCount; ++i) {
|
||||
if (MGPipeResidualFillSuppliesField(static_cast<MGPipeInputField>(i), kEverySubsystem,
|
||||
true, true)) {
|
||||
withConsumer.Words[i / 64] |= (Uint64{1} << (i % 64));
|
||||
}
|
||||
}
|
||||
|
||||
MGPipeSetResourceOps(nullptr);
|
||||
ASSERT_EQ(MGPipeGetResourceOps(), nullptr);
|
||||
for (SizeT i = 0; i < kMGPipeInputFieldCount; ++i) {
|
||||
if (MGPipeResidualFillSuppliesField(static_cast<MGPipeInputField>(i), kEverySubsystem,
|
||||
true, true)) {
|
||||
withoutConsumer.Words[i / 64] |= (Uint64{1} << (i % 64));
|
||||
}
|
||||
}
|
||||
MGPipeSetResourceOps(savedOps);
|
||||
|
||||
// THE NAMED ROW, both ways: GetFramebufferBindingSlot is emitted by set_framebuffer_state
|
||||
// and so rides the framebuffer family's consumer gate - and is pulled regardless, because
|
||||
// its storage is a BindingSlot<FramebufferObject> no payload can carry.
|
||||
EXPECT_FALSE(MGPipeFieldMaskHas(withConsumer, MGPipeInputField::GetFramebufferBindingSlot));
|
||||
EXPECT_FALSE(
|
||||
MGPipeFieldMaskHas(withoutConsumer, MGPipeInputField::GetFramebufferBindingSlot));
|
||||
|
||||
for (SizeT i = 0; i < kMGPipeInputFieldCount; ++i) {
|
||||
const auto field = static_cast<MGPipeInputField>(i);
|
||||
EXPECT_EQ(MGPipeFieldMaskHas(withConsumer, field),
|
||||
MGPipeFieldMaskHas(withoutConsumer, field))
|
||||
<< kMGPipeInputFieldNames[i]
|
||||
<< "'s supplied answer moved with the P4a consumer signal. That is CORRECT "
|
||||
"behaviour and this assertion is a trip wire, not a defect report: the "
|
||||
"conjunct stopped being dominated, so the memo's fourth key input is now "
|
||||
"observable and needs the move-it-and-read-it-back pair steps 1-3 give the "
|
||||
"other three - under split through CapsMirrorInstance().Adopt() with and "
|
||||
"without kMGPipeSubsystemResources in the CallMask, as "
|
||||
"SanityTest.ACapsMaskWithoutTheResourceFamilyEmitsNothingAndCountsTheRefusal "
|
||||
"already does. Rewrite this step into that pair; PipeFill.cpp's "
|
||||
"NoP4aFamilyFieldIsWhollySupplied() static_assert fires on the same change";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
|
||||
TEST_F(FieldOwnershipTest, AServerStampMakesRecordSuppliedFieldsFreshAndWithdrawsTheRest) {
|
||||
|
||||
Reference in New Issue
Block a user