Difference in SIMD and non-SIMD process_token tokens
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 66/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- performance
Línea de trabajo
Start at the step function in html5ever/src/tokenizer/mod.rs, comparing the small_char_set! used by pop_except_from (via BufferQueue) with the trailing-byte loop in data_state_simd_fast_path, which skips stopping at \n. Decide which path matches the HTML tokenizer spec, then align the two so process_token receives identical tokens with SIMD forced off (patch is_x86_feature_detected! to false). Done when both paths produce the same token stream; verify with cargo test and the tokenizer test suite.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
SIMD and non-SIMD paths produce different process_token calls.
As the maintainers of html5ever do you think this inconsistency is a bug or normal behaviour?
How it was discovered
The lychee test fails on riscv machine:
https://github.com/lycheeverse/lychee/issues/2263
Inside lychee-lib/src/extract/html/html5ever.rs process_token recieves
different tokens (example in the issue is given). This incosistency breaks tests.
Reason behind it
The step function inside html5ever/src/tokenizer/mod.rs contains following lines:
// ...
let set = small_char_set!('\r' '\0' '&' '<' '\n' );
#[cfg(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"))]
// ...
let result = unsafe { self.data_state_simd_fast_path(&mut front_buffer) };
// ...
#[cfg(not(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64"
)))]
let set_result = self.pop_except_from(input, set);
// ...
SIMD path
Note how data_state_simd_fast_path processes remaining bytes:
// ...
// Process any remaining bytes (less than STRIDE)
while let Some(c) = input.as_bytes().get(i) {
if matches!(*c, b'<' | b'&' | b'\r' | b'\0') {
break;
}
if *c == b'\n' {
n_newlines += 1;
}
i += 1;
}
// ...
non-SIMD path
Note how pop_except_from processes bytes:
let d = input.pop_except_from(set);
input is BufferQueue and set is small_char_set!('\r' '\0' '&' '<' '\n' ). So countrary to the SIMD part this pop stops after \n.
How to reproduce
I was able to reproduce this issue on x86_64 machine by turning SIMD off.
- git clone https://github.com/lycheeverse/lychee && cd lychee
- cargo vendor # don't forget to change .cargo/config.toml
- patch html5ever
--- a/vendor/html5ever/src/tokenizer/mod.rs
+++ b/vendor/html5ever/src/tokenizer/mod.rs
@@ -1921,7 +1921,7 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
fn is_supported_simd_feature_detected() -> bool {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
- is_x86_feature_detected!("sse2")
+ false
}
#[cfg(target_arch = "aarch64")]
- Fix checksums
sed -i -e 's/"files":{[^}]*}/"files":{}/' \
./vendor/html5ever/.cargo-checksum.json
cargo test --frozen -p lychee-lib --lib html5ever::tests::test_include_verbatim
- Lenguaje dominante
- Rust
- Estrellas
- 2.6k
- Forks
- 299
- Merge medio
- 8 d 22 h
- PR fusionados (30 d)
- 3
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de servo/html5ever
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
rcdom: selectedcontent lookup reads self.data, option clone never runsPosiblemente ocupada @jdm la tomó hace 71 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
servo/html5ever#776 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Tree builder: leftover active-formatting markers make each formatting end tag O(list length)Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Tokenizer: duplicate-attribute check is O(n²) in a tag's attribute countPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
Los mantenedores suelen responder en 1 día
-
Support processing instructions `<?target data>`Posiblemente ocupada @Delta-official la tomó hace 32 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
servo/html5ever#789 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de servo/html5ever
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Y-ASLant/ElegantClipboard#178 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
linxiv-dev/linXiv#384 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug drawings ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
userFRM/egui-charts#1595 ·
Los mantenedores suelen responder en 1 día
-
tcp: a very large keep-alive interval overflows `Instant` arithmetic (panic in debug builds)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
smoltcp-rs/smoltcp#1235 ·
Los mantenedores suelen responder en 1 día
-
scope:core type:security
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día