Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a timestamp component to qos in order to prioritize older/newer messages #148

Merged
merged 5 commits into from
May 31, 2024

Conversation

denopink
Copy link
Contributor

@denopink denopink commented May 29, 2024

  • 100% test cover for internal/wrphandlers/qos
  • added PrioritizeOldest options for qos
  • if PrioritizeOldest is false, then qos will favor the newest message during a qos value tie breaker (vice versa)
    - Updated priorityQueue.trim() to remove messages with the lowest qos value (taking PrioritizeOldest into account as well)

@denopink denopink added the feature new functionality proposal/implementation label May 29, 2024
@denopink denopink requested review from schmidtw and johnabass May 29, 2024 17:58
@denopink denopink self-assigned this May 29, 2024
…ewer messages

- 100% test cover for `internal/wrphandlers/qos`
- added `PrioritizeOldest` options for qos
- if `PrioritizeOldest` is false, then qos will favor the newest message during a qos value tie breaker (vice versa)
- Updated `priorityQueue.trim()` to remove messages with the lowest qos value (taking `PrioritizeOldest` into account as well)
@denopink denopink force-pushed the denopink/feat/qos-with-timestamp-ordering branch from e525819 to 5e0befb Compare May 29, 2024 18:04
@@ -51,34 +64,69 @@ func (pq *priorityQueue) Enqueue(msg wrp.Message) error {
return nil
}

// trim removes messages with the lowest QualityOfService (taking `prioritizeOldest` into account)
// until the queue no longer violates `maxQueueSize“.
func (pq *priorityQueue) trim() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Introduced this since we described a desire to keep messages with higher qos value taking the age of the message into account as well


// heap.Init() is required since the prioritization was switch to messages with the lowest QualityOfService.
// The complexity of heap.Init() is O(n) where n = h.Len().
heap.Init(pq)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we end up needing to trim often, then the O(n) cost of heap.Init() may start to sting...

I wanted to point that out in case we can't afford the O(n) cost of heap.Init() and we would rather trim() random messages instead.

cmd/xmidt-agent/config.go Outdated Show resolved Hide resolved
internal/wrphandlers/qos/priority_queue.go Outdated Show resolved Hide resolved
internal/wrphandlers/qos/options.go Outdated Show resolved Hide resolved
@denopink denopink requested a review from schmidtw May 30, 2024 17:47
internal/wrphandlers/qos/priority_queue.go Outdated Show resolved Hide resolved
internal/wrphandlers/qos/priority_queue.go Outdated Show resolved Hide resolved
@denopink denopink requested a review from schmidtw May 30, 2024 20:25
@schmidtw schmidtw merged commit 62d5d71 into main May 31, 2024
15 checks passed
@schmidtw schmidtw deleted the denopink/feat/qos-with-timestamp-ordering branch May 31, 2024 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature new functionality proposal/implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants