Skip to content

Commit 70a2e41

Browse files
committed
Drop the now-redundant emit_batch trim and fix the review nits
The batch list is built to its exact size, so the PyList_SetSlice trim was a no-op; call emit_sample directly. Also point the cap comment at the issue (gh-151378) and drop the stale over-long comment.
1 parent 6594318 commit 70a2e41

1 file changed

Lines changed: 7 additions & 23 deletions

File tree

Modules/_remote_debugging/binary_io_reader.c

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/* Progress callback frequency */
2929
#define PROGRESS_CALLBACK_INTERVAL 1000
3030

31-
/* Cap per-batch RLE samples to bound the timestamp list (gh-152089) */
31+
/* Cap per-batch RLE samples to bound the timestamp list (gh-151378) */
3232
#define MAX_RLE_BATCH_SAMPLES 8192
3333

3434
/* ============================================================================
@@ -950,21 +950,6 @@ emit_sample(RemoteDebuggingState *state, PyObject *collector,
950950
return 0;
951951
}
952952

953-
/* Helper to trim timestamp list and emit batch. Returns 0 on success, -1 on error. */
954-
static int
955-
emit_batch(RemoteDebuggingState *state, PyObject *collector,
956-
uint64_t thread_id, uint32_t interpreter_id, uint8_t status,
957-
const uint32_t *frame_indices, size_t stack_depth,
958-
BinaryReader *reader, PyObject *timestamps_list, Py_ssize_t actual_size)
959-
{
960-
/* Trim list to actual size */
961-
if (PyList_SetSlice(timestamps_list, actual_size, PyList_GET_SIZE(timestamps_list), NULL) < 0) {
962-
return -1;
963-
}
964-
return emit_sample(state, collector, thread_id, interpreter_id, status,
965-
frame_indices, stack_depth, reader, timestamps_list);
966-
}
967-
968953
/* Helper to invoke progress callback, returns -1 on error */
969954
static inline int
970955
invoke_progress_callback(PyObject *callback, Py_ssize_t current, uint32_t total)
@@ -1101,15 +1086,14 @@ binary_reader_replay(BinaryReader *reader, PyObject *collector, PyObject *progre
11011086
if (i == 0 || status != batch_status
11021087
|| batch_idx >= MAX_RLE_BATCH_SAMPLES) {
11031088
if (timestamps_list) {
1104-
int rc = emit_batch(state, collector, thread_id, interpreter_id,
1105-
batch_status, ts->current_stack, ts->current_stack_depth,
1106-
reader, timestamps_list, batch_idx);
1089+
int rc = emit_sample(state, collector, thread_id, interpreter_id,
1090+
batch_status, ts->current_stack, ts->current_stack_depth,
1091+
reader, timestamps_list);
11071092
Py_DECREF(timestamps_list);
11081093
if (rc < 0) {
11091094
return -1;
11101095
}
11111096
}
1112-
/* Append per element; the old alloc(count - i) + trim per batch was O(count^2). */
11131097
timestamps_list = PyList_New(0);
11141098
if (!timestamps_list) {
11151099
return -1;
@@ -1134,9 +1118,9 @@ binary_reader_replay(BinaryReader *reader, PyObject *collector, PyObject *progre
11341118

11351119
/* Emit final batch */
11361120
if (timestamps_list) {
1137-
int rc = emit_batch(state, collector, thread_id, interpreter_id,
1138-
batch_status, ts->current_stack, ts->current_stack_depth,
1139-
reader, timestamps_list, batch_idx);
1121+
int rc = emit_sample(state, collector, thread_id, interpreter_id,
1122+
batch_status, ts->current_stack, ts->current_stack_depth,
1123+
reader, timestamps_list);
11401124
Py_DECREF(timestamps_list);
11411125
if (rc < 0) {
11421126
return -1;

0 commit comments

Comments
 (0)