Skip to content

Performance + maintainability improvements for HLC [timestamps, headers, coordinator, GUID factory]#35

Merged
dexcompiler merged 1 commit intohlc-perf-improvementsfrom
copilot/sub-pr-34
Feb 8, 2026
Merged

Performance + maintainability improvements for HLC [timestamps, headers, coordinator, GUID factory]#35
dexcompiler merged 1 commit intohlc-perf-improvementsfrom
copilot/sub-pr-34

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

Optimizations for HLC hot paths and file organization improvements. All changes preserve HLC algorithm semantics while reducing allocations and improving code clarity.

HlcTimestamp

  • WriteTo/ReadFrom: Use BinaryPrimitives for counter/node serialization
  • Add Parse(ReadOnlySpan<char>) for allocation-free parsing from header segments
  • Refactor ToPackedInt64() with explicit ulong intermediates to reduce casts

HlcMessageHeader

  • ToString(): Use string.Create + Guid.TryFormat("N") instead of concatenation
  • Parse(): Span-based parsing eliminates Split() allocations

HlcStatistics

  • Use long.Abs(delta) to avoid Math.Abs(long.MinValue) overflow edge case

HlcGuidFactory

  • Increase RNG buffer 64→256 bytes to reduce refill frequency under lock (4× improvement)
  • Witness(HlcTimestamp): Eliminate temp struct allocations by inlining max selection logic
  • Witness(long): Replace nested Math.Max with sequential comparisons
  • CreateGuidFromHlc(): Use BinaryPrimitives for counter/node packing while preserving version/variant bits

File organization
Split HlcCoordinator.cs supporting types into dedicated files:

  • HlcStatistics.cs
  • HlcMessageHeader.cs
  • HlcClusterRegistry.cs

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Optimize performance and maintainability for HLC components Performance + maintainability improvements for HLC [timestamps, headers, coordinator, GUID factory] Feb 8, 2026
Copilot AI requested a review from dexcompiler February 8, 2026 04:16
@dexcompiler dexcompiler marked this pull request as ready for review February 8, 2026 04:24
@dexcompiler dexcompiler merged commit 5e905e1 into hlc-perf-improvements Feb 8, 2026
1 check 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.

2 participants