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

[RFC005] Lazy propagation #1086

Merged
merged 33 commits into from
Feb 17, 2023
Merged

[RFC005] Lazy propagation #1086

merged 33 commits into from
Feb 17, 2023

Conversation

yannham
Copy link
Member

@yannham yannham commented Jan 30, 2023

Follow-up of #990.

Implement the second part of RFC005, namely getting rid of eager cross application of contracts during merging, and implement lazy propagation instead. All the bogus examples from RFC005 now gives the desired result within this PR.

The idea and challenges are in fact quite similar to the ones of lazy array contracts (#809). We probably should use %force% instead of %deep_seq% even more. We also have the same potential performance issue that contract application aren't cached as long as we don't destruct a record (same happen with arrays):

let r = {foo | Num = 1 + 1} in
r.foo + r.foo + r.foo

Here, the Num contract is applied lazily at each field access, and thus recomputed 3 times (the contract application, not 1 + 1 which is in its own thunk). Somehow, 1 + 1 | Num doesn't have a proper intermediate thunk to be cached. However, this is not something very hard to solve (namely by introducing this intermediate level of thunk/cache). It's just postponed to future work.

In the end, the net diff is negative, and this PR gets rid of a lot of complexities from the merging function, transformation and the overall pipeline. Retrospectively, beside the user-centric motivations of RFC005, it also seems to be the better choice with respect to maintainability.

@github-actions github-actions bot temporarily deployed to pull request January 30, 2023 11:50 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 30, 2023 14:42 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 30, 2023 15:43 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 30, 2023 17:05 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 30, 2023 17:17 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 30, 2023 17:39 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 31, 2023 08:27 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 31, 2023 15:44 Inactive
@github-actions github-actions bot temporarily deployed to pull request January 31, 2023 15:59 Inactive
@yannham yannham marked this pull request as ready for review January 31, 2023 16:32
@github-actions github-actions bot temporarily deployed to pull request January 31, 2023 16:34 Inactive
@yannham yannham force-pushed the feature/rfc005-lazy-propagation branch from 29d4ef6 to bb4d423 Compare January 31, 2023 17:10
@github-actions github-actions bot temporarily deployed to pull request January 31, 2023 17:14 Inactive
Base automatically changed from task/rfc005-implem-draft to master February 8, 2023 09:29
The apply_contract phase doesn't make sense anymore in the lazy
propagation model of RFC005. However, we still need to convert "static"
annotations (the one provided by the user) to pending contracts, the
data that the runtime manipulates and cares about. This commit update
the contract application phase to become a pending contract generation
phase.
Continue the implementation of lazy propagation. Patch the various
record destructors (field access, force, equality, etc.) to apply
potential pending contracts when elements are requested.
Eager application of contracts acted directly on the annotation attached
to a field. Those were thus transformed by the share_normal_form to make
it work with recursive overriding.

Now, runtime contracts are all conained in the new pending_contracts
field. We can let metadata alone (that is, we don't have to transform
them anymore), while we have to transform pending_contracts, which is
what this commit does.
yannham and others added 9 commits February 14, 2023 10:19
Co-authored-by: Oghenevwogaga Ebresafe <[email protected]>
Co-authored-by: Oghenevwogaga Ebresafe <[email protected]>
Co-authored-by: Oghenevwogaga Ebresafe <[email protected]>
Co-authored-by: Oghenevwogaga Ebresafe <[email protected]>
Co-authored-by: Oghenevwogaga Ebresafe <[email protected]>
Co-authored-by: Oghenevwogaga Ebresafe <[email protected]>
Co-authored-by: Oghenevwogaga Ebresafe <[email protected]>
@github-actions github-actions bot temporarily deployed to pull request February 14, 2023 09:30 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 14, 2023 09:45 Inactive
src/error.rs Outdated Show resolved Hide resolved
Co-authored-by: Viktor Kleen <[email protected]>
@github-actions github-actions bot temporarily deployed to pull request February 15, 2023 13:57 Inactive
@github-actions github-actions bot temporarily deployed to pull request February 16, 2023 14:55 Inactive
Copy link
Contributor

@vkleen vkleen left a comment

Choose a reason for hiding this comment

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

Together with the performance improvement we discussed out-of-band this looks good!

@github-actions github-actions bot temporarily deployed to pull request February 16, 2023 16:19 Inactive
src/transform/mod.rs Outdated Show resolved Hide resolved
Co-authored-by: Viktor Kleen <[email protected]>
@yannham yannham added the merge-queue merge on green CI label Feb 17, 2023
@github-actions github-actions bot temporarily deployed to pull request February 17, 2023 09:42 Inactive
@yannham yannham merged commit 8a73309 into master Feb 17, 2023
@yannham yannham deleted the feature/rfc005-lazy-propagation branch February 17, 2023 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-queue merge on green CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nickel query doesn't print types
3 participants