Performance + maintainability improvements for HLC [timestamps, headers, coordinator, GUID factory]#34
Conversation
|
@copilot review |
|
@dexcompiler I've opened a new pull request, #35, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@cursoragent review this pr |
PR reviewI pulled What looks great
Nits / edge-case notes (non-blocking unless you want to tighten)
Overall: LGTM—the perf/memory changes are sensible, the refactor improves maintainability, and tests pass. |
Performance + maintainability improvements for HLC [timestamps, headers, coordinator, GUID factory]
…orks into hlc-perf-improvements
|
@cursoragent I have the made some changes to |
|
Nice update — the new One small correctness nit: Tests still pass for me in Release after the change (now 112 unit tests + 58 property tests). |


HLC timestamp
WriteTo(Span<byte>)/ReadFrom(ReadOnlySpan<byte>)usingBinaryPrimitivesfor counter/node.HlcTimestamp.Parse(ReadOnlySpan<char>)to enable allocation-free parsing from header segments.HLC coordinator + messaging header
HlcMessageHeader.ToString( )by usingstring.Create+Guid.TryFormat("N")instead of repeated concatenation.Parse(string)by using span-based parsing.HlcStatistics: uselong.Abs(delta)to avoid theMath.Abs(long.MinValue)overflow edge-case.HLC coordinator file organization
Split
HlcCoordinator.cssupporting types into dedicated files for readability and smaller diffs:HlcGuidFactory hot paths
Witness(HlcTimestamp)max selection to avoid temporary struct construction and repeated comparisons.CreateGuidFromHlc(HlcTimestamp, ReadOnlySpan<byte>)usingBinaryPrimitivesfor counter/node, while preserving version/variant bit layout.Witness(long)max computation logic.