Skip to content

Manually unbox closure in Hashtbl.mem#11500

Merged
nojb merged 3 commits intoocaml:trunkfrom
sim642:hashtbl-mem-unbox-closure
Aug 22, 2022
Merged

Manually unbox closure in Hashtbl.mem#11500
nojb merged 3 commits intoocaml:trunkfrom
sim642:hashtbl-mem-unbox-closure

Conversation

@sim642
Copy link
Copy Markdown
Contributor

@sim642 sim642 commented Aug 21, 2022

This avoids closure allocation and the associated GC call in mem. Numerous other Hashtbl functions (remove, find, find_opt, replace) are already like this. In particular, this was done to find for non-allocation reasons way back in d48c6cf.

I don't have any data for performance change one way or another. A while back while perf-ing some Hashtbl heavy code, I noticed GC calls in mem, which was unexpected as this lookup shouldn't need any allocation, and after some digging realized it's the mem_in_bucket closure causing that.

sim642 added 2 commits August 21, 2022 16:15
This avoids closure allocation and GC call in mem.
Numerous other Hashtbl functions are already like this,
particularly find from d48c6cf.
Copy link
Copy Markdown
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

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

LGTM

Maybe a Changes entry would be in order: "Make Hashtbl.mem non-allocating".

@sim642
Copy link
Copy Markdown
Contributor Author

sim642 commented Aug 22, 2022

Maybe a Changes entry would be in order: "Make Hashtbl.mem non-allocating".

Added.

@nojb nojb added the merge-me label Aug 22, 2022
@nojb nojb merged commit 712ee62 into ocaml:trunk Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants