[ https://issues.apache.org/jira/browse/THRIFT-5709?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukas Barth updated THRIFT-5709: -------------------------------- Description: Currently, the `to_string()` overloads in `TToString.h` call the `std::locale` constructor for *every* single call. Creating locales is surprisingly expensive. We have an application where we - especially during tests - write large amounts of Thrift dumps to disk, and is this application we currently spend around 17% of total CPU time in std::locale's constructor (building with MSVC, in a Release build - other compilers might optimize this away?). With the proposed change (see GitHub), it's basically down to zero. Since we always create the exact same locale anyways, using a `const static` one does not hurt. was: Currently, the `to_num()` overloads in `TToString.h` call the `std::locale` constructor for *every* single call. Creating locales is surprisingly expensive. We have an application where we - especially during tests - write large amounts of Thrift dumps to disk, and is this application we currently spend around 17% of total CPU time in std::locale's constructor (building with MSVC, in a Release build - other compilers might optimize this away?). With the proposed change (see GitHub), it's basically down to zero. Since we always create the exact same locale anyways, using a `const static` one does not hurt. > Drastically improve `to_num()` performace > ----------------------------------------- > > Key: THRIFT-5709 > URL: https://issues.apache.org/jira/browse/THRIFT-5709 > Project: Thrift > Issue Type: Improvement > Components: C++ - Library > Affects Versions: 0.19.0 > Reporter: Lukas Barth > Priority: Major > > Currently, the `to_string()` overloads in `TToString.h` call the > `std::locale` constructor for *every* single call. Creating locales is > surprisingly expensive. We have an application where we - especially during > tests - write large amounts of Thrift dumps to disk, and is this application > we currently spend around 17% of total CPU time in std::locale's constructor > (building with MSVC, in a Release build - other compilers might optimize this > away?). With the proposed change (see GitHub), it's basically down to zero. > Since we always create the exact same locale anyways, using a `const static` > one does not hurt. -- This message was sent by Atlassian Jira (v8.20.10#820010)