Skip to content

Load logs newest-first for fast first paint and cut resolver memory#615

Merged
jschick04 merged 9 commits into
jschick/embed-symbols-drop-m1from
jschick/log-load-perf
Jun 21, 2026
Merged

Load logs newest-first for fast first paint and cut resolver memory#615
jschick04 merged 9 commits into
jschick/embed-symbols-drop-m1from
jschick/log-load-perf

Conversation

@jschick04

Copy link
Copy Markdown
Collaborator

What

Overhauls log loading so the newest events render almost immediately and message resolution uses far less memory and time.

  • Newest-first first paint. EventLogReader gains reverse-direction reading and a direction-agnostic newest bookmark (IEventLogReader), so a freshly opened log paints its first screenful from the newest events instead of reading the whole log first.
  • Priority resolution lane. A newly opened log's first screenful resolves ahead of bulk resolution (PrioritySemaphore, ResolutionPriority, EventLogReaderFactory).
  • Lower-overhead reads. Event variants read via pointer (matching the documented EVT_VARIANT layout), value-type system properties read without boxing, batches of 256, handles released on a failed read.
  • Server GC for faster parallel resolution.
  • Compact, load-free message store. Provider message tables are stored compactly and legacy entries are read on demand per id (ILazyMessageSource, CompactMessageStore, LegacyMessageFileSource, MessageTableReader) instead of materializing every provider's full table - removing a large regression where modern EventSource providers each loaded a 65,536-entry legacy table to serve ~1 lookup.

Measured (5 largest live logs, vs last stable release)

First paint 169-369x faster; read throughput +5-10% with ~45% less read allocation/event; provider-metadata memory back to stable-release level (was ~4.5x regressed); ~46% less per-event memory; resolve on par to ~5% faster.

Tests

Adds reverse-read, priority-semaphore, message-table-reader, and event-variant/GetEventRecord marshalling tests. Unit suites pass (1986 local); resolution parity verified byte-for-byte over 69,353 exported events.

Copilot AI review requested due to automatic review settings June 21, 2026 06:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reworks the log-load + resolution pipeline to prioritize “newest-first” rendering (fast first paint) and reduces memory/time overhead in message resolution and EVT marshalling.

Changes:

  • Load logs newest-first via reverse-direction reading and a direction-agnostic NewestBookmark (IEventLogReader), plus eager first-paint partial dispatch.
  • Introduce a two-lane priority gate (PrioritySemaphore, ResolutionPriority) so first-screenful resolution preempts bulk work across concurrent loads.
  • Reduce provider message-table overhead via compact/lazy message sources (ILazyMessageSource, CompactMessageStore, LegacyMessageFileSource, MessageTableReader) and optimize EVT variant/system-property reads.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Unit/EventLogExpert.Runtime.Tests/EventLog/EffectsTests.cs Adds reverse eager-load behavior tests and helper fakes/utilities.
tests/Unit/EventLogExpert.Runtime.Tests/Concurrency/PrioritySemaphoreTests.cs Adds correctness/stress tests for priority semaphore behavior.
tests/Unit/EventLogExpert.Provider.Tests/Resolution/ProviderDetailsTests.cs Adds coverage for compact/lazy message storage preserving ordering/fields.
tests/Unit/EventLogExpert.Eventing.Tests/PublisherMetadata/MessageTableReaderTests.cs Adds tests for bounds-checked message-table walking and lazy source parity.
tests/Unit/EventLogExpert.Eventing.Tests/Interop/NativeMethodsEvtTests.cs Updates/extends marshalling tests for pointer-indexed EvtVariant reads and system property extraction.
tests/Integration/EventLogExpert.Eventing.IntegrationTests/Readers/EventLogReaderReverseTests.cs Adds integration tests for reverse reading and NewestBookmark semantics.
src/EventLogExpert/EventLogExpert.csproj Enables Server GC for Windows builds to improve parallel resolve throughput.
src/EventLogExpert.Runtime/EventLog/OpenLogEffects.cs Implements newest-first reading, eager first paint partial dispatch, and priority-gated resolution.
src/EventLogExpert.Runtime/EventLog/IEventLogReaderFactory.cs Introduces factory abstraction to enable test substitution of readers.
src/EventLogExpert.Runtime/EventLog/EventLogReaderFactory.cs Default factory implementation for creating EventLogReader instances.
src/EventLogExpert.Runtime/DependencyInjection/RuntimeServiceCollectionExtensions.cs Registers IEventLogReaderFactory in runtime DI.
src/EventLogExpert.Runtime/Concurrency/ResolutionPriority.cs Defines priority classes for resolution gating.
src/EventLogExpert.Runtime/Concurrency/PrioritySemaphore.cs Adds the priority-aware async semaphore implementation.
src/EventLogExpert.Provider/Resolution/ProviderDetails.cs Switches to lazy/compact message sources and exposes lazy sources for reuse/fallback.
src/EventLogExpert.Provider/Resolution/ILazyMessageSource.cs New interface for lazy message-table lookup/materialization.
src/EventLogExpert.Provider/Resolution/CompactMessageStore.cs New compact in-memory message store with lazy/cached per-id materialization.
src/EventLogExpert.Eventing/Readers/IEventLogReader.cs New reader abstraction exposing NewestBookmark and batch reads.
src/EventLogExpert.Eventing/Readers/EventLogReader.cs Adds reverse-direction querying and NewestBookmark capture for reverse reads; adds handle cleanup on failed reads.
src/EventLogExpert.Eventing/PublisherMetadata/ProviderMetadata.cs Updates EVT handle extraction to match new EvtVariant field naming.
src/EventLogExpert.Eventing/PublisherMetadata/MessageTableReader.cs New bounds-checked message-table reader (count + per-id extraction).
src/EventLogExpert.Eventing/PublisherMetadata/LegacyMessageFileSource.cs New lazy message source over provider DLL message tables.
src/EventLogExpert.Eventing/PublisherMetadata/EventMessageProvider.cs Migrates legacy message loading to the new table reader + lazy source path.
src/EventLogExpert.Eventing/Interop/NativeMethods.Evt.cs Switches to pointer-indexed EvtVariant reads, adds EvtQueryWithFlags, and optimizes system-property extraction.
src/EventLogExpert.Eventing/Interop/NativeMethods.cs Adds SizeofResource P/Invoke used by message table reader.
src/EventLogExpert.Eventing/Interop/EvtVariant.cs Updates EvtVariant to explicit, blittable layout with typed union fields and stable offsets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Unit/EventLogExpert.Runtime.Tests/EventLog/EffectsTests.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Comment thread src/EventLogExpert.Runtime/EventLog/OpenLogEffects.cs
Comment thread src/EventLogExpert.Runtime/Concurrency/PrioritySemaphore.cs
Comment thread src/EventLogExpert.Eventing/PublisherMetadata/MessageTableReader.cs
@jschick04 jschick04 force-pushed the jschick/log-load-perf branch from e1f3270 to 38011a3 Compare June 21, 2026 14:56
@jschick04 jschick04 changed the base branch from main to jschick/embed-symbols-drop-m1 June 21, 2026 14:56
@jschick04 jschick04 requested a review from Copilot June 21, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 7 comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Comment thread src/EventLogExpert.Runtime/EventLog/OpenLogEffects.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Comment thread src/EventLogExpert.Eventing/PublisherMetadata/MessageTableReader.cs Outdated
Comment thread src/EventLogExpert.Runtime/EventLog/OpenLogEffects.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Comment thread src/EventLogExpert.Runtime/EventLog/OpenLogEffects.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Comment thread src/EventLogExpert.Runtime/EventLog/OpenLogEffects.cs
Comment thread src/EventLogExpert.Runtime/EventLog/OpenLogEffects.cs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated no new comments.

@jschick04 jschick04 marked this pull request as ready for review June 21, 2026 17:44
@jschick04 jschick04 requested a review from a team as a code owner June 21, 2026 17:44
@jschick04 jschick04 merged commit f9ddcf5 into jschick/embed-symbols-drop-m1 Jun 21, 2026
2 checks passed
@jschick04 jschick04 deleted the jschick/log-load-perf branch June 21, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants