Skip to content

feat(ktrace): added derived CPU slices, thread states, threads and processes to ktrace-decode - #350

Merged
FlareCoding merged 2 commits into
masterfrom
pr/ktrace-decoder-tables
Oct 8, 2026
Merged

FlareCoding merged 2 commits into
masterfrom
pr/ktrace-decoder-tables

Conversation

@FlareCoding

@FlareCoding FlareCoding commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Questions about scheduling and per-process time made every analysis rebuild CPU timelines and thread states from raw switches and wakeups, which is easy to get subtly wrong.
  • ktrace-decode derives them once: cpu_slices, thread_states (running, runnable or sleeping, with the waker, switch reason or syscall behind each stretch), threads, thread_names and processes. Anything the records cannot determine is left out or NULL rather than guessed, and a switch_chain health check confirms the chain of switches these tables rely on is unbroken.
  • Thread and time indexes on the event and derived tables keep per-thread queries fast.

Note

Medium Risk
Large new timeline interpretation logic drives correctness of derived scheduling data; mistakes would mislead offline analysis but do not affect runtime kernel behavior.

Overview
ktrace-decode now materializes scheduling-oriented SQLite tables so analyses do not have to rebuild CPU timelines and thread lifetimes from raw sched_switch / sched_wakeup events. A new write_derived_tables pass walks the ordered timeline and populates cpu_slices, thread_states (running / runnable / sleeping, with waker, switch reason, and syscall or page-fault context when the trace supports it), threads, thread_names, and processes, using NULL where the records do not prove a value.

Pipeline and schema wiring changes: task-name interning moves into shared name_table (name_ids flows through event and derived writers); event table creation drops the inline names schema and instead auto-creates (tid, ts_ns) indexes on event fields whose names end in tid. Health checks gain a switch_chain validation that each CPU’s switches continue from the previous task, and check_health now takes the full timeline. CLI output reports derived row counts; record_event_id / record_payload helpers centralize record parsing.

Reviewed by Cursor Bugbot for commit aaf7dcd. Bugbot is set up for automated code reviews on this repo. Configure here.

cursor[bot]

This comment was marked as resolved.

@FlareCoding
FlareCoding merged commit f4c2924 into master Oct 8, 2026
10 checks passed
@FlareCoding
FlareCoding deleted the pr/ktrace-decoder-tables branch October 8, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant