Skip to content

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Jul 10, 2025

Fixes #5957

@Youssef1313 Youssef1313 marked this pull request as draft July 10, 2025 11:24
@Youssef1313 Youssef1313 marked this pull request as ready for review July 10, 2025 15:44
@Youssef1313 Youssef1313 marked this pull request as draft July 10, 2025 15:55
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Please upload report for BASE (rel/4.0@40ff27c). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...er.PlatformServices/ObjectModel/UnitTestElement.cs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             rel/4.0    #5974   +/-   ##
==========================================
  Coverage           ?   65.03%           
==========================================
  Files              ?      579           
  Lines              ?    32355           
  Branches           ?        0           
==========================================
  Hits               ?    21041           
  Misses             ?    11314           
  Partials           ?        0           
Flag Coverage Δ
Debug 65.03% <0.00%> (?)
integration 65.03% <0.00%> (?)
production 65.03% <0.00%> (?)
unit 65.03% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...er.PlatformServices/ObjectModel/UnitTestElement.cs 65.97% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Youssef1313
Copy link
Member Author

From discussion with @tannergooding, the version field can be used by tools to interpret Guid in certain ways.

https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-version-1

Version 1 for example is for UTC timestamps and network card MAC address encoding.
Version 3 is for values computed by MD5, etc etc.

If we want to embed our own version while following the RFC properly, we should use version 8, and reserve other bits for embedding our "own" version.

Note that in the past, I think we never followed the RFC accurately, as we just hashed and passed that to Guid constructor, meaning we are creating random versions, and none of the tools reading TRX today tries to interpret the version following the spec. So we were mostly okay, but still we violated the spec.

In addition, XxHash128 output is big endian, so it's best if we do new Guid(hash, bigEndian: true) instead of new Guid(hash).

Note that there is not much of a concern of us using extra bits for reserving our version with regards to collision probability, as it's still very unlikely to practically see collisions.

I think that summarizes our discussion @tannergooding (hopefully accurately/correctly).

@Youssef1313 Youssef1313 changed the title Set Guid version to 1 Set Guid version to 8 and embed reserve 4-bits for our own version "1" for now. Aug 19, 2025
@Youssef1313 Youssef1313 marked this pull request as ready for review August 19, 2025 11:45
Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

Approving but I'll let you merge once you get the confirmation.

Copy link
Member

@nohwnd nohwnd left a comment

Choose a reason for hiding this comment

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

Will rewrite in a way that touches single bytes.

@nohwnd
Copy link
Member

nohwnd commented Aug 20, 2025

Removed that complicated pointer logic, and instead we now edit just the appropriate bytes in the byte array. The byte array is always the same no matter if we are on big endian or little endian system, because endiannes only affects order of bytes, not order of bits within those bytes (and the hashing code handles it in a way that big endian is always returned).

image

This makes it very easy to find the bytes we need to edit. We edit the first half of the first byte (index 0), and set that to 0b0001. to set our version. The mask is "generated" by shifting the value 4 bits to the left, because it would be easy to specify the version as 0b1000 instead of the correct 0b1000_0000, so we would edit the wrong half of the byte.

The testcases changed a bit because I don't think the original code was correct.

Here a comparison of guid that is just letters a, shown as bits, before modification, after modification with the original code, and after modification with the new code:

image

@nohwnd
Copy link
Member

nohwnd commented Aug 20, 2025

@nohwnd
Copy link
Member

nohwnd commented Aug 21, 2025

Finally correct, despite the inconsistencies in guid.

image

@nohwnd
Copy link
Member

nohwnd commented Aug 22, 2025

Final code, tested on big endian system (s390x + rhel) vs little endian system (just normal boring windows :D )

image image

@nohwnd nohwnd merged commit ab8d4f9 into rel/4.0 Aug 22, 2025
8 checks passed
@nohwnd nohwnd deleted the dev/ygerges/id-cont branch August 22, 2025 15:49
@Youssef1313 Youssef1313 linked an issue Sep 11, 2025 that may be closed by this pull request
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.

Form correct v8 guid from the hashed data for new ID
4 participants