Chromium Code Reviews

Issue 2035483003: Hibernate the thread if there are no events in the queue. Wake it up when an event is added to the … (Closed)

Created:
4 years, 6 months ago by terelius
Modified:
4 years, 6 months ago
Reviewers:
ivoc, pbos-webrtc, stefan-webrtc, Stefan, tommi
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com, the sun, stefan-webrtc, mflodman
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

Hibernate the thread if there are no events in the queue. Wake it up when an event is added to the queue. BUG=614192 Committed: https://crrev.com/bea8959687abe97585a70b43152d8c90d8f7aa11 Cr-Commit-Position: refs/heads/master@{#13070}

Patch Set 1 #

Patch Set 2 : Nit #

Total comments: 10

Patch Set 3 : Rename signaling events and move to helper class. Change int to bool. #

Total comments: 2

Patch Set 4 : Rename SignalStopFile() -> WaitForFileFinished() #

Total comments: 2
Unified diffs Side-by-side diffs Stats (+70 lines, -52 lines)
M webrtc/call/rtc_event_log.cc View 11 chunks +17 lines, -26 lines 2 comments
M webrtc/call/rtc_event_log_helper_thread.h View 2 chunks +15 lines, -9 lines 0 comments
M webrtc/call/rtc_event_log_helper_thread.cc View 13 chunks +38 lines, -17 lines 0 comments

Messages

Total messages: 26 (9 generated)
terelius
I went with Stefan's suggestion, which is that if the output thread wakes up only ...
4 years, 6 months ago (2016-06-03 08:24:45 UTC) #3
pbos-webrtc
https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log_helper_thread.h File webrtc/call/rtc_event_log_helper_thread.h (right): https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log_helper_thread.h#newcode111 webrtc/call/rtc_event_log_helper_thread.h:111: rtc::Event* end_hibernation_; Shouldn't the wake_up_ event be sufficient to ...
4 years, 6 months ago (2016-06-03 08:51:06 UTC) #5
pbos-webrtc
https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log.cc File webrtc/call/rtc_event_log.cc (right): https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log.cc#newcode265 webrtc/call/rtc_event_log.cc:265: end_hibernation_.Set(); Should the last three lines here be replaced ...
4 years, 6 months ago (2016-06-03 08:54:25 UTC) #6
stefan-webrtc
lgtm % nits, and please consider pbos comments too. https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log_helper_thread.cc File webrtc/call/rtc_event_log_helper_thread.cc (right): https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log_helper_thread.cc#newcode123 webrtc/call/rtc_event_log_helper_thread.cc:123: ...
4 years, 6 months ago (2016-06-03 08:55:44 UTC) #8
pbos-webrtc
https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log_helper_thread.h File webrtc/call/rtc_event_log_helper_thread.h (right): https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log_helper_thread.h#newcode80 webrtc/call/rtc_event_log_helper_thread.h:80: int LogToMemory(); size_t or preferably just a bool for ...
4 years, 6 months ago (2016-06-03 08:56:15 UTC) #9
terelius
Please take another look. https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log.cc File webrtc/call/rtc_event_log.cc (right): https://codereview.webrtc.org/2035483003/diff/20001/webrtc/call/rtc_event_log.cc#newcode265 webrtc/call/rtc_event_log.cc:265: end_hibernation_.Set(); On 2016/06/03 08:54:25, pbos-webrtc ...
4 years, 6 months ago (2016-06-08 11:47:29 UTC) #10
pbos-webrtc
https://codereview.webrtc.org/2035483003/diff/40001/webrtc/call/rtc_event_log.cc File webrtc/call/rtc_event_log.cc (right): https://codereview.webrtc.org/2035483003/diff/40001/webrtc/call/rtc_event_log.cc#newcode255 webrtc/call/rtc_event_log.cc:255: helper_thread_.SignalStopFile(); // Wake up thread and wait for it ...
4 years, 6 months ago (2016-06-08 12:25:42 UTC) #11
ivoc
lgtm.
4 years, 6 months ago (2016-06-08 12:29:32 UTC) #12
pbos-webrtc
On 2016/06/08 12:29:32, ivoc wrote: > lgtm. lgtm
4 years, 6 months ago (2016-06-08 13:12:52 UTC) #13
terelius
https://codereview.webrtc.org/2035483003/diff/40001/webrtc/call/rtc_event_log.cc File webrtc/call/rtc_event_log.cc (right): https://codereview.webrtc.org/2035483003/diff/40001/webrtc/call/rtc_event_log.cc#newcode255 webrtc/call/rtc_event_log.cc:255: helper_thread_.SignalStopFile(); // Wake up thread and wait for it ...
4 years, 6 months ago (2016-06-08 13:13:42 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2035483003/60001
4 years, 6 months ago (2016-06-08 13:14:09 UTC) #17
commit-bot: I haz the power
Committed patchset #4 (id:60001)
4 years, 6 months ago (2016-06-08 14:20:34 UTC) #19
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/bea8959687abe97585a70b43152d8c90d8f7aa11 Cr-Commit-Position: refs/heads/master@{#13070}
4 years, 6 months ago (2016-06-08 14:20:47 UTC) #21
tommi
drive by observations https://codereview.webrtc.org/2035483003/diff/60001/webrtc/call/rtc_event_log.cc File webrtc/call/rtc_event_log.cc (right): https://codereview.webrtc.org/2035483003/diff/60001/webrtc/call/rtc_event_log.cc#newcode291 webrtc/call/rtc_event_log.cc:291: StoreEvent(&event); This pattern looked strange to ...
4 years, 6 months ago (2016-06-08 15:26:40 UTC) #23
terelius
https://codereview.webrtc.org/2035483003/diff/60001/webrtc/call/rtc_event_log.cc File webrtc/call/rtc_event_log.cc (right): https://codereview.webrtc.org/2035483003/diff/60001/webrtc/call/rtc_event_log.cc#newcode291 webrtc/call/rtc_event_log.cc:291: StoreEvent(&event); On 2016/06/08 15:26:40, tommi-webrtc wrote: > This pattern ...
4 years, 6 months ago (2016-06-08 17:52:17 UTC) #24
tommi
On 2016/06/08 17:52:17, terelius wrote: > https://codereview.webrtc.org/2035483003/diff/60001/webrtc/call/rtc_event_log.cc > File webrtc/call/rtc_event_log.cc (right): > > https://codereview.webrtc.org/2035483003/diff/60001/webrtc/call/rtc_event_log.cc#newcode291 > ...
4 years, 6 months ago (2016-06-09 14:06:34 UTC) #25
terelius
4 years, 6 months ago (2016-06-14 09:56:02 UTC) #26
Message was sent while issue was closed.
On 2016/06/09 14:06:34, tommi-webrtc wrote:
> On 2016/06/08 17:52:17, terelius wrote:
> >
>
https://codereview.webrtc.org/2035483003/diff/60001/webrtc/call/rtc_event_log.cc
> > File webrtc/call/rtc_event_log.cc (right):
> > 
>
https://codereview.webrtc.org/2035483003/diff/60001/webrtc/call/rtc_event_log...
> > webrtc/call/rtc_event_log.cc:291: StoreEvent(&event);
> > 
> > If the queue is full, then it is definitely not a bug to signal that there
are
> > new (i.e. unprocessed) events. Perhaps the function name could be chosen
> better,
> > but I wanted a name that makes it clear that the function should be called
> after
> > every inserted event.
> 
> My point was that if the queue is full and an event is not inserted, we still
> signal.  That's one signal for no event.

I understand what you mean (and it should be redundant to signal if no event was
added), but it is not a bug. The signal we send to the thread means "there are
events in the queues". If the queue is full, it is perfectly reasonable to wake
up the thread and inform it that there are events to be processed.

> > The Start and Stop methods are used to control whether we log to file. In
> > chromium we get the filename from the user, so we can't easily start logging
> > automatically. Note that calling Stop in the destructor wouldn't help at
all;
> > the problem isn't that we somehow "forget" to stop, the problem is that the
> > destructors never get called in the first place.
> 
> If Stop() gets called, couldn't that be the place where we'd delete the
object?
> (similarly, match Start() with the ctor?)

Which object do you want to delete? We can't delete the RtcEventLog object while
the Call exists since we have pointers to the event log in multiple components.
Once ivoc@ moves the event log ownership to Call, it will be deleted
automatically when the Call ends. (This will also terminate the helper thread.)

We could delete the RtcEventLogHelperThread when we are no longer writing to
file, but that would require larger changes than this CL. Also, previous
reviewers preferred a solution where the RtcEventLog can be oblivious to how the
events are handled; the decision between logging to memory and logging to file
is done by the helper thread. This design is also similar to the Process()
functions that are used all over WebRTC. If we want to only run the thread when
writing to file (and still keep a short history in memory when not logging to
file), then the RtcEventLog would have to store the events in the right memory
buffer which would potentially move some extra work from the helper thread to
the real-time thread.

TL;DR: I don't think this is a bad idea, but it would take more time to
implement and verify. Maintaining a history on the real-time thread would also
interfere with some ideas we have for reducing the memory usage, and we need to
understand that space-time trade-off.

Powered by Google App Engine