diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2015-01-18 14:56:21 +0100 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-02-14 18:43:35 +0000 |
commit | 2be0d3088fc5bc52ece6b28157b28d16699ccb9b (patch) | |
tree | 5dacfd6ea8f436239cd524cb16d620aa78defb61 /header.LGPL21 | |
parent | 0eedca658a52f96175fc7ee3980179872464f061 (diff) |
qFormatLogMessage: optimize %{backtrace}
backtrace_symbols is very slow because it tries to find the function
name from the address. In order to do that it needs to do a linear search
over all symbols. (Because the hash table goes the other way to find the
address from the symbol name)
The code is going to skip a few frames from QtCore. Since we cannot know
how many, we take a few more than necessary.
This patch changes the additional number of frames from 15 to 7
(Usually, there are about 5 suppressed frames).
We call backtrace_symbols several times for only one frame at the time.
So we are not looking up addresses we don't need after we printed the
right number of frames.
Calling many times backtrace_symbols means we do more malloc, but that's
negligible compared to the time we save. We anyway do a lot of other
allocations because of the regexp operations and such
So this patch is then saving about 10 frames lookups which allow to print
about 6 qDebug per miliseconds instead of only 2 when using %{backtrace depth=2}
Change-Id: Ic6ece2145d53dc570c80fcb0e4455dcef6bc40cb
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'header.LGPL21')
0 files changed, 0 insertions, 0 deletions