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

Avoid using toAbsoluteName so much in rewriter #1263

Closed
brianhuffman opened this issue Mar 15, 2021 · 0 comments · Fixed by #1272
Closed

Avoid using toAbsoluteName so much in rewriter #1263

brianhuffman opened this issue Mar 15, 2021 · 0 comments · Fixed by #1272
Labels
performance Issues that involve or include performance problems tech debt Issues that document or involve technical debt

Comments

@brianhuffman
Copy link
Contributor

During rewriting, the function toAbsoluteName from Name.hs is called repeatedly by the toPat function, which is used for matching terms in the rewriter. Profiling of the blst CI tests shows that identText (which is called by toAbsoluteName) performs as much as 6% of all the allocation of the entire saw program, because it does a bunch of concatenation of names. This allocation is unnecessary and should be avoided.

@brianhuffman brianhuffman transferred this issue from GaloisInc/saw-core Apr 27, 2021
@brianhuffman brianhuffman added tech debt Issues that document or involve technical debt performance Issues that involve or include performance problems labels Apr 27, 2021
brianhuffman pushed a commit that referenced this issue Apr 27, 2021
Fixes #1263.

We now use `identBaseName` instead of `identText` in the `termToPat`
definition. While `identText` concatenates the module name and base
name, `identBaseName` just returns the base name directly.

Using only the base name means that there is a chance of name collisions
between constants that differ only by module name. However, term nets
are only used as an approximate filter prior to term matching; it is
not a problem if a few extra hits are returned from time to time.

Ultimately it might be better to replace the use of `Text` in the term
net `Atom` constructor with a more specialized key type; for example
with `ExtCns` names we could use the `VarIndex` for matching. However,
this would require modifying the term net library.
brianhuffman pushed a commit that referenced this issue Apr 28, 2021
Fixes #1263.

We now use `identBaseName` instead of `identText` in the `termToPat`
definition. While `identText` concatenates the module name and base
name, `identBaseName` just returns the base name directly.

Using only the base name means that there is a chance of name collisions
between constants that differ only by module name. However, term nets
are only used as an approximate filter prior to term matching; it is
not a problem if a few extra hits are returned from time to time.

Ultimately it might be better to replace the use of `Text` in the term
net `Atom` constructor with a more specialized key type; for example
with `ExtCns` names we could use the `VarIndex` for matching. However,
this would require modifying the term net library.
brianhuffman pushed a commit that referenced this issue Sep 14, 2021
Fixes #1263.

We now use `identBaseName` instead of `identText` in the `termToPat`
definition. While `identText` concatenates the module name and base
name, `identBaseName` just returns the base name directly.

Using only the base name means that there is a chance of name collisions
between constants that differ only by module name. However, term nets
are only used as an approximate filter prior to term matching; it is
not a problem if a few extra hits are returned from time to time.

Ultimately it might be better to replace the use of `Text` in the term
net `Atom` constructor with a more specialized key type; for example
with `ExtCns` names we could use the `VarIndex` for matching. However,
this would require modifying the term net library.
@mergify mergify bot closed this as completed in #1272 Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issues that involve or include performance problems tech debt Issues that document or involve technical debt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant