22 Commits

Author SHA1 Message Date
tommi
7c3da27141 Add a missing DCHECK to PlatformThread::SetPriority.
This DCHECK is for the 'new and improved' way of setting thread priority.
What could happen is that code that's migrating over to the new method
might still have a lingering SetPriority call, that could incorrectly bind the
'spawned_thread_checker_' to the construction thread.

BUG=none

Review-Url: https://codereview.webrtc.org/2753423002
Cr-Commit-Position: refs/heads/master@{#17305}
2017-03-20 10:47:17 +00:00
tommi
db23ea69b6 Add performance tracing for PlatformThread and parts of the video code.
BUG=webrtc:7219

Review-Url: https://codereview.webrtc.org/2729783004
Cr-Commit-Position: refs/heads/master@{#17009}
2017-03-03 15:21:18 +00:00
tommi
0473b1dc03 Go back to only using sched_yield on Mac (sigh)
Using sched_yield on Linux seems to be causing RestartingSendStreamPreservesRtpStatesWithRtx/0 to never complete.

BUG=webrtc:7187
TBR=solenberg@webrtc.org

Review-Url: https://codereview.webrtc.org/2732443002
Cr-Commit-Position: refs/heads/master@{#16975}
2017-03-02 16:08:59 +00:00
tommi
500f1b7a32 Add a DCHECK for PlatformThread instances that are too busy.
This adds a simple mechanism that provides protection against
implementations that use the legacy callback type in PlatformThread
and are prone to entering a busy loop.

Enabled only in DCHECK enabled builds.

BUG=webrtc:7187

Review-Url: https://codereview.webrtc.org/2720223003
Cr-Commit-Position: refs/heads/master@{#16973}
2017-03-02 15:07:09 +00:00
danilchap
275234763b Revert of Use sched_yield on all POSIX platforms in PlatformThread. (patchset #1 id:1 of https://codereview.webrtc.org/2725573002/ )
Reason for revert:
breaks linux_ubsan bots.

Original issue's description:
> Reland of Use sched_yield on all POSIX platforms in PlatformThread. (patchset #1 id:1 of https://codereview.webrtc.org/2712133003/ )
>
> Reason for revert:
> Relanding - using sched_yield() in PlatformThread on all posix platforms.
>
> Original issue's description:
> > Revert of Use sched_yield on all POSIX platforms in PlatformThread. (patchset #1 id:1 of https://codereview.webrtc.org/2716683002/ )
> >
> > Reason for revert:
> > Reverting this change since it didn't affect the perf regressions we were seeing and actually seems to have caused more regressions as per comment in the bug.
> >
> > Original issue's description:
> > > Use sched_yield on all POSIX platforms in PlatformThread.
> > > (not only MacOS)
> > >
> > > This is a test to see if perf regressions we're seeing may be related to the use of nanosleep().
> > >
> > > BUG=695438
> > > TBR=solenberg@webrtc.org
> > >
> > > Review-Url: https://codereview.webrtc.org/2716683002 .
> > > Cr-Commit-Position: refs/heads/master@{#16807}
> > > Committed: 384498abb5
> >
> > TBR=solenberg@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=695438
> >
> > Review-Url: https://codereview.webrtc.org/2712133003
> > Cr-Commit-Position: refs/heads/master@{#16833}
> > Committed: 3ba1a8cd1b
>
> TBR=solenberg@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=695438
>
> Review-Url: https://codereview.webrtc.org/2725573002
> Cr-Commit-Position: refs/heads/master@{#16899}
> Committed: 4974df4183

TBR=solenberg@webrtc.org,tommi@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=695438

Review-Url: https://codereview.webrtc.org/2721893002
Cr-Commit-Position: refs/heads/master@{#16903}
2017-02-28 14:20:38 +00:00
tommi
4974df4183 Reland of Use sched_yield on all POSIX platforms in PlatformThread. (patchset #1 id:1 of https://codereview.webrtc.org/2712133003/ )
Reason for revert:
Relanding - using sched_yield() in PlatformThread on all posix platforms.

Original issue's description:
> Revert of Use sched_yield on all POSIX platforms in PlatformThread. (patchset #1 id:1 of https://codereview.webrtc.org/2716683002/ )
>
> Reason for revert:
> Reverting this change since it didn't affect the perf regressions we were seeing and actually seems to have caused more regressions as per comment in the bug.
>
> Original issue's description:
> > Use sched_yield on all POSIX platforms in PlatformThread.
> > (not only MacOS)
> >
> > This is a test to see if perf regressions we're seeing may be related to the use of nanosleep().
> >
> > BUG=695438
> > TBR=solenberg@webrtc.org
> >
> > Review-Url: https://codereview.webrtc.org/2716683002 .
> > Cr-Commit-Position: refs/heads/master@{#16807}
> > Committed: 384498abb5
>
> TBR=solenberg@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=695438
>
> Review-Url: https://codereview.webrtc.org/2712133003
> Cr-Commit-Position: refs/heads/master@{#16833}
> Committed: 3ba1a8cd1b

TBR=solenberg@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=695438

Review-Url: https://codereview.webrtc.org/2725573002
Cr-Commit-Position: refs/heads/master@{#16899}
2017-02-28 11:17:32 +00:00
deadbeef
37f5ecfd8f Replace NULL with nullptr or null in webrtc/base/.
BUG=webrtc:7147

Review-Url: https://codereview.webrtc.org/2718663005
Cr-Commit-Position: refs/heads/master@{#16878}
2017-02-27 22:06:41 +00:00
tommi
3ba1a8cd1b Revert of Use sched_yield on all POSIX platforms in PlatformThread. (patchset #1 id:1 of https://codereview.webrtc.org/2716683002/ )
Reason for revert:
Reverting this change since it didn't affect the perf regressions we were seeing and actually seems to have caused more regressions as per comment in the bug.

Original issue's description:
> Use sched_yield on all POSIX platforms in PlatformThread.
> (not only MacOS)
>
> This is a test to see if perf regressions we're seeing may be related to the use of nanosleep().
>
> BUG=695438
> TBR=solenberg@webrtc.org
>
> Review-Url: https://codereview.webrtc.org/2716683002 .
> Cr-Commit-Position: refs/heads/master@{#16807}
> Committed: 384498abb5

TBR=solenberg@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=695438

Review-Url: https://codereview.webrtc.org/2712133003
Cr-Commit-Position: refs/heads/master@{#16833}
2017-02-24 17:12:32 +00:00
Tommi
384498abb5 Use sched_yield on all POSIX platforms in PlatformThread.
(not only MacOS)

This is a test to see if perf regressions we're seeing may be related to the use of nanosleep().

BUG=695438
TBR=solenberg@webrtc.org

Review-Url: https://codereview.webrtc.org/2716683002 .
Cr-Commit-Position: refs/heads/master@{#16807}
2017-02-23 19:23:19 +00:00
tommi
0f8b403eb5 Introduce a new constructor to PlatformThread.
The new constructor introduces two new changes:

* Support specifying thread priority at construction time.
  - Moving forward, the SetPriority() method will be removed.
* New thread function type.
  - The new type has 'void' as a return type and a polling loop
    inside PlatformThread, is not used.

The old function type is still supported until all places have been moved over.

In this CL, the first steps towards deprecating the old mechanism are taken
by moving parts of the code that were simple to move, over to the new callback
type.

BUG=webrtc:7187

Review-Url: https://codereview.webrtc.org/2708723003
Cr-Commit-Position: refs/heads/master@{#16779}
2017-02-22 19:22:05 +00:00
tommi
82ead60076 Replace the stop_event_ in PlatformThread with an atomic flag
BUG=webrtc:7187

Review-Url: https://codereview.webrtc.org/2708433002
Cr-Commit-Position: refs/heads/master@{#16705}
2017-02-20 00:09:55 +00:00
perkj
6a2e20ad14 Make sure GetLastError on a PlatformThread return an error that is relevant to the thread.
BUG=none

Review-Url: https://codereview.webrtc.org/2541003002
Cr-Commit-Position: refs/heads/master@{#15328}
2016-11-30 12:53:14 +00:00
tommi
845afa8a02 Update PlatformThread to support a couple of new properties.
- name(): Returns the name of the thread (useful for debugging).
- GetThreadRef(): Returns the ID of the worker thread (also useful for debugging).
- QueueApc(): This is a Windows-only, protected function that allows derived classes on Windows to queue APCs to the worker thread.

NOTRY=true
(using notry since the patch has already passed the trybots and the cq is currently stalled)

Review URL: https://codereview.webrtc.org/1908373002

Cr-Commit-Position: refs/heads/master@{#12472}
2016-04-22 16:08:56 +00:00
sprang
e791ffd638 Remove non-monotonic clock support
Real time clock may cause problems as they can move (even backwards) if
the clock is changed, eg updated by NTP.

Non-monotonic clocks still in use on some platform (I'm looking at you,
Apple) for timed waits, but that should be less of an issue than actual
timestamps.

BUG=webrtc:5452

Review URL: https://codereview.webrtc.org/1613013002

Cr-Commit-Position: refs/heads/master@{#11375}
2016-01-26 09:53:24 +00:00
Peter Boström
8c38e8b9b9 Clean up PlatformThread.
* Move PlatformThread to rtc::.
* Remove ::CreateThread factory method.
* Make non-scoped_ptr from a lot of invocations.
* Make Start/Stop void.
* Remove rtc::Thread priorities, which were unused and would collide.
* Add ::IsRunning() to PlatformThread.

BUG=
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1476453002 .

Cr-Commit-Position: refs/heads/master@{#10812}
2015-11-26 16:45:57 +00:00
Peter Boström
7d842d660e Move thread_ conditional back under defines.
Unbreaks Windows builds.

BUG=
TBR=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1476543002 .

Cr-Commit-Position: refs/heads/master@{#10778}
2015-11-24 17:23:29 +00:00
Peter Boström
c661213a63 Skip setting thread priorities in NaCl.
Fixes Chromium build since PlatformThread is now built under NaCl.

BUG=
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1472083002 .

Cr-Commit-Position: refs/heads/master@{#10777}
2015-11-24 17:10:36 +00:00
Peter Boström
97c821dc56 Inline ConvertToSystemPriority.
Unused function when building Chromium, triggered build errors when
importing webrtc.

BUG=
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1471073005 .

Cr-Commit-Position: refs/heads/master@{#10768}
2015-11-24 12:48:20 +00:00
pbos
12411ef40e Move ThreadWrapper to ProcessThread in base.
Also removes all virtual methods. Permits using a thread from
rtc_base_approved (namely event tracing).

BUG=webrtc:5158
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1469013002

Cr-Commit-Position: refs/heads/master@{#10760}
2015-11-23 22:48:01 +00:00
henrikg
91d6edef35 Add RTC_ prefix to (D)CHECKs and related macros.
We must remove dependency on Chromium, i.e. we can't use Chromium's base/logging.h. That means we need to define these macros in WebRTC also when doing Chromium builds. And this causes redefinition.

Alternative solutions:
* Check if we already have defined e.g. CHECK, and don't define them in that case. This makes us depend on include order in Chromium, which is not acceptable.
* Don't allow using the macros in WebRTC headers. Error prone since if someone adds it there by mistake it may compile fine, but later break if a header in added or order is changed in Chromium. That will be confusing and hard to enforce.
* Ensure that headers that are included by an embedder don't include our macros. This would require some heavy refactoring to be maintainable and enforcable.
* Changes in Chromium for this is obviously not an option.

BUG=chromium:468375
NOTRY=true

Review URL: https://codereview.webrtc.org/1335923002

Cr-Commit-Position: refs/heads/master@{#9964}
2015-09-17 07:24:51 +00:00
Tommi
ea14f0ac11 Move SetCurrentThreadName to platform_thread.* in rtc_base_approved,
update all webrtc and libjingle code to use the same function and remove
extra implementations.

BUG=
R=andresp@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/55439004

Cr-Commit-Position: refs/heads/master@{#9205}
2015-05-18 11:50:31 +00:00
Tommi
bebc69010d Add platform_thread source files and move types from thread_checker_impl to there.
BUG=
R=henrika@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/52529004

Cr-Commit-Position: refs/heads/master@{#9201}
2015-05-18 07:51:16 +00:00