Skip to content

Conversation

@sapphi-red
Copy link
Member

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

Adds the arena-allocated HashSet.

@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 #14212 will not alter performance

Comparing 09-28-feat-allocator-add-hashset (f37b211) with main (0c14e50)

Summary

✅ 37 untouched

@sapphi-red sapphi-red changed the title feat(allocator): add HashMap::from_iter_in feat(allocator): add HashSet Sep 28, 2025
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.

Are the implementations of the various methods copied from hashbrown?

@sapphi-red sapphi-red force-pushed the 09-28-feat-allocator-add-hashset branch from b32ba2a to feeba46 Compare October 3, 2025 12:14
@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

Are the implementations of the various methods copied from hashbrown?

Probably it was.

The AI generated the code as a wrapper around HashMap. But while checking the implementation, I found that it is easier to implement as a wrapper around hashbrown::HashSet (because then we can utilize Deref). So I've rewritten the implementation.

@sapphi-red sapphi-red force-pushed the 09-28-feat-allocator-add-hashset branch from feeba46 to d50d949 Compare October 3, 2025 12:30
@sapphi-red sapphi-red marked this pull request as ready for review October 3, 2025 12:32
@sapphi-red sapphi-red force-pushed the 09-28-feat-allocator-add-hashset branch from d50d949 to 2799748 Compare October 3, 2025 13:27
@graphite-app graphite-app bot changed the base branch from 09-28-feat-allocator-add-hashmap-from-iter-in to graphite-base/14212 October 4, 2025 08:49
@graphite-app graphite-app bot force-pushed the graphite-base/14212 branch from 95be81c to 7a1c339 Compare October 4, 2025 08:57
@graphite-app graphite-app bot force-pushed the 09-28-feat-allocator-add-hashset branch from 2799748 to b09cd7d Compare October 4, 2025 08:57
@graphite-app graphite-app bot changed the base branch from graphite-base/14212 to main October 4, 2025 08:57
@graphite-app graphite-app bot force-pushed the 09-28-feat-allocator-add-hashset branch from b09cd7d to 8376ab7 Compare October 4, 2025 08:58
Copilot AI review requested due to automatic review settings October 4, 2025 09:14
@overlookmotel overlookmotel force-pushed the 09-28-feat-allocator-add-hashset branch from 8376ab7 to 994240b Compare October 4, 2025 09:14
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

This PR adds a new arena-allocated HashSet type to the oxc_allocator crate, matching the existing HashMap implementation. The HashSet is designed to work with the arena allocator and prevents Drop types from being stored to avoid memory leaks.

  • Implements HashSet as a thin wrapper around hashbrown::HashSet with disabled Drop
  • Adds comprehensive API including constructors, iterators, and trait implementations
  • Establishes conversion between HashMap<T, ()> and HashSet<T>

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_allocator/src/lib.rs Adds module declaration and public export for the new HashSet type
crates/oxc_allocator/src/hash_set.rs Complete implementation of arena-allocated HashSet with safety checks and API methods
crates/oxc_allocator/src/hash_map.rs Makes HashMap's inner field public(crate) and removes commented conversion code

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

@overlookmotel overlookmotel force-pushed the 09-28-feat-allocator-add-hashset branch from 994240b to a13a16b Compare October 4, 2025 09:17
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.

Thanks for doing this (and for including the oddity of allocator method).

To save time, in place of review, I've pushed a few commits with suggested changes (all minor). @sapphi-red If you're happy with them, please go ahead and merge, or feel free to make further changes if you don't like them.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 4, 2025

Merge activity

Adds the arena-allocated `HashSet`.
@graphite-app graphite-app bot force-pushed the 09-28-feat-allocator-add-hashset branch from a13a16b to f37b211 Compare October 4, 2025 11:14
@graphite-app graphite-app bot merged commit f37b211 into main Oct 4, 2025
28 checks passed
@graphite-app graphite-app bot deleted the 09-28-feat-allocator-add-hashset branch October 4, 2025 11:19
@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