Vincent van Ravesteijn - TNW wrote:
I'm having real problems working with LyX and child document. It's
very very
slow when typing text.
>> This is a very mysterious mystery.
rh
A possible explanation for this.
For each keystroke, updateMacros() is called, which calls
Ouch!
Isn't this something that is necessary only if you're actually dealing
with a macro? (making one, or filling in parameters)? If so, perhaps
check that first and just return if there is nothing macroish to do?
InsetInclude::loadIfNeeded(), which then calls
theBufferList::getBuffer(). This function iterates over all loaded
buffers and if the wanted file is not loaded yet it will be loaded.
I have a hard time understanding why any kind of filesystem check might
be necessary on _each keystroke_. Move the cursor into a file-backed
inset - sure. But not otherwise? The main LyX job is typing text and
that ought to work with a minimum of per-keystroke checks. I guess this
behaviour is unintentional.
As a consequence, having 5 child documents leads to comparing
2+3+4+5+6=20 times two filenames. In FileName::operator==(), two new
And the quadratic behaviour indicates that something else is amiss too.
Checking if any two files from a set is the same? Shouldn't be necessary
except when a new file is added to the set. A one time per file op,
rather than a once per keypress op.
FileName objects are constructed (lhs and rhs) and in the constructor
QFileInfo::isFileExists() is called. This leads thus already to
accessing the filesystem 40 times.Then, both QFileInfo objects are
refreshed, which makes it 80 times.
Having a thesis with 10 chapters in separate child documents, would
cause 260 filesystem checks for each character !!
Typing at a speed of 10 characters per second, thus leads to 2600
network files to be accessed.. per second ...
Time to mess up things ?
Much development happens on linux, where excellent file caching hides
this silliness/mistake. (No network access if the process asks about the
same few files over and over.) And a fast processor hides the actual
work in searching the file cache.
It is a good thing some have slow machines or slow filesystems, catching
such things. Perhaps there is too much encapsulation, hiding details
from programmers. A good implementation of LyX ought to have something
like the emergency save stuff being the most frequent use of the
filesystem when the user is merely typing.
Helge Hafting