Repository navigation
Filter by process before parsing, and name kernel_task's threads with pid 0 - #55
Merged
Merged
Conversation
…em into traces with filter_process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two changes to how traces are filtered by process (
filter_process,parse-live --process):Drop other processes' kevents before parsing.
filter_processwas applied afterTracesParserhad built every trace, so it saved only the formatting._filter_keventsnow drops each kevent whose thread is known to belong to another process before it is parsed. Threads whose process isn't known yet still go through, and the existing filter on finished traces still runs last. Some events pass whatever their thread:DBG_TRACEis needed to learn threads, processes, names and strings, and passes as before.DBG_DKRW) completes on whatever thread the completion interrupted, and is paired with its issue by buf address.DBG_PERF) can assign its own thread to a different process (PERF_THD_Data).execve,mac_execveandposix_spawn(withPOSIX_SPAWN_SETEXEC), the calling thread's process changes.Give kernel_task's threads pid 0. xnu marks threadmap entries valid with their pid, and kernel_task's with 1 (
_resolve_kernel_taskinbsd/kern/kdebug.c). That collides with launchd's pid. So kernel threads were attributed to launchd, and--process kernel_taskshowed almost nothing.Verification
--process: 1.09s -> 0.53s with kperf, 0.98s -> 0.37s without).--process kernel_taskgoes from 30 to 88,899 lines and--process launchdfrom 92,568 to 3,699. Results with and without kperf now agree.