Skip to content

Enhance TDH decoder to support manifest-based events and improve schema caching logic#313

Merged
brianrob merged 4 commits into
microsoft:mainfrom
swashtek:feature/tdh-manifest-decode
Jul 24, 2026
Merged

Enhance TDH decoder to support manifest-based events and improve schema caching logic#313
brianrob merged 4 commits into
microsoft:mainfrom
swashtek:feature/tdh-manifest-decode

Conversation

@swashtek

@swashtek swashtek commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Enhance TDH decoder to support manifest-based events and improve schema caching logic

Issue: #310

@swashtek
swashtek marked this pull request as ready for review July 21, 2026 06:54
Comment thread one_collect/src/etw/tdh.rs Outdated
Comment thread one_collect/src/etw/tdh.rs
Comment thread one_collect/src/etw/tdh.rs Outdated
Comment thread one_collect/src/etw/tdh.rs
Comment thread one_collect/src/etw/tdh.rs Outdated
Comment thread one_collect/src/etw/tdh.rs
@swashtek

Copy link
Copy Markdown
Contributor Author

@utpilla Thank you for feedback, I've addressed your comments in 19ae1fe

@brianrob brianrob left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for putting this together. A few questions / comments below.

Comment thread one_collect/src/etw/tdh.rs Outdated
Comment thread one_collect/src/etw/tdh.rs Outdated
let map = if is_32bit { &self.cache_32 } else { &self.cache_64 };
/// Returns the index of a cached TraceLogging schema, or `None` on a
/// miss. The key is hashed exactly once.
fn index_of_tl(&self, key: &[u8], is_32bit: bool) -> Option<usize> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Question - should we consider a scheme that preserves index_of and insert instead of having TL and manifest specific methods? In this scheme, the methods would take metadata as a single parameter, perhaps an enum that would contain either the TL key info or the ManifestKey as well as is_32bit and event_type which could be TraceLogging or Manifest. This would allow for selection of the cache in a single method instead of having to pick the right one. This would simplify the API design.

@swashtek swashtek Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea. The enum is actually already here as SchemaSource, and lookup_cached / insert_cached match on it today, so we're most of the way to what you're describing.
The remaining question is whether to push that match down into SchemaCache itself with a unified index_of(meta) / insert(meta, schema).

This relocates the branch rather than removing it. The two positive maps have different key types (HashMap<Vec<u8>, _> for TL vs HashMap<ManifestEventKey, _> for manifest), so a unified index_of still needs a 2-arm match inside to select the map pair, the "pick the right cache" step just moves into the cache instead of disappearing.

Additionally, lookup wants to borrow the TL key (&[u8]) while insert must own it (Vec<u8>), and the negative cache (is_manifest_unsupported) is manifest-only with no TL analog, so it stays separate regardless.

If we do fold it, I'd reuse the existing SchemaSource variant as the discriminant (rather than adding a parallel event_type field, which could drift out of sync with the variant) and keep is_32bit as its own parameter since it's orthogonal to the key.

Since this is purely an internal API-shape change with no behavior difference, I'd suggest we land it as a small follow-up so this PR stays scoped to the manifest/caching functionality, happy to open that up right after.
Let me know your thoughts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds great. Your latest commit looks good too. Happy to consider the API shape change in a subsequent PR.

@swashtek
swashtek force-pushed the feature/tdh-manifest-decode branch from 1370e9c to 46aa0df Compare July 24, 2026 01:07
@brianrob
brianrob merged commit 8233b92 into microsoft:main Jul 24, 2026
18 checks passed
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.

3 participants