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

Don't poll more than needed in BSP. #2971

Closed
wants to merge 1 commit into from

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Mar 3, 2021

Just whipped this up to compare against #2969. @sbandadd sorry if this overlaps with any approach you've tried.

@anuraaga anuraaga requested a review from jkwatson March 3, 2021 05:02
@jkwatson
Copy link
Contributor

jkwatson commented Mar 3, 2021

would love some benchmarking results along with these changes so we can compare apples to apples and not just guess at what might be better. :)

@anuraaga
Copy link
Contributor Author

anuraaga commented Mar 3, 2021

Yup - it'll be a bit tricky since I don't think we have any overhead benchmarks where we'd measure e.g. CPU usage of a change. Might work on it but wanted to throw this out there first

@jkwatson
Copy link
Contributor

jkwatson commented Mar 3, 2021

Along with any of these benchmarks of the BSP, we should also include metrics output so we can see how many spans we're dropping because the queue is full. I suspect this is a confounding factor that might be skewing results.

@@ -261,9 +272,13 @@ private void exportCurrentBatch() {
return;
}

for (ReadableSpan span : batch) {
batchData.add(span.toSpanData());
Copy link
Contributor

Choose a reason for hiding this comment

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

For good or ill, moving this down here will make the CPU usage a bit more spiky, since we'll only do this conversion all at once when the queue is full, or when the timer expires. The current implementation will spread out the conversion smoothly, since it happens as each span is added to the queue. Which way is better? I'm not sure, honestly, but it's something to keep in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah there's some tradeoff - I guess for a thread with a defined "interval", I'd sort of expect it to wake, work, sleep. We have a bit of a pathological behavior right now where it's fairly conceivable for this thread to be sleeping and waking in a thrashing manner if a span is recorded every 101ms for example - sleeping/waking is very expensive and I suspect we didn't intend that to be possible.

@@ -127,10 +127,12 @@ public CompletableResultCode forceFlush() {
private long nextExportTime;

private final BlockingQueue<ReadableSpan> queue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Using ArrayDequeue would be better when draining in batches similar to https://github.com/sbandadd/opentelemetry-java/pull/1/files. But I think the most important thing is to come up with a CPU benchmark and compare different versions.

@anuraaga
Copy link
Contributor Author

Superceded by #2983

@anuraaga anuraaga closed this Mar 19, 2021
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