Cosmos: Handle late discriminators in materialization

Abierto
#38,576 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Tranquilo
Stack tecnológico
csharp
Área
database

Línea de trabajo

Comienza revisando la materialización de Cosmos mediante streaming introducida por #38550, centrándote en el escaneo del discriminator de Utf8JsonReader y en el orden de los discriminators del serializer. Compara el comportamiento de los discriminators tardíos con los enfoques mencionados de excepciones de STJ DOM y opt-out; se requiere haber decidido una estrategia y haber realizado la validación correspondiente de rendimiento y corrección.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area-cosmos area-perf area-query customer-reported
What problem are you trying to solve?

Since #38550 cosmos materialization is done in a streaming fashion, using Utf8JsonReader.
This is faster and allocation light. Especially when comparing the to previous materializer that used Newtonsoft's DOM as an intermediate step.
However, when a structural type has an inheritance hierarchy, the materializer needs to know the discriminator value before it can start reading other values. Similar to STJ, the materializer will do a scan over the document to find the discriminator property and it's value. A document could be as large as 2MB and the discriminator can appear anywhere in the document. Limited benchmarking has shown that scanning the document can be slow when the discriminator appears late, to the point where STJ's DOM would be faster with very little increase in GC pressure.
The serializer has been changed to put discriminators early in the document, but using different write method or migrating from an older version of EF, we don't know the location of the discriminator

Describe the solution you'd like

To discuss.
STJ actually throws an opt-out exception when the discriminator is not the first property in a json document that has an inheritance hierarchy. We could consider the same, or even switch to DOM when we can't find the discriminator in the first (few) properties. This would mean maintaining 2 methods of materialization tho, which probably isn't worth it. Completely switching to STJ DOM could be an option, but we would be slightly slowing down the happy path materialization.

Lenguaje dominante
C#
Estrellas
14.8k
Forks
3.4k
Merge medio
3 d 18 h
PR fusionados (30 d)
159

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotnet/efcore

Todos los issues de dotnet/efcore

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.