Skip to content

Commit

Permalink
Bug 1862557: Add LongTask profiler marker generation to SocketThread …
Browse files Browse the repository at this point in the history
…r=necko-reviewers,kershaw

Includes separate markers for OnSocketReady() calls after Poll()

Differential Revision: https://phabricator.services.mozilla.com/D192533

UltraBlame original commit: 93a04e8835aaaf359b24f47f54d622f7d36fd813
  • Loading branch information
marco-c committed Dec 7, 2023
1 parent dc67e4b commit 9410a39
Show file tree
Hide file tree
Showing 2 changed files with 249 additions and 12 deletions.
253 changes: 247 additions & 6 deletions netwerk/base/nsSocketTransportService2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ mozilla
namespace
net
{
#
define
SOCKET_THREAD_LONGTASK_MS
3
LazyLogModule
gSocketTransportLog
(
Expand Down Expand Up @@ -4363,7 +4367,7 @@ pollTimeout
)
;
int32_t
rv
n
;
{
#
Expand Down Expand Up @@ -4423,7 +4427,7 @@ profiler_thread_sleep
}
#
endif
rv
n
=
PR_Poll
(
Expand Down Expand Up @@ -4597,7 +4601,7 @@ ts
)
;
return
rv
n
;
}
/
Expand Down Expand Up @@ -4907,6 +4911,22 @@ network_allow_raw_sockets_in_content_processes_AtStartup
)
)
{
/
/
Since
we
Poll
we
can
'
t
use
normal
LongTask
support
in
Main
Process
nsresult
rv
=
Expand All @@ -4922,12 +4942,15 @@ thread
)
this
{
.
stackSize
=
GetThreadStackSize
(
)
false
false
Some
(
SOCKET_THREAD_LONGTASK_MS
)
}
)
;
Expand Down Expand Up @@ -4989,6 +5012,18 @@ getter_AddRefs
thread
)
nullptr
{
nsIThreadManager
:
:
DEFAULT_STACK_SIZE
false
false
Some
(
SOCKET_THREAD_LONGTASK_MS
)
}
)
;
NS_ENSURE_SUCCESS
Expand Down Expand Up @@ -8750,6 +8785,36 @@ PR_IntervalNow
(
)
;
TimeStamp
startTime
;
#
ifdef
MOZ_GECKO_PROFILER
bool
profiling
=
profiler_thread_is_being_profiled_for_markers
(
)
;
if
(
profiling
)
{
startTime
=
TimeStamp
:
:
Now
(
)
;
}
#
endif
if
(
n
Expand Down Expand Up @@ -9191,6 +9256,182 @@ TryRepairPollableEvent
}
}
}
#
ifdef
MOZ_GECKO_PROFILER
if
(
profiling
)
{
TimeStamp
endTime
=
TimeStamp
:
:
Now
(
)
;
if
(
(
endTime
-
startTime
)
.
ToMilliseconds
(
)
>
=
SOCKET_THREAD_LONGTASK_MS
)
{
struct
LongTaskMarker
{
static
constexpr
Span
<
const
char
>
MarkerTypeName
(
)
{
return
MakeStringSpan
(
"
SocketThreadLongTask
"
)
;
}
static
void
StreamJSONMarkerData
(
baseprofiler
:
:
SpliceableJSONWriter
&
aWriter
)
{
aWriter
.
StringProperty
(
"
category
"
"
LongTask
"
)
;
}
static
MarkerSchema
MarkerTypeDisplay
(
)
{
using
MS
=
MarkerSchema
;
MS
schema
{
MS
:
:
Location
:
:
MarkerChart
MS
:
:
Location
:
:
MarkerTable
}
;
schema
.
AddKeyLabelFormatSearchable
(
"
category
"
"
Type
"
MS
:
:
Format
:
:
String
MS
:
:
Searchable
:
:
Searchable
)
;
return
schema
;
}
}
;
profiler_add_marker
(
ProfilerString8View
(
"
LongTaskSocketProcessing
"
)
geckoprofiler
:
:
category
:
:
OTHER
MarkerTiming
:
:
Interval
(
startTime
endTime
)
LongTaskMarker
{
}
)
;
}
}
#
endif
return
NS_OK
;
Expand Down
8 changes: 2 additions & 6 deletions xpcom/threads/nsThreadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,13 +2080,9 @@ nsThread
:
MAIN_THREAD
{
.
stackSize
=
0
.
longTaskLength
=
false
false
Some
(
W3_LONGTASK_BUSY_WINDOW_MS
Expand Down

0 comments on commit 9410a39

Please sign in to comment.