Skip to content

[libc++] int-to-string conversions significantly slower on mingw #56202

@alvinhochun

Description

@alvinhochun

This is the same issue as #40476 but specifically for mingw. The prior issue was fixed for MSVC with https://reviews.llvm.org/D59525 and the follow-up https://reviews.llvm.org/D59727, but mingw still uses the slow path requiring __libcpp_locale_guard.

I don't have proper benchmark data now, but converting numbers to strings using std::ostringstream is apparently quite slow on mingw. Especially when the current locale is not "C", the setlocale call takes the majority of time (see image below). When the locale is already "C" it seems about a magnitude faster but setlocale is still quite significant in profiling data.

profiling

(This is the code in use.)

The toolchain we use is llvm-mingw 20220323 (LLVM 14.0.0).

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions