Skip to content

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Sep 28, 2025

This PR adds HashMap::from_iter_in to the arena allocated HashMap.

@github-actions github-actions bot added the C-enhancement Category - New feature or request label Sep 28, 2025
Copy link
Member Author

sapphi-red commented Sep 28, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 28, 2025

CodSpeed Instrumentation Performance Report

Merging #14211 will not alter performance

Comparing 09-28-feat-allocator-add-hashmap-from-iter-in (7a1c339) with main (3656908)

Summary

✅ 37 untouched

Copy link
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

I think it's good to add this method. It's a basic functionality, and weird we didn't have it already.

One thing: hashbrown::HashMap uses the lower bound of the size hint:

https://github.com/rust-lang/hashbrown/blob/9e812fdd350b58e9d60888c1f9dc9c5eb953f716/src/map.rs#L4538-L4554

Whereas your impl here uses the upper bound.

I don't know which is best - it depends on the iterator! Upper bound could be a large over-estimate in the case of a filter iterator.

Unless you have some reason to think upper bound is better in our use cases, I would tend to copy hashbrown. It's the underlying implementation of Rust std lib's HashMap, so I'd assume there's some rationale for how it is.

@sapphi-red sapphi-red force-pushed the 09-28-feat-allocator-add-hashmap-from-iter-in branch from 6065c44 to 1767176 Compare October 3, 2025 12:14
@sapphi-red
Copy link
Member Author

I didn't have any reason to use the upper bound. Sorry, I had not taken a look at the code after it was generated by AI. I've now taken a look and aligned the implementation with hashbrown.

@sapphi-red sapphi-red marked this pull request as ready for review October 3, 2025 12:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a constructor to create an arena-allocated HashMap from an iterator.

  • Introduces HashMap::from_iter_in to build a map using a provided allocator
  • Documents the new API

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@overlookmotel overlookmotel left a comment

Choose a reason for hiding this comment

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

I'll follow up with a PR to add some comments.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Oct 4, 2025
Copy link
Member

overlookmotel commented Oct 4, 2025

Merge activity

This PR adds `HashMap::from_iter_in` to the arena allocated HashMap.
@graphite-app graphite-app bot force-pushed the 09-28-feat-allocator-add-hashmap-from-iter-in branch from 95be81c to 7a1c339 Compare October 4, 2025 08:49
@graphite-app graphite-app bot merged commit 7a1c339 into main Oct 4, 2025
28 checks passed
@graphite-app graphite-app bot deleted the 09-28-feat-allocator-add-hashmap-from-iter-in branch October 4, 2025 08:55
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 4, 2025
graphite-app bot pushed a commit that referenced this pull request Oct 4, 2025
)

Follow-on after #14211. Add comments reflecting conversation we had on that PR.
@Boshen Boshen mentioned this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants