Commit 4711543
committed
perf: gate AvaloniaNLogSink at Warning, cache loggers
Avalonia framework code emits high-volume Verbose/Debug/Info events
during layout, input, and rendering. nlog.config blackholes
Avalonia* events at those levels with a final="true" rule, so
they have nowhere to go — but IsEnabled returning true unconditionally
made Avalonia format arguments and call Log() before NLog discarded
them. dotnet-trace on a script-editor typing session showed the
sink consuming ~318ms of inclusive CPU over 30s, more than any
other app-attributed path.
Two changes:
1. IsEnabled now returns false below Warning. Avalonia short-circuits
before formatting arguments, matching the intent of the existing
nlog.config Avalonia* blackhole rule.
2. Per-source ILogger lookups go through a ConcurrentDictionary
keyed by Type instead of LogManager.GetLogger(string) on each
call. Smaller win after #1 since most calls don't reach Log
anymore, but cheap enough to land together.
Surviving Warning/Error/Fatal events flow through unchanged.1 parent 6786308 commit 4711543
1 file changed
Lines changed: 30 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
11 | 27 | | |
12 | 28 | | |
13 | 29 | | |
14 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
15 | 36 | | |
16 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
17 | 41 | | |
18 | | - | |
| 42 | + | |
| 43 | + | |
19 | 44 | | |
20 | 45 | | |
21 | 46 | | |
| |||
24 | 49 | | |
25 | 50 | | |
26 | 51 | | |
27 | | - | |
28 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
29 | 55 | | |
30 | 56 | | |
31 | 57 | | |
| |||
0 commit comments