Skip to content

Fixes from benchmark#508

Open
AnsonYeung wants to merge 8 commits into
hkust-taco:hkmc2from
AnsonYeung:benchmark-fixes
Open

Fixes from benchmark#508
AnsonYeung wants to merge 8 commits into
hkust-taco:hkmc2from
AnsonYeung:benchmark-fixes

Conversation

@AnsonYeung
Copy link
Copy Markdown
Contributor

The benchmark have quite some outdated code and refuse to work again. This moves the Benchmark.mls file to the correct place (the old location was not compiled) and fixes a time limit blowup on BlockSimplifier.

Copy link
Copy Markdown
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

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

This PR is marked as ready, but it doesn't look like it is. Please document the ins and outs of your changes.

def analyzeValues(asst: AssignInfo): Set[Value.RefLike] =
if emptyHanded && litValue === false then
analyzeAssignments(asst)
// analyzeAssignments(asst)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the rationale for commenting this? Does this lead to any missed opportunities?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

analyzeAssignment is just a no-op

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This code leads to a time blowup in compile test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be really helpful if you could come up with a minimized reproduction of the problem where the blowup occurs and add it to the diff-tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I found a test case that blow up even with this change. But this change is still beneficial.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FWIW, here's the diagnosis from Codex, which seems correct:

Cause: branch merges were building a shared AssignInfo DAG, but several simplifier queries walked it as if it were a tree. Repeated if maybe do set x += 1 caused the same merged histories to be revisited exponentially, especially through assignedPureCallPrefix; value analysis and match-shape analysis had the same risk.

I don't like the fix proposed by Codex very much (it memoizes things with an ad-hoc IdentityHashMap); I think adding a lazy val in AssignInfo to replace the analyzeValues calls should be enough.

Copy link
Copy Markdown
Contributor Author

@AnsonYeung AnsonYeung Jun 3, 2026

Choose a reason for hiding this comment

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

I think I can't quite reproduce the problem I was finding with the current commented code. Maybe the issue is fixed in the hkmc2 branch already but the compile test were not terminating even at 60s before I commented those out. I don't think that's triggering this particular exponential problem since the problem went away immediately after I commented the analyzeAssignment out.

Copy link
Copy Markdown
Contributor Author

@AnsonYeung AnsonYeung Jun 3, 2026

Choose a reason for hiding this comment

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

nevermind I merged hkmc2 into my branch and can still reproduce the massive time difference between those commented out or not. Could be related to my TryCatch handling...

Copy link
Copy Markdown
Contributor Author

@AnsonYeung AnsonYeung Jun 3, 2026

Choose a reason for hiding this comment

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

After troubleshooting I confirmed the other issue is also an exponential blowup. But most likely some branches are pruned away completely when assignResult is commented out. So I think by fixing this case the assignResult should be somewhat fixed as well (at least not exponential, maybe quadratic).

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