Hi,
the code files of our customers are sometimes really big, escpecially if they are generated. In some rare cases this leads to multiple thousands of outlining nodes in one file. With the old WinForms version we made some modifications to get a good performance. With the WPF release we noticed some performance issues for these files.
Since the updates are performed in the parser thread, this isn't immediately visible. But after some time the parser threads are busy with updating the outlining data and the main thread blocks until the parser thread is free again.
The key issue here is the use of RemoveAt():
95,81 % OnParseDataChanged • 292.723 ms • ActiproSoftware.Text.Implementation.CodeDocument.OnParseDataChanged(ParseDataPropertyChangedEventArgs)
95,81 % [Native code] • 292.723 ms
95,80 % OnEvent • 292.713 ms • ActiproSoftware.Text.Utility.WeakEventListener`2.OnEvent(Object, TEventArgs)
95,80 % r7P • 292.713 ms • ActiproSoftware.Internal.ut+<>c.r7P(ut, Object, EventArgs)
95,80 % EmL • 292.713 ms • ActiproSoftware.Internal.ut.EmL(Object, EventArgs)
95,80 % PmR • 292.713 ms • ActiproSoftware.Internal.ut.PmR(Nullable, TextSnapshotRange, Boolean)
95,77 % UpdateAutomaticOutlining • 292.601 ms • ActiproSoftware.Internal.ut.UpdateAutomaticOutlining(IOutliningSource, TextSnapshotRange)
47,86 % ixi • 146.233 ms • ActiproSoftware.Internal.bY.ixi(IOutliningNodeDefinition, Int32)
47,84 % fgO • 146.157 ms • ActiproSoftware.Internal.bY.fgO
46,50 % RemoveAt • 142.074 ms • System.Collections.Generic.List`1.RemoveAt(Int32)
0,47 % HxN • 1.438 ms • ActiproSoftware.Internal.w4.HxN
0,21 % Add • 643 ms • System.Collections.Generic.List`1.Add(T)
0,18 % Vxs • 550 ms • ActiproSoftware.Internal.w4.Vxs
0,12 % 8 functions hidden • 370 ms total
0,02 % 3 functions hidden • 76 ms total
47,62 % EgT • 145.493 ms • ActiproSoftware.Internal.bY.EgT(Int32)
47,62 % qxc • 145.483 ms • ActiproSoftware.Internal.bY.qxc(w4, Int32, Int32, Int32)
46,45 % RemoveAt • 141.933 ms • System.Collections.Generic.List`1.RemoveAt(Int32)
0,42 % HxN • 1.277 ms • ActiproSoftware.Internal.w4.HxN
0,18 % Insert • 543 ms • System.Collections.Generic.List`1.Insert(Int32, T)
0,15 % 7 functions hidden • 452 ms total
0,00 % VxQ • 10 ms • ActiproSoftware.Internal.bY.VxQ
0,27 % 8 functions hidden • 817 ms total
0,04 % qm9 • 112 ms • ActiproSoftware.Internal.ut.qm9(ref Nullable)
0,00 % UpdateTags • 10 ms • Vector.ITE.Languages.Common.Language.ErrorTagging.ActiproErrorTagCache.UpdateTags(ICodeDocument, IParseErrorProvider)
#stacktrace
Here is the callstack of the main thread, which waits for the parser thread to finish:
90,01 % OnTextInput • 292.330 ms • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorView.OnTextInput(TextCompositionEventArgs)
90,01 % Eth • 292.330 ms • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorView.Eth(TextCompositionEventArgs)
90,01 % PerformTyping • 292.330 ms • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorView.PerformTyping(String)
90,01 % ExecuteEditAction • 292.330 ms • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorView.ExecuteEditAction(IEditAction)
90,01 % Execute • 292.330 ms • ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction.Execute(IEditorView)
90,00 % ReplaceSelectedText • 292.319 ms • ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorView.ReplaceSelectedText(ITextChangeType, String, IEditorViewTextChangeOptions)
90,00 % Apply • 292.319 ms • ActiproSoftware.Text.Implementation.TextChange.Apply
90,00 % ApplyTextChange • 292.319 ms • ActiproSoftware.Text.Implementation.TextDocumentBase.ApplyTextChange(TextChange, Action)
90,00 % OnTextChanged • 292.319 ms • ActiproSoftware.Text.Implementation.CodeDocument.OnTextChanged(TextSnapshotChangedEventArgs)
90,00 % OnTextChanged • 292.319 ms • ActiproSoftware.Text.Implementation.TextDocumentBase.OnTextChanged(TextSnapshotChangedEventArgs)
89,98 % [Native code] • 292.244 ms
89,98 % OnEvent • 292.244 ms • ActiproSoftware.Text.Utility.WeakEventListener`2.OnEvent(Object, TEventArgs)
89,98 % j7W • 292.244 ms • ActiproSoftware.Internal.ut+<>c.j7W(ut, Object, TextSnapshotChangedEventArgs)
89,98 % wmc • 292.244 ms • ActiproSoftware.Internal.ut.wmc(Object, TextSnapshotChangedEventArgs)
89,96 % [Native code] • 292.171 ms
89,96 % Wait • 292.171 ms • System.Windows.Threading.DispatcherSynchronizationContext.Wait(IntPtr[], Boolean, Int32)
0,06 % 2 functions hidden • 181 ms total
0,02 % 2 functions hidden • 52 ms total
#stacktrace
Maybe there is a way to improve the performance and to avoid the blocking in the main thread.
Best regards, Tobias Lingemann.