On 10/25/2012 04:16 AM, Chris Cannam wrote:
> (I don't have the program in front of me atm either, and I can't
> actually remember offhand whether we don't show them at all or update
> them in batches -- either way we shouldn't be having a callback
> per-note and no edit commands should be firing)
When I try to record the Beethoven piece, Rosegarden hits 120% CPU on
my machine (Core i3 2.4GHz). The profiler stuff that's in there shows a
massive number of calls and time spent in functions like:
This thing is drawing like mad. It appears to be refreshing the
display over 400 times a second. And it gets worse as the recording
progresses. The more notes that are in the recording segment, the more
work it does. It feels like it is redrawing the entire segment, so as
the segment gets larger, it takes even longer.
I added profiling to the SegmentObserver related code and it is
getting hammered really hard while recording. This is because recording
calls Segment::insert() and Segment::erase() (multiple times for each
note), both of which fire off numerous SegmentObserver notifications and
set the RefreshStatus flags which cause even more work to be done. Here
are the numbers of calls after recording the Beethoven piece:
The piece is 7 minutes long, so we are seeing a rate of 478 calls per
second to the three Notify*() functions. updateRefreshStatuses() is
getting called about 388 times per second. The profiler indicates that
these are not sucking up too much time, however something else is. I'm
guessing the refresh flags are triggering other parts of the system to
work. Also, it might be that the profiler can't see across an update()
to the corresponding paint event.
High CPU usage when recording was one of the first things that I
noticed about rg when I started using it a couple years ago with much
less capable hardware. It's always been very high on my todo list to
It may be that the problem lies in a single observer of Segment.
This is one reason I'm diligently going through all observers to see if
something jumps out at me. Regardless, it would probably be a good idea
to redesign the Segment notification stuff so that the GUI can force
notifications for every user edit, and the MIDI recording feature can
just send notifications periodically, like ten times a second or so. I
don't think this is going to be easy, however.
In addition, Rosegarden is indeed recording the wrong things.
However, I have looked at the buffers and mutexes, and everything in
there seems ok. There still might be an issue, but pegging the CPU
really needs to be addressed before we can be sure it isn't due to
inordinate CPU usage.