[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] completion performance
|
Apparently every completion operation forces a reparse of the entire
translation unit up to the completion point. In some of the files of my
project, this takes about five seconds (and this is a dual Xeon
AMD64...).
One way to address this would be to keep the parser, scanner and AST
around after a completion operation, "roll back" to some point before
the next completion point and any edits that have been performed, then
resume parsing forward to the next completion point. To make things
easier, rollback points could be severely limited, e.g.: parser must be
between declarations in the translation unit and must not be inside any
inclusion or macro expansion. During a completion parse, the parser
could record available rollback points and advertise them to clients
through a new API. (OK, this might not work well for projects with
translation units that wrap everything in a namespace declaration, but
our project doesn't and it could be extended.)
Performing a rollback would have to reset the scanner state, remove
declarations from the translation unit AST node, clear bindings, flush
scopes and recompute bindings --- at least. What else would have to be
done? Is this complete lunacy?
It seems that clearing out all bindings and recomputing them from
scratch would be a reasonable way to update the model ... I *hope* that
later declarations in the translation unit can't cause ambiguities in
earlier declarations to be resolved differently. Otherwise we could try
to resolve ambiguities at each potential rollback point and refuse to
allow rollback there if there are outstanding ambiguities. Recomputing
all bindings might not perform well, I guess. But it looks like binding
computation happens lazily so maybe we wouldn't actually have to
recompute bindings for AST parts that were already parsed and aren't in
the scope of the completion.
Rob
--
["Therefore, my dear friends, as you have always obeyed–not only in my
presence, but now much more in my absence–continue to work out your
salvation with fear and trembling, for it is God who works in you to will
and to act according to his good purpose." Philippians 2:12-13.]