Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update the test_cs.rs #44

Closed
wants to merge 6 commits into from
Closed

refactor: update the test_cs.rs #44

wants to merge 6 commits into from

Conversation

flyq
Copy link
Contributor

@flyq flyq commented Oct 24, 2023

No description provided.

@flyq
Copy link
Contributor Author

flyq commented Oct 24, 2023

I'm not sure what makes the test take so long

@flyq flyq marked this pull request as draft October 24, 2023 05:17
@flyq
Copy link
Contributor Author

flyq commented Oct 24, 2023

I'm not sure what makes the test take so long

because the origin modification to eval_lc introduces the collect operation on Iterator, seriously reducing performance

@flyq flyq marked this pull request as ready for review October 24, 2023 07:22
crates/bellpepper-core/src/lc.rs Outdated Show resolved Hide resolved
crates/bellpepper-core/src/util_cs/test_cs.rs Show resolved Hide resolved
@flyq flyq requested a review from huitseeker October 26, 2023 14:17
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

@flyq, thanks for the contribution. Bellpepper-core is a load-bearing crate with significant dependencies, and aside from providing refactorings of existing methods, I have missed what this PR fixes (in your commits' own terms).

Because of that large production footprint, changes to bellpepper-core tend to be in "if it ain't broke, don't fix it" mode, and / or require strong evidence of significant improvement before getting in.

In other circumstances, your PR would have been welcome as an arguable improvement in readability, but the specific context of this crate makes accepting the change more difficult - unless I have missed a nuance about a major correctness or performance improvement brought by your change, of course. Please let me know if that's the case.

Comment on lines +63 to +66
.iter()
.filter(|(_, v)| **v != Scalar::ZERO)
.map(|(k, v)| (OrderedVariable(k), *v))
.collect()
Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, but since the TestCS type is used in (tests of) gigantic proving projects, the performance matters. Here the FromIterator implementation of BTreeMap is sorting the keys of the input before insertion, so I would need to see micro-benchmarks of this method against the prior implementation before considering this change (to compare your $O(n \log n$ vs. the prior $n O(\log n)$).

@huitseeker
Copy link
Contributor

Closing to make the status clear, but I'll track this issue for a few days, please do comment if you think there's something I missed.

@huitseeker huitseeker closed this Nov 1, 2023
@flyq
Copy link
Contributor Author

flyq commented Nov 2, 2023

Yeah, as you said, it's just to improve code readability, the performance difference has not been rigorously tested. Keeping it as is is probably the best option

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