Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.4.1, 6.5
-
None
-
-
21
-
Foundation PM Prioritized
Description
My app, that needs to filter a big table model, is very slow on macOS. Upon investigation, I found out that all QLocale().toString(int/double/QDateTime) are 2-3 orders of magnitude slower than the same calls on QLocale::c().
Attached is a simple benchmark tool that produces the output below. You'll see that we're currently around 100x slower in release builds (debug builds are around 1000x slower, but a big part of that is the QMacAutoReleasePool in the macOS query() callback).
Here is a patch on gerrit that adds caching to any QSystemLocale call that returns a constant string: https://codereview.qt-project.org/c/qt/qtbase/+/446822
Int and enum returns from query() are currently not cached and dynamic data (e.g. QDateTime as parameter to query) cannot be cached at all anyway.
baseline, dev branch, release build on MacBook Air M2
Locale: C 10000x toString(3.14): 0s 003ms 069us
Locale: de_DE 10000x toString(3,14): 0s 003ms 020us
System Locale: en_DE 10000x toString(3,14): 0s 408ms 052us
Locale: C 10000x toString(12345): 0s 000ms 331us
Locale: de_DE 10000x toString(12.345): 0s 000ms 704us
System Locale: en_DE 10000x toString(12.345): 0s 382ms 285us
Locale: C 10000x toString(Monday, 5 December 2022 04:05:29 CET): 0s 032ms 768us
Locale: de_DE 10000x toString(Montag, 5. Dezember 2022 04:05:29 CET): 0s 032ms 779us
System Locale: en_DE 10000x toString(5. December 2022 04:05:29 CET): 2s 457ms 831us
with caching patch:
Locale: C 10000x toString(3.14): 0s 003ms 243us
Locale: de_DE 10000x toString(3,14): 0s 003ms 346us
System Locale: en_DE 10000x toString(3,14): 0s 005ms 205us
Locale: C 10000x toString(12345): 0s 000ms 926us
Locale: de_DE 10000x toString(12.345): 0s 001ms 809us
System Locale: en_DE 10000x toString(12.345): 0s 002ms 975us
Locale: C 10000x toString(Monday, 5 December 2022 04:02:32 CET): 0s 047ms 544us
Locale: de_DE 10000x toString(Montag, 5. Dezember 2022 04:02:32 CET): 0s 032ms 981us
System Locale: en_DE 10000x toString(5. December 2022 04:02:32 CET): 0s 035ms 714us
Attachments
Issue Links
- relates to
-
QTBUG-116642 Provide a refresh mechanism for system locale data
- Reported
-
QTBUG-118759 [Regr:6.5->6.6] QDateTime comparison performance regression on macOS
- Closed
-
QTBUG-104785 [REGR:5->6] Performance regression in QLocale on macOS
- Closed
-
QTBUG-104012 QDateTime constructor performance regression when year is below epoch
- Closed
Gerrit Reviews
For Gerrit Dashboard: QTBUG-109201 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
446822,2 | Cache QSystemLocale queries | dev | qt/qtbase | Status: DEFERRED | -1 | 0 |