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

Represent implicits as a tree instead of a list to make conjoining them constant time #3521

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

nikswamy
Copy link
Collaborator

@nikswamy nikswamy commented Oct 4, 2024

With @mtzguido, we noticed that concatenating implicit argument lists makes type checking large expressions quadratic, as reported by @jaylorch and @LukeXuan

This PR represents implicits as a tree, enabling a constant time operation to conjoin them, coercing them to a list only when needed eventually to iterate over all implicits.

@mtzguido
Copy link
Member

mtzguido commented Oct 4, 2024

I wonder if this will also improve the performance of the long lists in HACL*. @R1kM, @msprotz , could you remind me which module that was so I check it?

@nikswamy
Copy link
Collaborator Author

nikswamy commented Oct 4, 2024

I think it's things like Test.Vectors.Chacha20Poly1305.fst that take a long time to check. I think this PR will help, but those list literals are also written as polymorphic instantiations of Cons.

If it were to be written as

let cons_u8 = Cons #u8`
let nil_u8 = Nil #u8

let l = cons_u8 0x9buy <| cons_u8 0x18uy <| ...

I would expect to see significant speedups

@nikswamy nikswamy merged commit 55b74ff into master Oct 4, 2024
20 of 21 checks passed
@nikswamy nikswamy deleted the nik_implicits_t branch October 4, 2024 23:50
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