Skip to content

Commit 4153902

Browse files
debug(audience): add T1/T2/T3 timing markers in HttpTransport.SendBatchAsync
Temporary diagnostic for the Unity 6 Linux PlayMode regression. Tests on Unity 6 Mono Linux take ~33 sec each vs ~1.8 sec on Unity 2021.3 Mono Linux for the same suite, same llvmpipe, same network endpoint. T1 logs request start, T2 logs response received (continuation back on the main thread), T3 logs batch deletion done. Comparing T1->T2 vs T2->T3 gaps across Unity versions disambiguates whether the stall is inside HttpClient.SendAsync (network/socket/TLS regression in Unity 6 Mono on Linux) or in the awaiter continuation (SyncContext dispatch regression on Unity 6 Linux player loop). To revert: drop this commit.
1 parent 1c7bd06 commit 4153902

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/Packages/Audience/Runtime/Transport/HttpTransport.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,23 @@ internal async Task<bool> SendBatchAsync(CancellationToken ct = default)
9595
request.Content = new StringContent(payload, Encoding.UTF8, "application/json");
9696
#endif
9797

98+
// Temporary diagnostic markers to measure where SendBatchAsync
99+
// spends time on Unity 6 Linux PlayMode cells (where each test
100+
// sits at the 30 sec WaitForLogEntry budget on Mono Linux but
101+
// finishes in 1-2 sec on Unity 2021.3 Linux). T1 is request
102+
// start, T2 is response received (continuation alive), T3 is
103+
// batch deletion + state reset done. Comparing T1->T2 vs
104+
// T2->T3 gaps across Unity versions disambiguates whether the
105+
// stall is in HttpClient.SendAsync (network/socket) or in the
106+
// continuation back onto Unity's main thread (SyncContext).
107+
var __t1 = System.Diagnostics.Stopwatch.StartNew();
108+
Log.Debug($"[HttpTransport][T1] SendAsync start url={_url} count={batch.Count}");
109+
98110
using var response = await _client.SendAsync(request, ct).ConfigureAwait(false);
99111

112+
var __t2Ms = __t1.Elapsed.TotalMilliseconds;
113+
Log.Debug($"[HttpTransport][T2] SendAsync done t1->t2={__t2Ms:F1}ms status={(int)response.StatusCode}");
114+
100115
var statusCode = (int)response.StatusCode;
101116

102117
if (statusCode >= 200 && statusCode < 300)
@@ -113,6 +128,7 @@ internal async Task<bool> SendBatchAsync(CancellationToken ct = default)
113128
NotifyError(AudienceErrorCode.ValidationRejected,
114129
$"Batch partially rejected: {rejected} of {batch.Count} events dropped");
115130
}
131+
Log.Debug($"[HttpTransport][T3] batch handled t1->t3={__t1.Elapsed.TotalMilliseconds:F1}ms (t2->t3={(__t1.Elapsed.TotalMilliseconds - __t2Ms):F1}ms)");
116132
}
117133
else if (statusCode == 429)
118134
{

0 commit comments

Comments
 (0)