Skip to content

Review of dataflow package#1707

Merged
wmdietl merged 12 commits into
masterfrom
dataflow-perf
May 12, 2026
Merged

Review of dataflow package#1707
wmdietl merged 12 commits into
masterfrom
dataflow-perf

Conversation

@wmdietl
Copy link
Copy Markdown
Member

@wmdietl wmdietl commented May 11, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 11, 2026 20:17
addToWorklistAgain);
}
} else {
S regular = inputBefore.copy().getRegularStore();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why do we need to do the copy() at all?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We don't need it. getRegularStore() either computes a fresh leastUpperBound result (two-store case) or returns the store directly (single-store case). Since the analysis never mutates stores in-place — leastUpperBound/widenedUpperBound always return fresh stores, and the transfer function always works on a copy() of inputBefore — aliasing is safe. Removed in 12b976b.

public static boolean listIsDeterministic(
List<? extends @Nullable JavaExpression> list, AnnotationProvider provider) {
return list.stream().allMatch(je -> je == null || je.isDeterministic(provider));
for (int i = 0, n = list.size(); i < n; ++i) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot Assuming this is on a hot path, is it worth replacing lambdas by explicit loops to improve performance?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The lambda at line 167 was already replaced with an explicit for loop in commit 3345ace (the "Avoid lambdas and re-computations" change). The current code avoids Stream creation and lambda overhead on this hot path.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors multiple dataflow utilities to reduce allocations/overhead (replacing streams with loops, avoiding unnecessary map lookups/copies) and tightens some internal invariants around identity-based data structures and lazy copying in analysis results.

Changes:

  • Simplifies purity queries and adds explicit handling for auto-generated record members.
  • Replaces several stream/map patterns with loops and direct get() usage to reduce overhead.
  • Refines lazy-copy behavior in AnalysisResult and optimizes some CFG/dataflow lookups.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dataflow/src/main/java/org/checkerframework/dataflow/util/PurityUtils.java Refactors deterministic/side-effect-free checks; special-cases record accessors.
dataflow/src/main/java/org/checkerframework/dataflow/expression/MethodCall.java Replaces stream-based modifiability check with loops.
dataflow/src/main/java/org/checkerframework/dataflow/expression/JavaExpression.java Replaces streams with loops and refactors varargs handling to reduce repeated calls.
dataflow/src/main/java/org/checkerframework/dataflow/constantpropagation/ConstantPropagationStore.java Uses Map.get() instead of containsKey()+get() patterns.
dataflow/src/main/java/org/checkerframework/dataflow/cfg/ControlFlowGraph.java Uses identity-based visited set for DFS order and minor lookup/loop refactors.
dataflow/src/main/java/org/checkerframework/dataflow/analysis/TransferInput.java Adjusts hashCode() to align with equals() semantics.
dataflow/src/main/java/org/checkerframework/dataflow/analysis/ForwardAnalysisImpl.java Attempts to reduce copying during exceptional successor propagation.
dataflow/src/main/java/org/checkerframework/dataflow/analysis/AnalysisResult.java Splits lazy-copy tracking to avoid copying tree/postfix maps when only nodeValues may be mutated.
dataflow/src/main/java/org/checkerframework/dataflow/analysis/AbstractAnalysis.java Avoids materializing full transitive operand sets by using an early-exit traversal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI commented May 11, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • central.sonatype.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14.5-bin/690y85m0j9nfaub7xoiayko8a/gradle-8.14.5/lib/gradle-daemon-main-8.14.5.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

wmdietl and others added 2 commits May 11, 2026 16:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@wmdietl wmdietl merged commit b609781 into master May 12, 2026
50 checks passed
@wmdietl wmdietl deleted the dataflow-perf branch May 12, 2026 01:07
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.

3 participants