sqlite: remove the null prototype from result rows
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, sqlite
Línea de trabajo
Comienza localizando las implementaciones de get(), all(), iterate() y el manejo existente de los resultados de run(), y después lee cómo se usan la V8 API y v8::DictionaryTemplate. Revisa los benchmarks propuestos y la implementación funcional mencionados en el issue. Se considera terminado cuando se hayan evaluado el comportamiento de los objetos ordinarios, la forma de fila compartida, el rendimiento y las preocupaciones de compatibilidad de semver-major.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Current behavior
Rows returned by get(), all() and iterate() are created with a null prototype. The V8 API that does this produces dictionary-mode objects, and V8 will not cache a prototype transition on a dictionary map, so every row also gets its own freshly allocated hidden class. Rows from the same statement therefore share no shape: they are slow to build, and every property access on them in user code is megamorphic.
Proposal
Drop the null prototype and build rows with v8::DictionaryTemplate, cached per statement. Rows become ordinary objects, and every row of a statement shares one hidden class.
Pros
all()is 10–37% faster depending on the query; reading the rows afterwards is far cheaper still.- Consistent with
run(), which already returns an ordinary object, and withbetter-sqlite3.
Cons
- Semver-major.
- Rows can no longer be indexed by untrusted keys without
Object.hasOwn()—row.toStringandrow.constructorstart resolving throughObject.prototype. - User code comparing rows against
{ __proto__: null, ... }breaks.
Prototype pollution is not a concern either way: rows are built by defining own properties directly, so a __proto__ column is an own property and never reaches Object.prototype.
I have benchmarks and a working implementation if there is interest.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.4k
- Merge medio
- 4 d 3 h
- PR fusionados (30 d)
- 272
Guía de contribución
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 nodejs/node
-
doc
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
build
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
feature request
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Todos los issues de nodejs/node
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
avniproject/avni-client#2135 ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bevyengine/bevy-website#2595 ·
-
ecosystem wording
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
matrix-org/matrix.org#3649 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
vadimdemedes/ink#1029 ·