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

Follow-up on review comments for the bounded queue #2008

Merged
merged 2 commits into from Jan 9, 2020
Merged

Follow-up on review comments for the bounded queue #2008

merged 2 commits into from Jan 9, 2020

Conversation

jpkrohling
Copy link
Contributor

@jpkrohling jpkrohling commented Jan 7, 2020

Which problem is this PR solving?

Short description of the changes

@jpkrohling jpkrohling changed the title WIP - Follow-up on review comments for the bounded queue Follow-up on review comments for the bounded queue Jan 8, 2020
@jpkrohling
Copy link
Contributor Author

This is now ready for review. The only thing missing based on the review comments is to either use a mutex for touching the queue or wrapping it in atomic.Value. The first implementation of the PR had mutexes to change the backing queue and we talked about changing it to use a second queue, so that we could avoid mutexes.

I might be missing something, but I took another look at the code and couldn't find any serious consequences of a concurrent read while the new queue is being set. At most, we'd be getting an updated value for the capacity, which in the worst case will cause a span to be dropped (the other case is that the queues will have one more span than the desired capacity).

If you think it's still worth having a lock, I can certainly add one for the Resize operation.

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@codecov
Copy link

codecov bot commented Jan 8, 2020

Codecov Report

Merging #2008 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2008      +/-   ##
==========================================
+ Coverage   96.93%   96.95%   +0.02%     
==========================================
  Files         205      205              
  Lines       10114    10119       +5     
==========================================
+ Hits         9804     9811       +7     
+ Misses        271      268       -3     
- Partials       39       40       +1
Impacted Files Coverage Δ
pkg/queue/bounded_queue.go 94.8% <100%> (+0.36%) ⬆️
plugin/storage/badger/spanstore/reader.go 96.79% <0%> (ø) ⬆️
...lugin/sampling/strategystore/adaptive/processor.go 100% <0%> (+0.79%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08a0a4b...12d5dee. Read the comment docs.

@@ -165,10 +170,13 @@ func (q *BoundedQueue) Resize(capacity int) bool {
swapped := atomic.CompareAndSwapPointer((*unsafe.Pointer)(unsafe.Pointer(&q.items)), unsafe.Pointer(q.items), unsafe.Pointer(&queue))
if swapped {
// start a new set of consumers, based on the information given previously
q.StartConsumers(q.workers, q.consumer)
q.StartConsumers(int(q.workers), q.consumer)
Copy link
Member

Choose a reason for hiding this comment

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

q.workers is already int

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you spot it using a different linter?

Copy link
Member

Choose a reason for hiding this comment

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

no, just paying attention

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should plug your brain in the CI, as our linters didn't catch it.

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@jpkrohling jpkrohling merged commit eb00999 into jaegertracing:master Jan 9, 2020
@jpkrohling jpkrohling deleted the 1949-Follow-up-PR branch July 28, 2021 19:22
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.

None yet

2 participants