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

Streaming cpu high usage fix #1844

Closed

Conversation

abernste
Copy link
Contributor

@abernste abernste commented Jun 6, 2018

Bug fix: The CPU usage is too high when running Realsense Viewer while streaming is enabled.
Found the bug on post processing filters render loop thread
The thread is polling for new frames on a high frequency
The fix: change render loop thread from frame polling to wait for frame with small timeout (100 msec)
This will free the CPU (sleep) until frame arrives, without delay on new frames,
and not hang the render thread for more than 100 msec when video stream is disabled.

abernste added 2 commits June 6, 2018 13:47
Merge from IntelRealSense/librealsense/master
…e streaming is enabled.

Found the bug on post processing filters render loop thread
The thread is polling for new frames on a high frequency
The fix: change render loop thread from frame polling to wait for frame with small timeout (100 msec)
This will free the CPU (sleep) until frame arrives, without delay on new frames,
and not hang the render thread for more than 100 msec when video stream is disabled.
@abernste
Copy link
Contributor Author

abernste commented Jun 6, 2018

This fix is a suggested fix to: #1809

@abernste
Copy link
Contributor Author

abernste commented Jun 7, 2018

Wait for frames CPU usage Close delay
1 23% Immediate
10 20% Immediate
20 15% Immediate
30 10% Immediate
100 10% Immediate
1000 10% 1 sec

I would go with 30 msec, agree?

This will set the lowest CPU usage + shortest stream close delay
@dorodnic
Copy link
Contributor

I'm concerned that this will introduce frequent handled exceptions, preventing effective debugging of the application. The issue is with wait_for_frame throwing on time-out. Am I wrong?

@abernste
Copy link
Contributor Author

@dorodnic
As I run this on release (to check CPU load), I didn't see any timeout exception.
Maybe on debug there are exception..
Maybe we can remove the timeout check in rs2_wait_for_frame on debug?
Maybe we can add a new default parameter to function single_consumer_queue:dequeue to ignore timeouts?
I think its better to use wait_for_frame from our framework instead of writing a new one just for the render function.
Do you suggest something else?

@dorodnic
Copy link
Contributor

In #1730 we had a proposal to change the time-out behaviour of wait_for_frames. Overall, it would make sense. Lets discuss internally first.

@abernste
Copy link
Contributor Author

Pending this pull request for wait_for_frame refactoring.
(Remove exception on wait_for_frame timeout)

@dorodnic
Copy link
Contributor

Continued on #2055

@dorodnic dorodnic closed this Jul 15, 2018
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.

2 participants