Skip to content

Use a map to memoize looked-up items in signatures #1049

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

Closed
wants to merge 1 commit into from
Closed

Use a map to memoize looked-up items in signatures #1049

wants to merge 1 commit into from

Conversation

gpetiot
Copy link
Collaborator

@gpetiot gpetiot commented Nov 29, 2023

Opening this PR for ocaml-benchmarks. Follow-up of #1039

@gpetiot gpetiot changed the title Use a hashtable to lookup items in signatures Use a map to memoize looked-up items in signatures Dec 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Lookups are cached in each Component.Signature values to help avoid time
blowup on large signatures due to the linear lookup.
let find_in_sig :
Signature.t -> string -> (Signature.item -> 'a option) -> 'a option =
fun sg name f ->
try find_map f (StringMap.find name sg.lookup_cache)
Copy link
Collaborator

Choose a reason for hiding this comment

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

With @gpetiot we found a bug here:

Say a signature contains both a module and a module type named Foo. A first lookup to the module would populate the cache with only the module. A second lookup to signature_in_sig would find something in the cache and never go through the linear lookup to find the module type.

@Julow
Copy link
Collaborator

Julow commented Jan 15, 2024

We'll close this prototype due to a lack of time.

@Julow Julow closed this Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants