Conversation
📝 WalkthroughWalkthroughAdds a fast-fail hook Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
6fb5f27 to
5202ca0
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In
`@analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/ActiveTidStateProvider.java`:
- Around line 75-78: The filter in considerEvent currently excludes sched_switch
events (it uses !event.getName().equals(fSchedSwitch)) which is inverted and
causes eventHandle (which reads fNextTid via layout.fieldNextTid()) to operate
on events without that field; change considerEvent to only accept sched_switch
events by removing the negation so it returns true when
event.getName().equals(fSchedSwitch), ensuring eventHandle sees events that
contain fNextTid; verify fSchedSwitch and fNextTid references (and
layout.fieldNextTid()) remain unchanged.
In
`@analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelStateProvider.java`:
- Line 105: fValidEventNames is populated but never read (dead code); remove the
field declaration fValidEventNames and any code that populates it (references to
fValidEventNames), and then remove the now-unused Set/HashSet imports; ensure
considerEvent continues to use fEventNames.containsKey(name) so behavior is
unchanged.
- Around line 17-21: Remove the unused imports ArrayList and List from
KernelStateProvider.java to fix the CI build; locate the import lines
referencing java.util.ArrayList and java.util.List in the import block at the
top of the file and delete those two import statements so only the actually used
imports (e.g., HashSet, Map, Set) remain.
🧹 Nitpick comments (3)
tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/AbstractTmfStateProvider.java (1)
443-455: Javadoc references "function entry/exit analysis" — too narrow for this general-purpose hook.The Javadoc on line 444 says "function entry/exit analysis," which appears to be copied from
CallStackStateProvider. Since this method lives in the abstract base class and is used by many different providers (kernel, memory, CPU usage, TID), the description should reflect its general filtering purpose.📝 Suggested Javadoc fix
/** - * Check if this event should be considered at all for function entry/exit - * analysis. This check is a fast fail to allow events to not be processed as much. + * Check if this event should be considered for state change processing. + * This is a fast-fail filter to skip irrelevant events early. * * `@param` event * The event to check * `@return` If false, the event will be ignored by the state provider. If * true processing will continue. * `@since` 10.2 */lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java (1)
162-168: LGTM! Minor: missing space afterifon line 164.The filtering logic is correct and aligns well with the existing
eventHandlelogic.- if(!super.considerEvent(event)) { + if (!super.considerEvent(event)) {analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelStateProvider.java (1)
183-194: Minor formatting issues on lines 190 and 193.
- Line 190: trailing space before
):fEventNames.containsKey(name) )- Line 193: missing space before
||:isSyscallEntry(name)|| isSyscallExit(name)📝 Proposed fix
- if (fEventNames.containsKey(name) ) { + if (fEventNames.containsKey(name)) { return true; } - return isSyscallEntry(name)|| isSyscallExit(name); + return isSyscallEntry(name) || isSyscallExit(name);
...nux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/tid/ActiveTidStateProvider.java
Show resolved
Hide resolved
...src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelStateProvider.java
Outdated
Show resolved
Hide resolved
...src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelStateProvider.java
Show resolved
Hide resolved
5202ca0 to
7000cff
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In
`@analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelStateProvider.java`:
- Around line 181-192: In considerEvent(ITmfEvent event) clean up the minor
formatting: remove the trailing space inside the contains call so
"fValidEventNames.contains(name) )" becomes "fValidEventNames.contains(name)"
and add a space before the logical operator so "isSyscallEntry(name)||
isSyscallExit(name)" becomes "isSyscallEntry(name) || isSyscallExit(name)"; keep
all logic unchanged and only adjust whitespace around the contains call and the
|| operator.
In
`@lttng/org.eclipse.tracecompass.lttng2.ust.core/src/org/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java`:
- Around line 162-168: In UstMemoryStateProvider.override considerEvent, fix the
style issue by adding a space after the if keyword: change the condition check
in considerEvent (the line currently "if(!super.considerEvent(event))") to use
"if (!super.considerEvent(event))" so the method body remains the same (still
returns false and then checks fEventNames.containsKey(event.getName())).
In
`@tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/AbstractTmfStateProvider.java`:
- Around line 443-455: The Javadoc for the protected method
considerEvent(ITmfEvent event) in AbstractTmfStateProvider incorrectly
references "function entry/exit analysis" which is too specific; update the
method comment to describe it as a general-purpose fast-fail hook for whether an
event should be processed by any state provider (e.g., kernel, memory,
CPU-usage, callstack), explaining that returning false skips processing and
returning true continues processing, and keep the `@since` and param/return tags
intact; locate the considerEvent method in AbstractTmfStateProvider and replace
the specific wording with a generic description that applies to all state
providers.
🧹 Nitpick comments (3)
analysis/org.eclipse.tracecompass.analysis.profiling.core/src/org/eclipse/tracecompass/analysis/profiling/core/callstack/CallStackStateProvider.java (1)
204-207: Redundant override—parent class already defaults toreturn true.The parent
AbstractTmfStateProviderdefinesconsiderEvent()with a default implementation that returnstrue, and the event filter is executed inEventProcessor.run()beforeeventHandle()is dispatched. This override repeats the parent's default behavior and adds no new functionality.However, the override is defensible as documentation: it explicitly preserves the pre-existing Javadoc contract for
CallStackStateProvidersubclasses and signals that this provider does not perform event filtering. If the intent is to document this behavior for subclass authors, the override and its Javadoc are reasonable. If clarity is the only goal, consider removing it.tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/AbstractTmfStateProvider.java (1)
322-325: Pre-filter executes post-dequeue, not pre-enqueue — queue pressure is unchanged.The commit message states the goal is to "reduce queue fill by enqueuing only events that may be read by analyses," but
considerEventis called afterfEventsQueue.take()(consumer side), so every event still passes through theBufferedBlockingQueue. The optimization skips the heaviereventHandlepath, which is valuable, but queue memory pressure and blocking inprocessEventremain the same.If the intent is truly to reduce enqueue volume, consider moving the
considerEventcheck intoprocessEvent()(producer side):♻️ Sketch: filter on the producer side
`@Override` public void processEvent(ITmfEvent event) { if (!fStateSystemAssigned) { throw new IllegalStateException(...); } fPropagateExceptions.run(); - ITmfEvent curEvent = event; - fEventsQueue.put(curEvent); + if (considerEvent(event)) { + fEventsQueue.put(event); + } }Note: moving the check to the producer side would change the threading model —
considerEventwould then run on the producer thread instead of the consumer thread. If subclass overrides access fields that are only safe on the consumer thread, this could introduce concurrency issues. Evaluate whether the subclass implementations are thread-safe before making this change.analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernelmemoryusage/KernelMemoryStateProvider.java (1)
64-68:TreeSetis unnecessary for a 2-element membership-check set.
fToConsideris only ever used forcontains()calls with exactly two elements. AHashSet(likeKernelStateProvideruses) would be more idiomatic for unordered membership tests.TreeSetadds ordering overhead that isn't leveraged here.♻️ Suggested change
-import java.util.TreeSet; +import java.util.HashSet;- private final Set<String> fToConsider = new TreeSet<>(); + private final Set<String> fToConsider = new HashSet<>();
...src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelStateProvider.java
Show resolved
Hide resolved
...rg/eclipse/tracecompass/internal/lttng2/ust/core/analysis/memory/UstMemoryStateProvider.java
Show resolved
Hide resolved
...ass.tmf.core/src/org/eclipse/tracecompass/tmf/core/statesystem/AbstractTmfStateProvider.java
Show resolved
Hide resolved
Add a pre-filter activity to reduce queue fill. Only enqueue data that may be read by analyses. This patch updates: * ActiveTidStateProvider * KernelStateProvider * KernelMemoryStateProvider * KernelCpuUsageStateProvider * CallstackStateProvider [Changed] add filter to event dispatch to speed up trace compass Change-Id: I51c8cb5594812491c85a2cbafe8d32fd4f6bc0c5 Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
7000cff to
f623a10
Compare
What it does
This PR adds pre-filtering to event dispatch to speed up trace parsing by reducing queue fill. Only events that may be read by analyses are enqueued, improving performance.
The following state providers are updated to implement event filtering:
How to test
Follow-ups
Add more analyses.
Summary by CodeRabbit