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

Speed up OptMergePass by 1.75x. #3975

Merged
merged 5 commits into from
Oct 9, 2023
Merged

Conversation

rmlarsen
Copy link
Contributor

@rmlarsen rmlarsen commented Oct 2, 2023

The main speedup comes from switching away from using SHA1 hash to using std::hash<std::string> for fingerprinting cells. There is no need to use an expensive cryptographic hash for fingerprinting in this context.

Flamegraph of benchmark timings from synthesis of a representative circuit:

Before:
image

After:
image

The main speedup comes from swithing from using a SHA1 hash to std::hash<std::string>. There is no need to use an expensive cryptographic hash for fingerprinting in this context.
@whitequark
Copy link
Member

You could probably use an even cheaper hash than SHA1.

kernel/celltypes.h Outdated Show resolved Hide resolved
@povik
Copy link
Member

povik commented Oct 3, 2023

@whitequark

You could probably use an even cheaper hash than SHA1.

The change here is away from SHA1.

Copy link
Collaborator

@Ravenslofty Ravenslofty left a comment

Choose a reason for hiding this comment

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

see the comments I made, plus a more general "IdString should be passed by value".

kernel/rtlil.h Show resolved Hide resolved
passes/opt/opt_merge.cc Outdated Show resolved Hide resolved
@rmlarsen
Copy link
Contributor Author

rmlarsen commented Oct 3, 2023

@Ravenslofty is there a setting to auto-squash my commits here? I noticed my commits didn't get squashed for the PRs you merged yesterday.

@Ravenslofty
Copy link
Collaborator

There is, but I have the habit of "rebase and merge" to not lose history; if you want your commits squashed I can do that with my next merge.

@povik
Copy link
Member

povik commented Oct 3, 2023

Btw @Ravenslofty we were discussing in the dev JF that doing merge commits is better since they have the PR number, which is otherwise lost.

@Ravenslofty
Copy link
Collaborator

Well okay.

@rmlarsen
Copy link
Contributor Author

rmlarsen commented Oct 3, 2023

OK, I'll leave that up to you. I'm just used to us squashing for Eigen.

@povik
Copy link
Member

povik commented Oct 3, 2023

FWIW squash commits should have the PR number and are ok too, it's just the rebase that loses it.

@rmlarsen
Copy link
Contributor Author

rmlarsen commented Oct 3, 2023

PTAL

Copy link
Collaborator

@Ravenslofty Ravenslofty left a comment

Choose a reason for hiding this comment

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

Yeah, this looks much better.

@rmlarsen rmlarsen changed the title Speed up OptMergePass by 1.7x. Speed up OptMergePass by 1.75x. Oct 3, 2023
@rmlarsen
Copy link
Contributor Author

rmlarsen commented Oct 3, 2023

Yeah, this looks much better.

I just ran the measurements again, and it actually ended up slightly faster too. Go figure... :-)

@Ravenslofty Ravenslofty added the discuss to be discussed at next dev jour fixe (see #devel-discuss at https://yosyshq.slack.com/) label Oct 8, 2023
@nakengelhardt nakengelhardt merged commit 3e22791 into YosysHQ:master Oct 9, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss to be discussed at next dev jour fixe (see #devel-discuss at https://yosyshq.slack.com/)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants