Skip to content

Thread statuses improvements#398

Merged
MatthewKhouzam merged 2 commits into
eclipse-tracecompass:masterfrom
arfio:thread-statuses-improvements
May 12, 2026
Merged

Thread statuses improvements#398
MatthewKhouzam merged 2 commits into
eclipse-tracecompass:masterfrom
arfio:thread-statuses-improvements

Conversation

@arfio
Copy link
Copy Markdown
Contributor

@arfio arfio commented May 6, 2026

What it does

  • Make callstack analysis with multiple callstacks for each thread work without having errors
  • Reverse the filter which was not implemented correctly, when the predicate is true, the element is kept.

How to test

Open a callstack analysis that have threads callstacks with a kernel trace alongside it. For example using eclipse-tracecompass-incubator/org.eclipse.tracecompass.incubator#265

Follow-ups

N/A

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of timestamp filtering for thread interval queries; kernel-level states now correctly surface syscall labels in flame charts.
  • Refactor
    • Flame chart handling updated to support multiple linked kernel entries per thread.
  • Tests
    • Test fixtures and assertions updated to expect syscall labels and to enforce exact state counts before per-state comparisons.
  • Style
    • Annotation formatting cleaned up; event-stub handling refined for instant events.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dd790996-63bf-44b2-bd8a-7dffa88f65e6

📥 Commits

Reviewing files that changed from the base of the PR and between 9a9e5c5 and 32c7b50.

📒 Files selected for processing (15)
  • analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/callgraph2/FlameGraphDataProviderTest.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/stubs/org/eclipse/tracecompass/analysis/profiling/core/tests/stubs2/KernelStateProviderStub.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowFull2Times
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowFullAll
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowFullZoom
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowOne2Times
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowOneAll
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowOneZoom
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowProcess2Times
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowProcessAll
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowSelection2Times
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowSelectionAll
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowSelectionZoom
✅ Files skipped from review due to trivial changes (4)
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowOne2Times
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowFullZoom
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowFullAll
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/testfiles/dp/expectedFgRowProcessAll
🚧 Files skipped from review as they are similar to previous changes (3)
  • analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/stubs/org/eclipse/tracecompass/analysis/profiling/core/tests/stubs2/KernelStateProviderStub.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java

📝 Walkthrough

Walkthrough

Tightened timestamp filtering in KernelThreadInformationProvider; refactored FlameChartDataProvider to group multiple linked kernel entry IDs per thread and build kernel states per linked entry; tests and expected fixtures updated for syscall labeling; stub event handling refined; minor annotation formatting edits.

Changes

Thread Status Interval Filtering

Layer / File(s) Summary
Filtering Logic
analysis/org.eclipse.tracecompass.analysis.os.linux.core/.../KernelThreadInformationProvider.java
getStatusIntervalsForThreads now filters times to include only timestamps strictly inside the state system bounds (ss.getStartTime(), ss.getCurrentEndTime()), altering which timestamps are passed to ss.query2D(...).

Flame Chart Data Handling

Layer / File(s) Summary
Kernel State Grouping
analysis/org.eclipse.tracecompass.analysis.profiling.core/.../FlameChartDataProvider.java (lines 580–606)
getKernelStates groups TidInformation by thread ID into sets of linked kernel entry IDs, queries statuses once per thread, then iterates linked entry IDs to resolve entry IDs and build TimeGraphState objects stored per linked entry ID.
Annotation Formatting
analysis/org.eclipse.tracecompass.analysis.profiling.core/.../FlameChartDataProvider.java (lines 735, 766, 788–792, 801)
Whitespace/formatting adjustments and reflow of OutputElementStyle/Annotation construction; no functional change to annotation values.

Tests, Tooltip, Stub & Fixtures

Layer / File(s) Summary
Test expectations & verifier
analysis/.../FlameChartDataProviderTest.java (imports, lines ~255–305, 436–438)
Updated expected kernel TimeGraphState at time 12 to "openat" with LinuxStyle.SYSCALL; verifyStates now asserts equal list sizes before index-wise comparisons; minor import reordering.
Tooltip expectation
analysis/.../callgraph2/FlameGraphDataProviderTest.java (line ~303)
Tooltip assertion broadened to treat RUN_SYTEMCALL as an empty-tooltip case.
Stub event handling
analysis/.../stubs2/KernelStateProviderStub.java (lines 60–74)
Ignore "instant_event" events; extract "op" into operationName with null check and apply "op4"-specific transition only when matched; otherwise use RUN/WAIT_CPU as before.
Expected-output fixtures
analysis/.../testfiles/dp/expectedFgRow*
Multiple CSV-like expected-output fixtures updated to change kernel status labels and interval boundaries to include RUN_SYTEMCALL segments where applicable.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant FlameChart as FlameChartDataProvider
  participant SS as StateSystem
  participant Tests
  Client->>FlameChart: request kernel states for TidInformation list
  FlameChart->>FlameChart: group TidInformation by TID -> Set<linkedEntryIds>
  FlameChart->>SS: query kernel/process statuses for each TID once
  SS->>FlameChart: return status intervals
  FlameChart->>FlameChart: for each linkedEntryId -> resolve entryId, build TimeGraphState, filter, store keyed by linkedEntryId
  FlameChart->>Tests: supply states (with syscall labels/styles) for assertions
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • MatthewKhouzam

Poem

🐰 A filter tightened, timestamps align,
Many kernel links in one neat line,
Tests now spot syscall names that bloom,
Stubs skip instants, guard the event room,
Code hops tidy—tracepaths chime.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Thread statuses improvements' is vague and generic, using non-descriptive terms that don't convey the specific technical changes made in the changeset. Consider a more specific title that reflects the main changes, such as 'Fix kernel state filtering logic and support multiple kernel entry IDs per thread' or 'Reverse filter predicate logic in thread status analysis'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java`:
- Line 551: The filter predicate for currentTimes is incorrect: change the
boolean operator so it keeps times within the session window instead of almost
always allowing them; in the times.stream() filter that references
ss.getCurrentEndTime() and ss.getStartTime(), replace the OR condition with an
AND (so times satisfy time < ss.getCurrentEndTime() && time > ss.getStartTime(),
adjust inclusivity if needed) to ensure only timestamps inside the current time
window are collected before sorting and collecting into currentTimes.

In
`@analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java`:
- Around line 583-585: The threadIdsToEntryIds collection currently uses
Collectors.toList(), which allows duplicate tid.fLinked values per thread and
leads to duplicate kernel states during the status-expansion that follows;
change the collector on the tids stream (the code that builds
threadIdsToEntryIds in FlameChartDataProvider) to collect unique linked IDs
instead (e.g., use Collectors.toCollection(LinkedHashSet::new) or
Collectors.toSet() so each tid.fLinked appears only once per thread) and update
any downstream code that expects a List (the expansion loop that iterates over
threadIdsToEntryIds entries) to iterate the resulting Set or convert it to a
List if ordering is required.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e64aa7c9-86b3-4b37-be29-a807f56940e3

📥 Commits

Reviewing files that changed from the base of the PR and between b5bdbd3 and bdd20cc.

📒 Files selected for processing (2)
  • analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java

@arfio arfio force-pushed the thread-statuses-improvements branch from bdd20cc to 84539f9 Compare May 6, 2026 20:42
…he same tid

Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
@arfio arfio force-pushed the thread-statuses-improvements branch from 84539f9 to 9a9e5c5 Compare May 7, 2026 20:07
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java (2)

29-30: 💤 Low value

Remove commented-out duplicate imports.

Lines 29 and 59 are commented-out versions of their immediately adjacent active imports — debug artifacts that add noise.

🧹 Proposed cleanup
-//import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 import org.eclipse.tracecompass.tmf.core.model.annotations.Annotation;
-//import org.eclipse.tracecompass.tmf.core.model.annotations.Annotation;

Also applies to: 58-59

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java`
around lines 29 - 30, In FlameChartDataProviderTest remove the commented-out
duplicate import statements for java.util.stream.Collectors (the commented line
above the active import and the duplicate at the later import block) so only the
single active import remains; locate the commented "//import
java.util.stream.Collectors;" entries near the top of the class and delete them
to clean up noise introduced during editing.

439-444: 💤 Low value

Dead-code branch in verifyStates after the new assertEquals.

Adding assertEquals(expectedStates.size(), states.size()) at line 439 is the right fix — it catches both under- and over-delivery of states. However, it makes lines 442–444 unreachable: the loop variable i is bounded by states.size(), which is now asserted equal to expectedStates.size(), so i > expectedStates.size() - 1 is always false. The fail(...) can never execute.

🧹 Proposed cleanup
     assertEquals(expectedStates.size(), states.size());
     for (int i = 0; i < states.size(); i++) {
         String entryName = entry.getName();
-        if (i > expectedStates.size() - 1) {
-            fail("Unexpected state at position " + i + FOR_ENTRY + entryName + ": " + states.get(i));
-        }
         ITimeGraphState actual = states.get(i);
         ITimeGraphState expected = expectedStates.get(i);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java`
around lines 439 - 444, The new assertEquals(expectedStates.size(),
states.size()) makes the conditional inside verifyStates' loop unreachable;
remove the dead branch that checks "if (i > expectedStates.size() - 1) {
fail(... entry.getName() ... states.get(i)) }" or replace the loop to iterate
over expectedStates.size() and directly compare elements, so the fail(...) call
and the unreachable i check are deleted; update verifyStates to perform direct
comparisons between expectedStates.get(i) and states.get(i) (using
entry.getName() only in failure messages).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java`:
- Around line 29-30: In FlameChartDataProviderTest remove the commented-out
duplicate import statements for java.util.stream.Collectors (the commented line
above the active import and the duplicate at the later import block) so only the
single active import remains; locate the commented "//import
java.util.stream.Collectors;" entries near the top of the class and delete them
to clean up noise introduced during editing.
- Around line 439-444: The new assertEquals(expectedStates.size(),
states.size()) makes the conditional inside verifyStates' loop unreachable;
remove the dead branch that checks "if (i > expectedStates.size() - 1) {
fail(... entry.getName() ... states.get(i)) }" or replace the loop to iterate
over expectedStates.size() and directly compare elements, so the fail(...) call
and the unreachable i check are deleted; update verifyStates to perform direct
comparisons between expectedStates.get(i) and states.get(i) (using
entry.getName() only in failure messages).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7a65ed87-2044-4802-bcab-72b639b00a43

📥 Commits

Reviewing files that changed from the base of the PR and between bdd20cc and 9a9e5c5.

📒 Files selected for processing (4)
  • analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/src/org/eclipse/tracecompass/analysis/profiling/core/tests/FlameChartDataProviderTest.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core.tests/stubs/org/eclipse/tracecompass/analysis/profiling/core/tests/stubs2/KernelStateProviderStub.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelThreadInformationProvider.java
  • analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/internal/analysis/profiling/core/instrumented/FlameChartDataProvider.java

Signed-off-by: Arnaud Fiorini <fiorini.arnaud@gmail.com>
@arfio arfio force-pushed the thread-statuses-improvements branch from 9a9e5c5 to 32c7b50 Compare May 12, 2026 16:00
@arfio arfio requested a review from MatthewKhouzam May 12, 2026 17:28
Copy link
Copy Markdown
Contributor

@MatthewKhouzam MatthewKhouzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix!

@MatthewKhouzam MatthewKhouzam merged commit 3c40d1c into eclipse-tracecompass:master May 12, 2026
5 checks passed
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.

2 participants