Skip to content

Enhance queue handling with new configurations and tie-breaking logic#1

Draft
twisti-dev wants to merge 7 commits intomasterfrom
fix/queue
Draft

Enhance queue handling with new configurations and tie-breaking logic#1
twisti-dev wants to merge 7 commits intomasterfrom
fix/queue

Conversation

@twisti-dev
Copy link
Copy Markdown
Contributor

This pull request introduces a new, more robust queue scoring system for Redis, improving ordering precision and tie-breaking for queue entries. It replaces the previous RedisQueueScorePacker with a new RedisQueueScore value class, updates all queue logic to use this new system, and refactors several queue-related classes for better reliability and maintainability. Additionally, it includes minor dependency and configuration updates.

Queue scoring and ordering improvements:

  • Introduced RedisQueueScore, a value class that packs priority, timestamp, and a 6-bit sequence into a 53-bit value, ensuring total ordering in Redis sorted sets and supporting up to 64 entries per millisecond. This replaces the old RedisQueueScorePacker [1] [2].
  • Updated all queue logic to use RedisQueueScore for packing/unpacking scores, including tie-breaking logic with a per-instance enqueueSequence counter to prevent collisions when multiple entries are enqueued in the same millisecond [1] [2] [3] [4] [5].

Queue store and API enhancements:

  • Refactored RedisQueueStore to use helper methods for atomic Redis batch operations and updated all relevant methods to work with RedisQueueScore instead of raw Double values [1] [2] [3].
  • Added utility methods to AbstractSurfQueue for retrieving queue entry metadata, score, last seen time, and retry count.

Reliability and logging:

  • Improved lock management in RedisQueueLockManager by adding error handling and logging for failed lock releases [1] [2] [3].

Configuration and dependency updates:

  • Changed the Redis queue key prefix to queue:v2: to avoid collisions with previous queue versions.
  • Updated Kotlin and Gradle library versions and made minor IDE configuration changes [1] [2] [3].

Performance and safety:

  • Optimized buffer allocation in QueueEntryCodec for more efficient serialization.

These changes collectively provide more accurate queue ordering, improved concurrency safety, and better maintainability for the queue system.

- set buffer size in QueueEntryCodec to a constant for better readability
- improve buffer initialization by specifying min and max capacity
…handling

- rename startTransferring to startTicking for clarity
- add SurfQueueConfig for managing queue settings
- implement TransferAction enum for better transfer state management
- enhance PaperQueue with tickSecond method for periodic processing
- add QueueMetrics for tracking queue performance metrics
@twisti-dev twisti-dev self-assigned this Apr 9, 2026
@twisti-dev twisti-dev added status: in progress Issue is currently being worked on type: Fix PR that fixes an issue labels Apr 9, 2026
- change command tree name from "squeue" to "squeue-velocity" for clarity
…ated updates

- rename AbstractSurfQueue to AbstractQueue for consistency
- update references in PaperSurfQueue and related files
- introduce QueueTicker for managing queue ticks
- implement cleanup logic in PaperQueueCleanup
- enhance performance with optimized UUID handling in queue methods
… update references

- rename VelocitySurfQueue class to VelocityQueueImpl for consistency
- update all references to VelocitySurfQueue in related files
- adjust QueueDisplay and QueuePlayerListener to use new class name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: in progress Issue is currently being worked on type: Fix PR that fixes an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant