Optimize 128-bit decimal formatting

Cerrado
#5,006 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 8 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
cpp
Área
performance

Línea de trabajo

Start by locating count_digits(native_uint128) and do_format_decimal, then trace how the 64-bit formatter returns the start of its output. Check the existing tests and benchmarks for 128-bit decimal formatting before changing the division path. Done means the proposed operations are removed or replaced without changing formatting results, and benchmarks confirm the performance impact.

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

Descripción

Hi..

current 128-bit decimal formatting path uses division and modulo by 10^19 to reduce values into 64-bit chunks........ and GCC emits __udivti3 and __udivmodti4 calls for these operations.

During this i found two probably redundant operations - please correct me if i'm wrong or missed a point to review here :

  • count_digits(native_uint128) performs a second 128-bit division when the result is already known to have 39 digits.
  • do_format_decimal counts the remaining digits again, although the 64-bit formatter already returns the start of the formatted output.

so can we remove these redundant operations and replacing division by 10^19 with an exact three-multiply reciprocal implementation .... 10^19 = 2^19 * 5^19.

anyway in my testing GCC (12.2.0)benchmarks show a 14.6% improvement in fmt::format_to for uniformly distributed 128-bit values and 24.8% for the upper 39-digit range.

Lenguaje dominante
C++
Estrellas
25.9k
Forks
3.1k
Merge medio
9 d 12 h
PR fusionados (30 d)
16

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 fmtlib/fmt

Todos los issues de fmtlib/fmt

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.