Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: content/common/gpu/sync_point_manager.cc

Issue 279303003: Randomize sync point starting number to reduce risk of GPU hangs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/gpu/sync_point_manager.h" 5 #include "content/common/gpu/sync_point_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h"
8 9
9 namespace content { 10 namespace content {
10 11
12 static const int kMaxSyncBase = 10000000;
piman 2014/05/14 19:21:29 Because of the birthday paradox, the collision ris
13
11 SyncPointManager::SyncPointManager() 14 SyncPointManager::SyncPointManager()
12 : next_sync_point_(1) { 15 : next_sync_point_(base::RandInt(1, kMaxSyncBase)) {
16 // To reduce the risk that a sync point created in a previous GPU process
17 // will be in flight in the next GPU process, randomize the starting sync
18 // point number.
piman 2014/05/14 19:21:29 nit: can you file a bug to revisit this (assign to
13 } 19 }
14 20
15 SyncPointManager::~SyncPointManager() { 21 SyncPointManager::~SyncPointManager() {
16 } 22 }
17 23
18 uint32 SyncPointManager::GenerateSyncPoint() { 24 uint32 SyncPointManager::GenerateSyncPoint() {
19 base::AutoLock lock(lock_); 25 base::AutoLock lock(lock_);
20 uint32 sync_point = next_sync_point_++; 26 uint32 sync_point = next_sync_point_++;
21 27
22 // Note: wrapping would take days for a buggy/compromized renderer that would 28 // Note: wrapping would take days for a buggy/compromized renderer that would
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 bool SyncPointManager::IsSyncPointRetired(uint32 sync_point) { 66 bool SyncPointManager::IsSyncPointRetired(uint32 sync_point) {
61 DCHECK(thread_checker_.CalledOnValidThread()); 67 DCHECK(thread_checker_.CalledOnValidThread());
62 { 68 {
63 base::AutoLock lock(lock_); 69 base::AutoLock lock(lock_);
64 SyncPointMap::iterator it = sync_point_map_.find(sync_point); 70 SyncPointMap::iterator it = sync_point_map_.find(sync_point);
65 return it == sync_point_map_.end(); 71 return it == sync_point_map_.end();
66 } 72 }
67 } 73 }
68 74
69 } // namespace content 75 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698