Size-based representation for std::vector

Abierto
#6,421 1 comentario 1 reacción 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
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
cpp

Línea de trabajo

Empieza leyendo la propuesta de ABI de LLVM libc++ enlazada y el issue 2574 anterior de microsoft/STL; después, identifica las áreas de implementación y pruebas de STL afectadas por una representación alternativa de std::vector. Se considera terminado cuando el diseño propuesto basado en el tamaño esté implementado con una cobertura de ABI adecuada y su rendimiento y comportamiento se hayan validado para distintos tamaños de elemento.

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

Descripción

performance vNext

Instructions

libc++ has a new optional ABI where std::vector stores len and cap instead of pointers which yields significantly better results when hardening is enabled, and "positive or neutral impact on run-time" without hardening

Adding a size-based vector to libc++’s unstable ABI

tl;dr We can significantly improve the runtime performance of std::vector by changing its representation from three pointers to one pointer and two integers. This document explains the details of this change, along with the justifications for making it.

There was https://github.com/microsoft/STL/issues/2574 but the benchmarks there were flawed and not cover all cases like different element sizes. In real code there are a lot of cases where std::vector<some_struct> is used and the struct size is unlikely to be a power of 2. In this case size() would need a multiplication, usually by a small number that fit into the immediate field of the instructions, or can be split into LEA or SHIFT/ADD series. In the traditional pointer-based it's a division by some number that will be converted into multiplication by a large "random" number that may need multiple instructions to construct

It would be nice if this alternative layout can be added

Lenguaje dominante
C++
Estrellas
11.2k
Forks
1.7k
Merge medio
4 d 4 h
PR fusionados (30 d)
14

Preparar el entorno

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 microsoft/STL

Todos los issues de microsoft/STL

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.