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

[RFC007] Extract runtime contract equality out of typecheck #2130

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

yannham
Copy link
Member

@yannham yannham commented Dec 23, 2024

This PR continues the preparation work to migrate the typechecker to the new AST. One current blocker is that typecheck::eq is used both by the typechecker and at runtime for contract deduplication. We need to get rid of this module when switching the typechecker implementation, while still needing to perform contract deduplication at runtime (until the landing of the bytecode virtual machine).

This PR extracts the code from typecheck::eq for contract deduplication in a new module, so that the runtime isn't dependent on typecheck anymore. The code is specialized (as it doesn't need to handle static contract equality), and in order to eliminate the dependence on UnifType, we drop the ability to compare polymorphic types. The latter is the only reason typecheck::eq operated on UnifType instead of Type (which makes it dependent on the old typechecker), but the motivation is not very convincing: how many times do we encounter a type annotation, itself inside a contract annotation, such that annotation is a polymorphic type AND it happens to be a candidate for deduplication? Our intuition would be: zero.

This hypothesis has been validated on our working benchmarks, as --metrics show detailed data on contract deduplication - including the total count of deduplicated contracts - which doesn't change between this PR and master.

This continues the preparative work to migrate the typechecker to the
new AST. One current blocker is that the `typecheck::eq` is used both by
the typechecker and at runtime for contract deduplication; however we
will get rid of it eventually, while still needing to perform contract
deduplication (until the landing of the bytecode virtual machine).

This commit extract the code from `typecheck::eq` for contract
deduplication in a new module, so that the runtime isn't dependent on
`typecheck` anymore. The code is specialized (as it doesn't need to
handle static contract equality), and in order to eliminate the
dependence on `UnifType`, we drop the ability to compare polymorphic
type. The latter is the only reason `typecheck::eq` operated on
`UnifType` instead of `Type`, but the motivation is not very convincing:
how many times do we encounter a type annotation, itself inside a
contract annotation, such that annotation is a polymorphic type AND it
happens to be a candidate for deduplication? Our intuition would be: zero.

This hypothesis will be validated on our working benchmarks
(instrumentation counts each contract deduplication)
@yannham yannham requested a review from jneem December 23, 2024 15:16
core/src/eval/contract_eq.rs Outdated Show resolved Hide resolved
@yannham yannham enabled auto-merge December 24, 2024 08:47
@yannham yannham added this pull request to the merge queue Dec 24, 2024
Merged via the queue into master with commit cae9894 Dec 24, 2024
5 checks passed
@yannham yannham deleted the rfc007/extract-contract-dedup branch December 24, 2024 09:01
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