Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
92b7f3f
tp: fix descendant_slice missing boundary instant children
LalitMaganti Mar 23, 2026
f9502f0
FIx
LalitMaganti Mar 23, 2026
f7f8f8f
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 24, 2026
12422e8
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 24, 2026
fb496da
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 24, 2026
331b290
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 24, 2026
df08c64
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 24, 2026
2f95d43
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 25, 2026
9ef8b94
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 25, 2026
ccea606
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 25, 2026
31c9658
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 25, 2026
c8de1e0
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 25, 2026
336f927
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 25, 2026
d74d756
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 26, 2026
c97025a
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 26, 2026
bf7019e
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 26, 2026
120836f
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 27, 2026
ae96862
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 27, 2026
0e99380
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 27, 2026
06a9513
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 27, 2026
29a159a
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 30, 2026
62b774c
Merge remote-tracking branch 'origin/main' into dev/lalitm/fix
LalitMaganti Mar 30, 2026
ace5233
Fix
LalitMaganti Mar 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,29 @@ bool GetDescendantsInternal(
cursor.SetFilterValueUnchecked(0, start_ref->ts());
cursor.SetFilterValueUnchecked(1, start_ref->track_id().value);
cursor.SetFilterValueUnchecked(2, start_ref->depth());
// Intervals are closed on the left and open on the right, so we use Lt for
// the upper bound. However, instants (dur=0) stack on top of each other, so
// for an instant at ts=T we need child_ts <= T, achieved by using T+1 as
// the Lt bound. See SliceTracker::TryCloseStack for the matching logic.
int64_t ts_upper_bound;
if (start_ref->dur() > 0) {
ts_upper_bound = start_ref->ts() + start_ref->dur();
} else if (start_ref->dur() == 0) {
ts_upper_bound = start_ref->ts() + 1;
// Use Le for the upper bound so that slices starting exactly at the end
// boundary are included as candidates; we verify those with a parent chain
// walk below. This is necessary because an instant child emitted while its
// parent is still open gets parent_id set to that parent, even though its
// ts equals parent.ts + parent.dur (the open-right boundary).
int64_t ts_end;
if (start_ref->dur() >= 0) {
ts_end = start_ref->ts() + start_ref->dur();
} else {
ts_upper_bound = std::numeric_limits<int64_t>::max();
ts_end = std::numeric_limits<int64_t>::max();
}
cursor.SetFilterValueUnchecked(3, ts_upper_bound);
cursor.SetFilterValueUnchecked(3, ts_end);

// The timestamp filter can produce false positives at the start boundary
// (candidate.ts == start.ts) where a child of a slice ending at start.ts
// shares the same timestamp. For such candidates, walk the parent chain to
// verify ancestry. For candidates strictly inside the interval (ts >
// start.ts), same-depth non-overlapping guarantees they are true descendants.
// The timestamp filter can produce false positives at the start and end
// boundaries where a candidate shares the same timestamp but belongs to a
// different subtree. For such candidates, walk the parent chain to verify
// ancestry. For candidates strictly inside the interval, same-depth
// non-overlapping guarantees they are true descendants.
int64_t start_ts = start_ref->ts();
for (cursor.Execute(); !cursor.Eof(); cursor.Next()) {
auto row_num = cursor.ToRowNumber();
auto ref = row_num.ToRowReference(slices);
if (ref.ts() == start_ts &&
if ((ref.ts() == start_ts || ref.ts() == ts_end) &&
!IsAncestor(slices, ref, starting_id, start_ref->depth())) {
continue;
}
Expand Down Expand Up @@ -206,7 +205,7 @@ tables::SliceTable::ConstCursor Descendant::MakeCursor(
dataframe::FilterSpec{
tables::SliceTable::ColumnIndex::ts,
3,
dataframe::Lt{},
dataframe::Le{},
std::nullopt,
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b1a2941b2d324a2d30e10d724159faf619710be5e79594f98a3f119be064f645
5fcde60486cf84ce1430abbfb2229d456640a8fadeeb277fc21b0b51e5094b2a
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bf6d7f44e7ae8b346b85a49ac55f113b241279680c4be29c1529532fbe296d34
8307b9c488adf2bf9dd0ee6ff97dbf1ed330890724a2cf84a608d16aa102ca62
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c7474e3f6ddf13fc9e77949050092216304a45340da2f39681cc8cfd5fabadd9
8cef83398f7c9cc7150db5f5fbb314fe89e9b21f4703bc2f8da1e68688d48cd1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7cecffd8b72e5734e793a063763e88f7d46f07143e72a953bb126913fbcc861f
e254e8fc5c828a5015c855f79150350fa651e6e88ae0aea9a0e06b6419a2ef7b
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7bf9c9b29b41b9f60a4854b93eaafb072d328472a47a5612eb7b3a2864fdc03c
e2218fe79abf6e846f78ef7cf0586b40921099821d3dd9762f4fd0225e133e60
99 changes: 99 additions & 0 deletions test/trace_processor/diff_tests/stdlib/dynamic_tables/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,105 @@ def test_descendant_slice_boundary_instant(self):
"descendant_name"
"""))

# Regression test: descendant_slice should include an instant child at the
# exact end boundary of its parent when the parent_id chain confirms it.
# This mirrors the real-world sequence: Begin(parent) -> Scoped(instant at
# parent_end) -> End(parent) -> Begin(uncle).
def test_descendant_slice_boundary_instant_parent(self):
return DiffTestBlueprint(
trace=TextProto(r"""
packet {
trusted_packet_sequence_id: 1
timestamp: 0
incremental_state_cleared: true
track_descriptor {
uuid: 1
parent_uuid: 10
thread {
pid: 5
tid: 1
thread_name: "t1"
}
}
trace_packet_defaults {
track_event_defaults {
track_uuid: 1
}
}
}
packet {
trusted_packet_sequence_id: 1
timestamp: 0
track_descriptor {
uuid: 10
process {
pid: 5
process_name: "p1"
}
}
}
# Parent slice [1000, 3000)
packet {
trusted_packet_sequence_id: 1
timestamp: 1000
track_event {
categories: "cat"
name: "parent"
type: 1
}
}
# Child instant at ts=3000, emitted while parent is still open
packet {
trusted_packet_sequence_id: 1
timestamp: 3000
track_event {
categories: "cat"
name: "child_instant"
type: 3
}
}
# Parent ends at 3000
packet {
trusted_packet_sequence_id: 1
timestamp: 3000
track_event {
categories: "cat"
name: "parent"
type: 2
}
}
# Uncle slice [3000, 5000) adjacent to parent
packet {
trusted_packet_sequence_id: 1
timestamp: 3000
track_event {
categories: "cat"
name: "uncle"
type: 1
}
}
packet {
trusted_packet_sequence_id: 1
timestamp: 5000
track_event {
categories: "cat"
name: "uncle"
type: 2
}
}
"""),
query="""
SELECT d.name AS descendant_name
FROM slice AS s
JOIN descendant_slice(s.id) AS d
WHERE s.name = 'parent'
ORDER BY d.ts, d.name;
""",
out=Csv("""
"descendant_name"
"child_instant"
"""))

# Ancestor slice by stack table.
def testancestor_slice_by_stack(self):
return DiffTestBlueprint(
Expand Down
Loading