Skip to content

Commit 6c9f2b6

Browse files
authored
gh-149584: Stop rereading the base frame sentinel in _remote_debugging (#159124)
Skip the remote read of the base frame sentinel while preserving the GC marker and complete-stack checks.
1 parent aced381 commit 6c9f2b6

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve the performance of the Tachyon profiler by avoiding unnecessary remote
2+
reads of the base frame sentinel. Patch by Maurycy Pawłowski-Wieroński.

‎Modules/_remote_debugging/frame_cache.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,8 @@ frame_cache_store(
318318
// Validate we have a complete stack before caching.
319319
// Only cache if last_frame_visited matches base_frame_addr (the sentinel
320320
// at the bottom of the stack). Note: we use last_frame_visited rather than
321-
// addrs[num_addrs-1] because the base frame is visited but not added to the
322-
// addrs array (it returns frame==NULL from is_frame_valid due to
323-
// owner==FRAME_OWNED_BY_INTERPRETER).
321+
// addrs[num_addrs-1] because the base frame's address is not added to the
322+
// addrs array.
324323
if (base_frame_addr != 0 && last_frame_visited != base_frame_addr) {
325324
// Incomplete stack - don't cache (graceful degradation)
326325
return 0;

‎Modules/_remote_debugging/frames.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,14 @@ process_frame_chain(
294294
}
295295
assert(frame_count <= MAX_FRAME_CHAIN_DEPTH);
296296

297+
// The base frame is a sentinel with previous == NULL: reaching it is
298+
// enough, no need to read it. Still read it when it is the GC frame
299+
// so the <GC> marker gets emitted.
300+
if (frame_addr == ctx->base_frame_addr
301+
&& !(unwinder->gc && frame_addr == ctx->gc_frame)) {
302+
break;
303+
}
304+
297305
if (ctx->chunks && ctx->chunks->count > 0) {
298306
parse_result = parse_frame_from_chunks(
299307
unwinder, &frame, frame_addr, &next_frame_addr, ctx->chunks);

0 commit comments

Comments
 (0)