Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@notthetup
Copy link
Collaborator

@notthetup notthetup commented Aug 20, 2025

We need UUID when creating new Message.msgID and JSONMessage.id for fjage. Historically we used various UUID/GUID implementations mainly from standard library but sometimes custom. The main requirement is uniqueness across all messages send in a single fjage "universe".

While the previous implementations of UUID/GUID were sufficient for that, the new (and upcoming) UUID7 standard has a couple of useful features.

  • Since the MSB of the UUID7 is a millisecond level timestamp, it's easy to sort messages using the msgID.
  • Since the MSB of the UUID7 is a millisecond level timestamp, we can use the timestamp to know when messages were created. This could be useful for collecting metrics and logging how long messages stayed in queues etc.

See more : http://uuid7.com/

@notthetup notthetup requested a review from Copilot August 20, 2025 08:40
Copy link
Contributor

Copilot AI left a comment

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 migrates the fjage framework from using standard UUID4 to UUID7 for message IDs. UUID7 provides time-based sorting capabilities and embedded timestamps, which enables better message ordering and metrics collection.

Key changes:

  • Implements UUID7 generation across all supported languages (Java, Python, JavaScript, C)
  • Updates message creation to use UUID7 instead of UUID4
  • Adjusts tests to accommodate UUID7's longer string format

Reviewed Changes

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

Show a summary per file
File Description
src/main/java/org/arl/fjage/UUID7.java New Java implementation of UUID7 with timestamp extraction and UUID compatibility
src/main/java/org/arl/fjage/Message.java Updated to use UUID7 for message ID generation
gateways/python/fjagepy/__init__.py Updated Python gateway to use UUID7 for message IDs and request IDs
gateways/python/fjagepy/UUID7.py New Python implementation of UUID7 with comparable interface
gateways/js/test/spec/fjage.spec.js Updated test to handle UUID7's variable length format
gateways/js/src/utils.js Added JavaScript UUID7 implementation
gateways/js/src/message.js Updated JavaScript message creation to use UUID7
gateways/c/src/fjage.c Added C implementation of UUID7 and updated message/request ID generation
Comments suppressed due to low confidence (1)

gateways/python/fjagepy/init.py:601

  • The removal of UUID parsing logic in the dispatch function may cause issues if the system still receives UUID4 format IDs from older clients or during migration. The code should handle both UUID4 and UUID7 string formats.
        rsp = dict()

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

…essage.id

in fjage Java implementation and also the JS, Python, and C gateways
Copy link
Member

@mchitre mchitre left a comment

Choose a reason for hiding this comment

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

Have we benchmarked the performance of UUID7 vs the Java UUID implementation we were using to know the impact? Also, we need to add this to Fjage.jl too.

@notthetup
Copy link
Collaborator Author

notthetup commented Aug 20, 2025

Have we benchmarked the performance of UUID7 vs the Java UUID implementation we were using to know the impact? Also, we need to add this to Fjage.jl too.

No. I can do this, although I doubt it would be critical.

@notthetup
Copy link
Collaborator Author

I did a Java Micro Benchmark using the implementation in this PR and the attached JMH test harness.

Results :

Benchmark Mode Cnt Score Error Units
UuidBenchmark.generateJdkUUID thrpt 5 4535792.068 ± 89795.365 ops/s
UuidBenchmark.generateUUID7 thrpt 5 6284723.497 ± 836342.781 ops/s

So if anything the UUID7 implementation is faster that the default JDK based one.

UuidBenchmark.java

@notthetup notthetup merged commit 2a073eb into master Aug 21, 2025
2 checks passed
@notthetup notthetup deleted the uuid7 branch August 21, 2025 05:43
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