servo / servo/html5ever

Make async ergonomics nicer.

Open
#478 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.6k
Forks
288
Avg merge
2d 22h
Merged PRs (30d)
8

Description

Using html5ever in async code is painful, because of Cell in StrTendril. As far as I can tell, that choice is for performance reasons (the documentation claims that the use of non-thread-safe primitives is explained in README.md, but no such explanation exists anywhere I can find) but in my use case I'm quite happy to trade a bit of performance for massively enhanced ergonomics with async.

To that end, I'd like to see something which swaps out StrTendril (aka Tendril<UTF8, NonAtomic>) for Tendril<UTF8, Atomic>. A feature to enable atomicity seems reasonable, but there might be a better option. As far as I can tell that's a completely source-compatible change, so this can probably be implemented with something like:

#[cfg(not(feature="atomic"))]
type H5ETendril = tendril::StrTendril;
#[cfg(feature="atomic")]
type H5ETendril = tendril::Tendril<tendril::UTF8, tendril::Atomic>;

and then replacing references to tendril::StrTendril with crate::H5ETendril.

Obviously the names can be bikeshedded. Those are the first ones I came up with.

Whether this belongs in this crate or tendril is also up for debate, but in my opinion: people using tendril directly already have plenty of ways to give themselves atomicity, and changing defaults through a feature there would just lead to dependency hell.

I can put in a PR, if it does turn out to be that simple.

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.

Research direction

Start by reading README.md and locating the crate's references to tendril::StrTendril. Determine how an optional atomic Tendril choice would affect those references and async use. Done means the selected feature provides the intended atomic representation without breaking the existing default.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.