[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [be] bibledit-bin CPU usage
From: |
Teus Benschop |
Subject: |
Re: [be] bibledit-bin CPU usage |
Date: |
Mon, 02 Feb 2009 16:55:45 +0200 |
Hi Dan,
A fix for the CPU expense has been put in the local repository, to be
pushed out within 12 hours. It reduced the average CPU usage of
bibledit-bin from 2% on my laptop to 1% now. Which implies that you hit
the mail on the head when locating the routine that uses a lot of CPU
cycles. I'll submit a task, to be done later, to look into whether this
routine cannot be called only under certain circumstances rather than
once every so many milliseconds.
Thanks for your contribution.
Teus.
On Sat, 2009-01-31 at 16:47 -0800, Dan Dennison wrote:
> I ran bibledit-bin on Linux through callgrind, which is part of
> valgrind.
>
> It seems the bulk of its idle CPU usage is in the following fragment,
> located in editor_aids.cpp:
>
> for (unsigned int i = 0; i < usfm->styles.size(); i++) {
> if (marker == usfm->styles[i].marker) {
> type = usfm->styles[i].type;
> subtype = usfm->styles[i].subtype;
> break;
> }
> }
>
> This fragment is called every verse_tracker_timeout. Of the 51
> verse_tracker_timeouts captured by my sample, 43,880 calls were made
> to ustring::compare, which is called during evaluation of the if
> statement. Quick math shows about 860 calls to a string comparison per
> verse_tracker_timeout.
>
> I think I might be possible to optimize the loop out completely by
> using a hash table to do the lookup here. This is significant because
> the idle CPU draw from bibledit-bin can be then further reduced,
> allowing for even greater laptop battery life, crucial for some of our
> deployment scenarios.
>
> What do you think? My callgrind output is at https://thedennisons.org/
> ~dand/callgrind.out.19357.gz
>
> dan :)
>
>
>