mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-20 16:31:57 +09:00
Compare commits
3
Commits
102f2ca7d5
...
6bccf98d7f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bccf98d7f | ||
|
|
3a6c5c7f04 | ||
|
|
b017ec1c1f |
+1
-1
@@ -594,7 +594,7 @@ namespace MobileGL::MG_Config {
|
||||
// caller was fire-and-forget. The window's own creates are fire-and-forget AND read, so a
|
||||
// flag keyed on wantReply would disable the very mechanism it exists to enable
|
||||
// (docs/Disaggregated/notes/p12/CREATE-WINDOW-MEASURED.md sections 7-11).
|
||||
Uint32 CreateWindow = 6;
|
||||
Uint32 CreateWindow = 10;
|
||||
// MOBILEGL_IPC_ADOPT_TIER: 2 = emulate (client keeps the shadow and pushes), which
|
||||
// is the only tier P5 implements and the reason persistent-map-push can be non-zero
|
||||
// at all (R-6). 0 and 1 parse and are Fatal at use with "P11"; they exist now so the
|
||||
|
||||
@@ -420,7 +420,7 @@ namespace MobileGL::MG_ConfigLoader {
|
||||
// declared answers, and the device sweep showed the wall clock still falling at the old
|
||||
// cap of 4 (see WireTables.cpp's kCreateWindowMax). WireTables.cpp's static_assert and
|
||||
// StreamLink's crossing log are the checks on this number.
|
||||
ipc.CreateWindow = QueryEnvUint32("MOBILEGL_IPC_CREATE_WINDOW", 6, 1, 8);
|
||||
ipc.CreateWindow = QueryEnvUint32("MOBILEGL_IPC_CREATE_WINDOW", 10, 1, 12);
|
||||
// The verify harness compares the pushed block against the applier per verb; a
|
||||
// batched queue lets the comparer read a supplied field mid-apply, which is a
|
||||
// torn read rather than a divergence. The batch is therefore off whenever the
|
||||
|
||||
@@ -215,6 +215,32 @@ void main() { oColor = texture(uTex, vUv); }
|
||||
<< " (" << image.ColorName(cx, cy) << ")" << std::endl;
|
||||
}
|
||||
|
||||
// A REAL BOUNDARY BEFORE ANY WHITE-BOX READ OF THE APPLIER (P12).
|
||||
//
|
||||
// The reads below (RecordIsReadable and its callers) read state that lives in the
|
||||
// APPLIER, and the records they assert about are the mask moves a sticky-bit change
|
||||
// produces - `resource_respecify` rows. P12 made that row FIRE-AND-FORGET for a texture
|
||||
// whose existence is already confirmed (PipeRoute.h's
|
||||
// MGPipeResourceRespecifyWantsItsReply: the answer only ever said "the applier holds a
|
||||
// record for this handle", which the client's own publication latch already answers), so
|
||||
// the client no longer waits, and a read taken immediately after the setter now races
|
||||
// the apply thread. MEASURED: DirectGLES.P4aFinalFixScenario's DSA case red with
|
||||
// `Serial` 7 vs 7 and the RENDER_TARGET bit clear, twice in a row, on the inproc arm -
|
||||
// and it is exactly the failure the CtWireScenario death gates had, from the same cause.
|
||||
//
|
||||
// A READBACK IS THE BOUNDARY THAT HOLDS ON EVERY ARM: ReadPixels is
|
||||
// kReplySlot|kWaitReply, the client blocks on its answer, and an answer is posted only
|
||||
// after its record has been APPLIED - so every record published before it, the mask move
|
||||
// included, is applied too. (The harness's applied-seq fence would be the other choice
|
||||
// and it is right for inproc only; it times out on the spawn/tcp arms, which this file
|
||||
// has no registrations on today but may grow.)
|
||||
void FenceTheApplierRead() {
|
||||
GLubyte fencePixel[4]{};
|
||||
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, fencePixel);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR))
|
||||
<< "the applier-read fence left a GL error behind";
|
||||
}
|
||||
|
||||
// The white-box gate of the M-A case: true when the applier holds a record for the
|
||||
// texture in this process. Prints the decline.
|
||||
bool RecordIsReadable(unsigned glTextureName, const char* what, PipeTextureResourceRecordPeek* out) {
|
||||
@@ -563,6 +589,7 @@ void main() { oColor = texture(uTex, vUv); }
|
||||
(void)uploadsReadable;
|
||||
glBindImageTexture(0, texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA8);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
FenceTheApplierRead();
|
||||
if (readable) {
|
||||
ASSERT_TRUE(PeekPipeTextureResourceRecord(texture, &record));
|
||||
EXPECT_EQ(record.ImageBindableHint, 1u)
|
||||
@@ -637,6 +664,7 @@ void main() { oColor = texture(uTex, vUv); }
|
||||
glCreateFramebuffers(1, &namedFbo);
|
||||
glNamedFramebufferTexture(namedFbo, GL_COLOR_ATTACHMENT0, early, 0);
|
||||
ASSERT_EQ(FirstGLError(), GLenum(GL_NO_ERROR));
|
||||
FenceTheApplierRead();
|
||||
if (earlyReadable) {
|
||||
ASSERT_TRUE(PeekPipeTextureResourceRecord(early, &earlyRecord));
|
||||
EXPECT_NE(earlyRecord.BindMask & (1u << 7), 0u)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <MG_Remote/FatalFunnel.h>
|
||||
#include <MG_Remote/Handshake.h>
|
||||
#include <MG_Remote/Transport/LinkMetrics.h>
|
||||
#include <MG_Remote/Transport/StreamLink.h>
|
||||
|
||||
#include "../CapsCodec.h"
|
||||
#include "../Protocol/generated/protocol_generated.h"
|
||||
@@ -2260,6 +2261,16 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// overlap and at most one frame of added latency (ruling 4 / ID-92).
|
||||
const Uint64 awaited = serial - credit;
|
||||
++m_presentCreditWaits;
|
||||
// P65CLIENTPACE: WHERE THE CLIENT'S FRAME GOES, ONE LINE PER FRAME.
|
||||
//
|
||||
// The frame is a lockstep ping-pong and every stage measured so far is IDLE: the client
|
||||
// GL thread at 13% of the frame, the server's apply at 7%, and the server's io thread
|
||||
// 97% blocked in recv waiting for this side. So the missing time is on the CLIENT, and
|
||||
// this is the only per-frame wait the client is known to take - it blocks here until
|
||||
// the server acknowledges the swap of (serial - credit). With it, the io thread's send
|
||||
// side (is the socket full?) and the frame's own wall/CPU, the 80% has nowhere left to
|
||||
// hide: it is either this wait, the send, or the game.
|
||||
const auto paceStarted = std::chrono::steady_clock::now();
|
||||
const BarrierWaitScope waiting;
|
||||
Transport::SessionWait wait = Transport::SessionWait::TimedOut;
|
||||
for (;;) {
|
||||
@@ -2286,6 +2297,17 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// ShutDown is teardown and returns: the present did not happen, the same answer
|
||||
// the barrier gives on a dead doorbell.
|
||||
if (wait == Transport::SessionWait::Reached) DrainEventRing(*m_events);
|
||||
const double creditMs =
|
||||
static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now() - paceStarted).count()) / 1e6;
|
||||
const auto io = Transport::StreamLink::TakeSendStats();
|
||||
MGLOG_I("P65ClientPace present=%llu credit_wait_ms=%.1f | io: %llu B in %llu sendmsg "
|
||||
"send_ms=%.1f total_ms=%.1f",
|
||||
static_cast<unsigned long long>(serial), creditMs,
|
||||
static_cast<unsigned long long>(io.bytes),
|
||||
static_cast<unsigned long long>(io.calls),
|
||||
static_cast<double>(io.nsInRecv) / 1e6,
|
||||
static_cast<double>(io.nsTotal) / 1e6);
|
||||
}
|
||||
m_presentsSent = serial;
|
||||
return serial;
|
||||
|
||||
@@ -398,7 +398,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// (THE NARRATIVE ABOVE PREDATES RETENTION and ends at "the default is 1". It is kept as
|
||||
// the record of what was tried; what made the window work is the declared-answer store,
|
||||
// and the default is 2 - Config.h carries the device numbers.)
|
||||
constexpr Uint32 kCreateWindowMax = 8;
|
||||
constexpr Uint32 kCreateWindowMax = 12;
|
||||
// THE POOL ARGUMENT THAT USED TO PIN THIS AT 4 IS GONE, AND WHY IT IS GONE IS THE ONE
|
||||
// THING TO RE-CHECK BEFORE RAISING IT AGAIN. It read: the pool is kDefaultReplySlotCount
|
||||
// slots addressed seq % count, so an answer is readable only while its slot has not been
|
||||
@@ -451,6 +451,32 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// answers from existing at all - the second is what a no-reply bit keyed on wantReply
|
||||
// would produce, and it would leave every other reading green.
|
||||
Uint64 g_createWindowTaken = 0;
|
||||
// P12 MEASUREMENT: WHY A CREATE DOES NOT DEFER. The window's own arithmetic says a frame's
|
||||
// blocking takes should be creates/window (4,536/6 = 756 at the shipped default), and the
|
||||
// device measures 1,155 - a CONSTANT ~400 that does not move when the window deepens (at
|
||||
// window 8 the ideal is 567 and the measurement is 859). A constant is a fixed population
|
||||
// rather than a queueing effect, and the four exits below are the only ways into it, so
|
||||
// counting them by name is what says which one it is. It matters because the frame turned
|
||||
// out to be LATENCY-bound, not throughput-bound (the server applies all 103,097 records in
|
||||
// 1.95 s of a 9.64 s frame, and the client's 1,161 blocking takes at ~4.9 ms are 5.7 s of
|
||||
// it) - so the way to make it faster is fewer blocks, not a faster apply.
|
||||
Uint64 g_blockNoWindow = 0, g_blockSuspectsFull = 0, g_blockSuspectObject = 0,
|
||||
g_blockWindowStillFull = 0, g_blockTotal = 0;
|
||||
void NoteCreateBlocked(Uint64& reason) {
|
||||
++reason;
|
||||
++g_blockTotal;
|
||||
// Once per 256 blocks: a handful of lines per load frame, and the composition is
|
||||
// readable from any one of them.
|
||||
if (g_blockTotal % 256 == 0) {
|
||||
MGLOG_I("P12 create blocks: total=%llu no-window=%llu suspects-full=%llu "
|
||||
"suspect-object=%llu window-still-full=%llu",
|
||||
static_cast<unsigned long long>(g_blockTotal),
|
||||
static_cast<unsigned long long>(g_blockNoWindow),
|
||||
static_cast<unsigned long long>(g_blockSuspectsFull),
|
||||
static_cast<unsigned long long>(g_blockSuspectObject),
|
||||
static_cast<unsigned long long>(g_blockWindowStillFull));
|
||||
}
|
||||
}
|
||||
|
||||
// A HANDLE WHOSE CREATE CAME BACK DECLINED IS NEVER WINDOWED AGAIN. Without this the window
|
||||
// would UNDO the repair it exists to keep: every later use of the object sends another create,
|
||||
@@ -624,6 +650,13 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// all four take the blocking branch, which is the pre-window shape - and on the device
|
||||
// this is the branch the whole row takes, because the deferral above it cannot be
|
||||
// collected. See the section comment for the measurement and the arithmetic.
|
||||
if (window <= 1) {
|
||||
NoteCreateBlocked(g_blockNoWindow);
|
||||
} else if (g_createSuspects.size() >= kCreateSuspectMax) {
|
||||
NoteCreateBlocked(g_blockSuspectsFull);
|
||||
} else if (CreateIsSuspect(payload->Resource)) {
|
||||
NoteCreateBlocked(g_blockSuspectObject);
|
||||
}
|
||||
if (window <= 1 || g_createSuspects.size() >= kCreateSuspectMax ||
|
||||
CreateIsSuspect(payload->Resource)) {
|
||||
// THE WINDOW RETIRES HERE, AND IT MAY BE HOLDING ANSWERS (P12). This branch is
|
||||
@@ -650,6 +683,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// against the effective window, which is what the array below is sized for, so
|
||||
// this line IS the overwrite guard.
|
||||
if (g_createWindowCount >= window) {
|
||||
NoteCreateBlocked(g_blockWindowStillFull);
|
||||
EmitCreateBlocking(session, payload, reply);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "ServerLoop.h"
|
||||
#include <MG_Remote/FatalFunnel.h>
|
||||
#include <MG_Remote/Transport/StreamLink.h>
|
||||
#include <MG_Backend/MGPipe/PipeInputs.h>
|
||||
|
||||
#include <Config.h>
|
||||
@@ -739,6 +740,30 @@ namespace MobileGL::MG_Remote::Server {
|
||||
ServerSession& session = *m_session;
|
||||
Transport::SessionConsumer& consumer = session.Consumer();
|
||||
PipeApplier& applier = session.Applier();
|
||||
// ---- P65ServerFrame: WHERE THE SERVER'S TIME GOES (P12 measurement) -----------------
|
||||
//
|
||||
// THE CLIENT SIDE IS MEASURED OUT AND THE SERVER'S IS NOT MEASURED AT ALL. Every reading
|
||||
// this harness produces is the CLIENT's - wall_ns, wait_replies, client_thread_cpu_ns - and
|
||||
// they now add up to less than the frame: at window 6 the client burns 2.5 s of CPU and
|
||||
// 1,162 blocking waits, and removing 292 of those waits (window 8) moves the wall clock by
|
||||
// nothing. The same 101 MB over USB instead of WiFi moves it by nothing either. What is
|
||||
// left is the one process nobody has timed: the server applying 103,097 records.
|
||||
//
|
||||
// THE SPLIT IS THE POINT. apply_ms is the sum of the time spent INSIDE
|
||||
// PipeApplier::ApplyOne - the GL work, the decode, the reply posts - and wall_ms is Present
|
||||
// to Present on the apply thread. Their difference is everything that is NOT applying:
|
||||
// waiting on the ring for the next record, retiring, and the socket. So one line answers
|
||||
// "is the phone CPU-bound, or is it waiting for the client?" without a profiler, which is
|
||||
// the question the next optimisation has to be chosen from.
|
||||
//
|
||||
// FUNCTION-LOCAL STATIC BECAUSE THE FRAME DOES NOT FIT IN ONE DrainRing CALL: records
|
||||
// trickle in, so a frame spans many drains, and state that reset per drain would measure a
|
||||
// batch. There is exactly one apply thread (ServerLoopInstance's), which is what makes a
|
||||
// static safe here; the same reasoning the drain tally above uses.
|
||||
static auto sFrameWallStart = std::chrono::steady_clock::now();
|
||||
static std::uint64_t sFrameApplyNs = 0;
|
||||
static std::uint64_t sFrameRecords = 0;
|
||||
static std::uint64_t sFrameIndex = 0;
|
||||
Uint64 applied = 0;
|
||||
for (;;) {
|
||||
if (SessionLatched()) break;
|
||||
@@ -749,7 +774,50 @@ namespace MobileGL::MG_Remote::Server {
|
||||
bool corrupt = false;
|
||||
const bool popped = consumer.ApplyOne(
|
||||
[this, &applier](const Transport::RingRecordView& record) {
|
||||
const auto applyStarted = std::chrono::steady_clock::now();
|
||||
applier.ApplyOne(record);
|
||||
// P65ServerFrame: timed around the ONE call that is the server's work, and
|
||||
// summed across the drains a frame spans. See the block above DrainRing's loop.
|
||||
sFrameApplyNs += static_cast<std::uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now() - applyStarted)
|
||||
.count());
|
||||
++sFrameRecords;
|
||||
if (record.kind == static_cast<std::uint16_t>(MG_Pipe::MGPWireOp::Present)) {
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
const auto wallNs = static_cast<std::uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(now - sFrameWallStart)
|
||||
.count());
|
||||
const double applyMs = static_cast<double>(sFrameApplyNs) / 1e6;
|
||||
const double wallMs = static_cast<double>(wallNs) / 1e6;
|
||||
// AND THE STAGE NOTHING ELSE COVERS: the io thread's socket reads, which
|
||||
// its own MGLOG_ lines cannot report (the phone's forwarded log carries
|
||||
// mgl-srv-apply and mgl-display-ser only). read_ms is wall time inside
|
||||
// recv - blocking included - so a frame that is 90% read_ms is a frame the
|
||||
// reader spent WAITING for bytes, and one that is mostly recv calls with
|
||||
// little read_ms is a reader that is copying.
|
||||
const auto read = Transport::StreamLink::TakeReadStats();
|
||||
MGLOG_I("P65ServerFrame frame=%llu records=%llu apply_ms=%.1f wall_ms=%.1f "
|
||||
"outside_ms=%.1f | read: %llu B in %llu recv(%llu reads) "
|
||||
"recv_ms=%.1f total_ms=%.1f (%.0f%% blocked, %.1f MB/s)",
|
||||
static_cast<unsigned long long>(++sFrameIndex),
|
||||
static_cast<unsigned long long>(sFrameRecords), applyMs, wallMs,
|
||||
wallMs - applyMs,
|
||||
static_cast<unsigned long long>(read.bytes),
|
||||
static_cast<unsigned long long>(read.calls),
|
||||
static_cast<unsigned long long>(read.reads),
|
||||
static_cast<double>(read.nsInRecv) / 1e6,
|
||||
static_cast<double>(read.nsTotal) / 1e6,
|
||||
read.nsTotal ? 100.0 * static_cast<double>(read.nsInRecv) /
|
||||
static_cast<double>(read.nsTotal)
|
||||
: 0.0,
|
||||
read.nsTotal ? static_cast<double>(read.bytes) /
|
||||
(static_cast<double>(read.nsTotal) / 1e9) / 1e6
|
||||
: 0.0);
|
||||
sFrameWallStart = now;
|
||||
sFrameApplyNs = 0;
|
||||
sFrameRecords = 0;
|
||||
}
|
||||
// THE TALLY MOVES HERE, INSIDE THE CALLBACK, AND NOT AFTER THE BATCH. s1's
|
||||
// SessionConsumer::ApplyOne publishes appliedSeq the instant this callback
|
||||
// returns, and publishing appliedSeq is what releases the client from the
|
||||
|
||||
@@ -27,6 +27,16 @@
|
||||
#endif
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
// P65Read's counters: written by the server's io thread, drained by its apply thread (see
|
||||
// StreamLink::TakeReadStats).
|
||||
static std::atomic<std::uint64_t> gReadBytes{0}, gReadCalls{0}, gReadReads{0};
|
||||
static std::atomic<std::uint64_t> gReadNsInRecv{0}, gReadNsTotal{0};
|
||||
// P65CLIENTPACE's send half: the io thread's side of the same question. A sendmsg that blocks
|
||||
// is the socket full, i.e. the WRITE side's back-pressure - and on a client whose frame is 80%
|
||||
// waiting, "is it waiting to hand bytes over, or waiting for the game to make them" is the
|
||||
// whole question. Time spent inside sendmsg, not calls made.
|
||||
static std::atomic<std::uint64_t> gSendBytes{0}, gSendCalls{0}, gSendNsInSend{0};
|
||||
static std::atomic<std::uint64_t> gSendNsTotal{0};
|
||||
namespace {
|
||||
constexpr std::uint64_t kDataEnvelopeBytes = 20;
|
||||
constexpr std::uint64_t kMaxDataPayload = kMaxFramePayloadSize - kDataEnvelopeBytes;
|
||||
@@ -187,9 +197,32 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
bool Read(void* data, std::size_t size) {
|
||||
#if !defined(_WIN32)
|
||||
// P65Read: THE SERVER'S SOCKET-READ PATH, WHICH NOTHING MEASURED. The per-frame
|
||||
// clocks say the frame's time is NOT in the client's GL thread (13%) and NOT in
|
||||
// PipeApplier::ApplyOne (11%) - 76% of a 105-185 ms frame is outside both, and the
|
||||
// only stage between them is this loop. Two different worlds look identical from
|
||||
// outside it and need opposite fixes:
|
||||
// * few BIG recvs with little time blocked -> the reader is copying, i.e. one
|
||||
// thread's throughput is the ceiling;
|
||||
// * many SMALL recvs, most of the wall spent blocked -> the reader is STARVED and
|
||||
// the client (or the batching on its side) sets the pace.
|
||||
// Counted here rather than sampled from /proc because the question is per-call, not
|
||||
// per-thread. Printed every kReadMarkBytes so a frame's worth of traffic yields
|
||||
// several lines and no line can be lost to a quiet period.
|
||||
constexpr std::uint64_t kReadMarkBytes = 8ull * 1024ull * 1024ull;
|
||||
(void)kReadMarkBytes;
|
||||
const auto readStarted = std::chrono::steady_clock::now();
|
||||
std::uint64_t calls = 0;
|
||||
auto* p = static_cast<std::uint8_t*>(data);
|
||||
const auto wanted = size;
|
||||
while (size) {
|
||||
const auto recvStarted = std::chrono::steady_clock::now();
|
||||
const auto n = ::recv(fd, p, size, 0);
|
||||
gReadNsInRecv.fetch_add(static_cast<std::uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now() - recvStarted).count()),
|
||||
std::memory_order_relaxed);
|
||||
++calls;
|
||||
if (n < 0 && errno == EINTR) continue;
|
||||
if (n <= 0) {
|
||||
Die(!stopping.load(std::memory_order_acquire));
|
||||
@@ -198,6 +231,13 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
p += n;
|
||||
size -= static_cast<std::size_t>(n);
|
||||
}
|
||||
gReadCalls.fetch_add(calls, std::memory_order_relaxed);
|
||||
gReadReads.fetch_add(1, std::memory_order_relaxed);
|
||||
gReadBytes.fetch_add(wanted, std::memory_order_relaxed);
|
||||
gReadNsTotal.fetch_add(static_cast<std::uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now() - readStarted).count()),
|
||||
std::memory_order_relaxed);
|
||||
return true;
|
||||
#else
|
||||
(void)data;
|
||||
@@ -221,8 +261,16 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
msghdr message{};
|
||||
message.msg_iov = vectors;
|
||||
message.msg_iovlen = size ? 2 : 1;
|
||||
const auto sendStarted = std::chrono::steady_clock::now();
|
||||
std::uint64_t sendCalls = 0;
|
||||
while (message.msg_iovlen) {
|
||||
const auto syscallStarted = std::chrono::steady_clock::now();
|
||||
const auto sent = ::sendmsg(fd, &message, MSG_NOSIGNAL);
|
||||
gSendNsInSend.fetch_add(static_cast<std::uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now() - syscallStarted).count()),
|
||||
std::memory_order_relaxed);
|
||||
++sendCalls;
|
||||
if (sent < 0 && errno == EINTR) continue;
|
||||
if (sent <= 0) {
|
||||
Die(!stopping.load(std::memory_order_acquire));
|
||||
@@ -239,6 +287,12 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
message.msg_iov->iov_len -= consumed;
|
||||
}
|
||||
}
|
||||
gSendCalls.fetch_add(sendCalls, std::memory_order_relaxed);
|
||||
gSendBytes.fetch_add(size, std::memory_order_relaxed);
|
||||
gSendNsTotal.fetch_add(static_cast<std::uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now() - sendStarted).count()),
|
||||
std::memory_order_relaxed);
|
||||
return true;
|
||||
#else
|
||||
(void)payload;
|
||||
@@ -425,6 +479,25 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
};
|
||||
|
||||
StreamLink::ReadStats StreamLink::TakeSendStats() {
|
||||
ReadStats out;
|
||||
out.bytes = gSendBytes.exchange(0, std::memory_order_relaxed);
|
||||
out.calls = gSendCalls.exchange(0, std::memory_order_relaxed);
|
||||
out.nsInRecv = gSendNsInSend.exchange(0, std::memory_order_relaxed);
|
||||
out.nsTotal = gSendNsTotal.exchange(0, std::memory_order_relaxed);
|
||||
return out;
|
||||
}
|
||||
|
||||
StreamLink::ReadStats StreamLink::TakeReadStats() {
|
||||
ReadStats out;
|
||||
out.bytes = gReadBytes.exchange(0, std::memory_order_relaxed);
|
||||
out.calls = gReadCalls.exchange(0, std::memory_order_relaxed);
|
||||
out.reads = gReadReads.exchange(0, std::memory_order_relaxed);
|
||||
out.nsInRecv = gReadNsInRecv.exchange(0, std::memory_order_relaxed);
|
||||
out.nsTotal = gReadNsTotal.exchange(0, std::memory_order_relaxed);
|
||||
return out;
|
||||
}
|
||||
|
||||
StreamLink::StreamLink() : m_impl(new Impl) {}
|
||||
StreamLink::~StreamLink() {
|
||||
Detach();
|
||||
|
||||
@@ -11,6 +11,23 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
public:
|
||||
StreamLink();
|
||||
~StreamLink() override;
|
||||
// P65READ: THE SERVER'S SOCKET-READ PATH, ACCOUNTED WHERE IT CAN BE SEEN. The counters are
|
||||
// published from the io thread's recv loop and read by the APPLY thread, because the io
|
||||
// thread's own MGLOG_ lines never reach the phone's forwarded log (only mgl-srv-apply and
|
||||
// mgl-display-ser do - measured, not assumed). Taking them RESETS them, so one call is one
|
||||
// frame's worth of the stage nothing else measures: the frame's time is not the client's GL
|
||||
// thread (13%) and not PipeApplier::ApplyOne (11%), and this is what sits between them.
|
||||
struct ReadStats {
|
||||
std::uint64_t bytes = 0; // payload bytes taken off the socket
|
||||
std::uint64_t calls = 0; // recv() calls it took
|
||||
std::uint64_t reads = 0; // Link::Read() calls (one per header, envelope or chunk)
|
||||
std::uint64_t nsInRecv = 0; // wall time inside recv - blocking included
|
||||
std::uint64_t nsTotal = 0; // wall time inside Read
|
||||
};
|
||||
static ReadStats TakeReadStats();
|
||||
// The client's half: bytes handed to the io thread's sendmsg, the calls it took, and the
|
||||
// wall time inside sendmsg (blocking included). nsInRecv carries the send time.
|
||||
static ReadStats TakeSendStats();
|
||||
MobileGLResult Attach(int dataFd, SessionSegments& mirrors, TransportRoleTag role);
|
||||
MobileGLResult AttachOwned(int dataFd, const struct SessionSegmentSizes& sizes, TransportRoleTag role);
|
||||
// PH-7 (4), ID-P7-3. The SERVER's half of a nonce-bound data connection, in two steps.
|
||||
|
||||
Reference in New Issue
Block a user