Skip to content

Add BTree parity goal - #836

Open
clarfonthey wants to merge 3 commits into
rust-lang:mainfrom
clarfonthey:btree
Open

clarfonthey wants to merge 3 commits into
rust-lang:mainfrom
clarfonthey:btree

Conversation

@clarfonthey

@clarfonthey clarfonthey commented Oct 26, 2026 •

Copy link
Copy Markdown

@clarfonthey clarfonthey added the C-goal-proposal This is a goal proposal label Oct 26, 2026
@rustbot

rustbot commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

A #goals/proposed topic was opened to discuss this issue.

@teor2345 teor2345 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just some very minor nits, I don't feel strongly about these

View changes since this review

Comment thread src/2026/btree-parity.md Resolved
Comment thread src/2026/btree-parity.md Resolved
Comment thread src/2026/btree-parity.md Resolved
clarfonthey and others added 2 commits October 25, 2026 21:43
Co-authored-by: teor <teor@riseup.net>
Co-authored-by: teor <teor@riseup.net>

@nxsaken nxsaken left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Needs a libs champion (which could be you) and, because the ask is large, a lead sign-off (informal).

View changes since this review

Comment thread src/2026/btree-parity.md

### The status quo

Right now, the standard library's implementation of `HashMap` and `HashSet` relies on the implementation in the `hashbrown` crate. This has been a very healthy relationship, since it means that the ecosystem can easily suggest changes to ergonomics of the implementation and expose its inner workings without having to deal with the extremely strict stability guarantees of the standard library. There are several ecosystem crates that are able to build upon this work for other primitives like `indexmap` (hash tables with ordered entries) and `dashmap` (concurrent hash tables).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some background about how the standard library started relying on hashbrown (and maybe linking to related issues/PRs) would be a good setup for the proposal below.

Comment thread src/2026/btree-parity.md

Right now, the standard library's implementation of `HashMap` and `HashSet` relies on the implementation in the `hashbrown` crate. This has been a very healthy relationship, since it means that the ecosystem can easily suggest changes to ergonomics of the implementation and expose its inner workings without having to deal with the extremely strict stability guarantees of the standard library. There are several ecosystem crates that are able to build upon this work for other primitives like `indexmap` (hash tables with ordered entries) and `dashmap` (concurrent hash tables).

In the standard library, we also have the types `BTreeMap` and `BTreeSet` for an analogous data structure, however, these types have languished a lot because they don't have the benefit of being an external crate like `hashbrown`. This has lead to a lot of anxiety when it comes to working on these types: several features have been "put off" for their implementation due to the complexity of the current code (custom allocator support, cursors, etc.) and many downstream users are limited in the ways they can leverage these primitives due to the lack of robust APIs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
In the standard library, we also have the types `BTreeMap` and `BTreeSet` for an analogous data structure, however, these types have languished a lot because they don't have the benefit of being an external crate like `hashbrown`. This has lead to a lot of anxiety when it comes to working on these types: several features have been "put off" for their implementation due to the complexity of the current code (custom allocator support, cursors, etc.) and many downstream users are limited in the ways they can leverage these primitives due to the lack of robust APIs.
In the standard library, we also have the types `BTreeMap` and `BTreeSet` for an analogous data structure, however, these types have languished because they don't have the benefit of being an external crate like `hashbrown`. This has led to a lot of anxiety when it comes to working on these types: several features have been "put off" for their implementation due to the complexity of the current code (custom allocator support, cursors, etc.) and many downstream users are limited in the ways they can leverage these primitives due to the lack of robust APIs.

Comment thread src/2026/btree-parity.md
Comment on lines +11 to +13
Right now, the standard library has the benefit of the `hashbrown` crate: a modern hash table implementation that can be reused by the ecosystem for more complicated situations, which is explicitly used for the libstd `HashMap` and `HashSet` types.

A very related set of types, `BTreeMap` and `BTreeSet`, currently have gotten so overbearing in the standard library that they have a bit of a reputation of being hard to deal with. We should fix this, both factoring the implementation out into its own crate where the API can be experimented with more easily, and to resolve concerns on custom allocators, cursors, and other desired APIs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The summary should be something roughly like this:

Suggested change
Right now, the standard library has the benefit of the `hashbrown` crate: a modern hash table implementation that can be reused by the ecosystem for more complicated situations, which is explicitly used for the libstd `HashMap` and `HashSet` types.
A very related set of types, `BTreeMap` and `BTreeSet`, currently have gotten so overbearing in the standard library that they have a bit of a reputation of being hard to deal with. We should fix this, both factoring the implementation out into its own crate where the API can be experimented with more easily, and to resolve concerns on custom allocators, cursors, and other desired APIs.
Move the implementation of `BTreeMap` and `BTreeSet` into a separate crate similar to `hashbrown` and bring their APIs to parity with `HashMap` and `HashSet`.

Comment thread src/2026/btree-parity.md
@@ -0,0 +1,61 @@
# `BTree` feature parity

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a bit unclear. I think it needs some reference to hashbrown or HashTable, the former probably conveys the idea of this goal better.

Something like this?

Suggested change
# `BTree` feature parity
# Hashbrownify `BTree` types

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is an extremely cursed naming and I'm not sure if I want to accept it yet, but, will ponder it

Comment thread src/2026/btree-parity.md
| :--------------- | ------------------------------------------------------------- |
| Contact | @clarfonthey |
| Status | Proposed |
| What and why | Make `BTree` types as robust as their `HashTable` equivalents |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
| What and why | Make `BTree` types as robust as their `HashTable` equivalents |
| What and why | Make `BTree` types as robust as their `hashbrown` equivalents |

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, makes sense; HashTable is currently only offered in hashbrown but we do have an active ACP for BTree.

At this point, I mostly just need to flesh these out with existing issues/etc. for more context.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-goal-proposal This is a goal proposal

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

4 participants