Enable zero-allocation conversion between Atom's from different static atom sets

Open
#293 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
rust
Domain
performance

Research direction

Start by reviewing the Atom Hash implementation and the rationale in string-cache issue #224. Determine how hashing Atom content would affect conversions among Atom, Atom, and DefaultAtom. Done means these conversions avoid reallocation while preserving correct interning and hashing behavior.

Written by the indexing model from the issue text.

Description

It would be useful to be able to cheaply convert between an Atom<StyloAtomSet>, an Atom<ServoAtomSet>, a DefaultAtom, etc. This would allow for interop between different crates without a performance penalty and without them all needing to coordinate on which set of static atoms to use.

However currently a dynamically allocated Atom is keyed by it's hash and that hash varies between static atom sets. So converting between Atom types requires reallocating.

I believe that implementing this would involve changing the Hash implementation of Atom to hash the content of the Atom rather than 64 bit value (see also https://github.com/servo/string-cache/issues/224 for why this may be a good anyway). At which point

Dominant language
Rust
Stars
212
Forks
84
Avg merge
1d 2h
Merged PRs (30d)
6

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from servo/string-cache

All issues in servo/string-cache

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.