Could not wait until afternoon, too interesting...
Unluckily, the overall result is a bit disappointing, the changes in CPU time are not really significant:
13-24% (average ~20%) all plugins (including debugger and compiler) original version
9-22% (average ~16%) all plugins (including debugger and compiler) after removing
OnIdleIt
appears to be slightly better, but the two intervals overlap quite a bit, so it may well be that the observed difference is due to inaccurate measurement.
The code was changed in the following manner:
//void CompilerGCC::OnIdle(wxIdleEvent& event)
//{
// if (m_Process && ((PipedProcess*)m_Process)->HasInput())
// event.RequestMore();
// else
// event.Skip();
//}
void CompilerGCC::OnTimer(wxTimerEvent& event)
{
if(m_Process)
while (((PipedProcess*)m_Process)->HasInput())
;
}
(the respective declarations and event table entries were deleted)
These changes were done for CompilerGCC, DebuggerGDB, and PipedProcess, which internally all use this strategy. Another possible optimization would be to move the
while into
PipedProcess::HasInput, so the two
TextInputStreams are not opened and closed for every single line of output read, but that will only affect performance while a compile is running, it should make no difference when idle (probably not an issue, so best leave as is).
Also, I deleted the
OnIdle function from
ProjectManager because all it did was call
Skip() - this is quite useless, we get the same result if we don't insert that function into the event table in the first place.
wxScintilla does some very peculiar idle processing, too. Apparently, the line wrapping is done by calling
RequestMore() for each line (?). Using
RequestMore in a loop is titled as "not usually a good idea" on comp.soft-sys.wxwindows, hmm... anyway. I removed this idle code to check what difference it makes, but since my test setting has no document open, the event table entry is not generated anyway, so of course there was no difference at all (it might while editing, maybe... but nobody complained so far?).
NotifyPlugins is
not guilty of taking up CPU time. I removed each and every call to
NotifyPlugins and did not see any difference in CPU load at all.
To summarise:It is not
OnIdle (it could be accused of maybe 5% CPU).
It is not
NotifyPlugins (not noticeable at all).
Neither compiler nor debugger spawn threads secretly.
Whatever eats those 15% of CPU time, must consquently be related to UI events.
Or... any other ideas?