-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<chrono>: time_zone::get_info code is excessively slow #5304
Comments
what a shocking surprise, std c++ code relies on icu. Feels like the issue is never going to be fixed |
Resolving as a duplicate of #2842. We chose to take a dependency on the OS's copy of ICU because the alternative would be to ship a copy of the IANA timezone database within the STL, which would be problematic for a couple of reasons: (1) it would significantly increase the size of the STL, and (2) it couldn't be automatically updated in response to timezone changes (due to legislation etc.). (Consider an application that's built with MSVC, deployed to an end-user's machine, and then runs unchanged for many years - if timezone info were baked into the STL, it would become outdated.) Having the OS be responsible for providing up-to-date timezone information avoids these issues - it's just that on Windows, we don't have direct access to the IANA timezone database. We may be able to improve performance here (hence we're keeping the primary issue open), but we don't believe we have good alternatives to ICU at this time. |
Yes, I understand that. If ICU made it into the OS it's the easiest route to make it work First time I tried to use ICU like 20 years ago with boost::regex. After using it, I always avoided it, no particular reason, I don't know why. Very surprised it's now part of the OS itself :) When I switched to chrono timezone I was expecting something like api-ms-win-crt-timezone-1-2-3.dll in the dependencies. Surprisingly, didn't see anything and was puzzled how it could have worked correctly when 1) WinAPI itself is really bad with timezone data (very limited support for historical info) and 2) binary didn't increase in size while timezone data apparently was present somehow. |
Describe the bug
I used abseil for timezone code and wanted to switch to standard std::chrono that supports timezones now. Code works, but some time later I've noticed perf issues. After debugging, it appears that time_zone::get_into is more than 100x slower in MS chrono::timezone code compared to abseil or chrono with g++.
sample code bellow. Note, there is
_putenv("TZDIR=...")
for abseil, adjust it for your absl location. Also, if easier, just comment out abseil and use chrono code with ms and g++ compilers to compare timing.This code simply walks 140 years day by day and asks for timezone info for each of these days.
When timezone info changes, it's stores day of the change as a unix timestamp. This part is simply to verify that the results from absl timezone and chono timezone are the same. When I run x64 release build on Win11 I get this output:
basically absl and chrono produce the same result, but it takes 400x more time to run chrono timezone code. Not sure what the reason is, but it certainly shouldn't be this slow. It's not even a caching issue imo. IANA timezone db is only like 500KB (and I access only EST timezone, which is perhaps less than 10KB total).
When I run this code on my PC compiled with mingw64 (version 14.2.0) I for chrono I get this output:
it's 1000x faster on mingw64
The text was updated successfully, but these errors were encountered: