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

Side by Side Diff: src/libplatform/default-platform.cc

Issue 1785933003: Reland of "[platform] Change default platform max thread pool size 4 -> 8" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Typo Created 4 years, 9 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
« no previous file with comments | « no previous file | test/cctest/cctest.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project 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 "src/libplatform/default-platform.h" 5 #include "src/libplatform/default-platform.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 9
10 #include "src/base/logging.h" 10 #include "src/base/logging.h"
(...skipping 11 matching lines...) Expand all
22 platform->SetThreadPoolSize(thread_pool_size); 22 platform->SetThreadPoolSize(thread_pool_size);
23 platform->EnsureInitialized(); 23 platform->EnsureInitialized();
24 return platform; 24 return platform;
25 } 25 }
26 26
27 27
28 bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate) { 28 bool PumpMessageLoop(v8::Platform* platform, v8::Isolate* isolate) {
29 return reinterpret_cast<DefaultPlatform*>(platform)->PumpMessageLoop(isolate); 29 return reinterpret_cast<DefaultPlatform*>(platform)->PumpMessageLoop(isolate);
30 } 30 }
31 31
32 32 const int DefaultPlatform::kMaxThreadPoolSize = 8;
33 const int DefaultPlatform::kMaxThreadPoolSize = 4;
34
35 33
36 DefaultPlatform::DefaultPlatform() 34 DefaultPlatform::DefaultPlatform()
37 : initialized_(false), thread_pool_size_(0) {} 35 : initialized_(false), thread_pool_size_(0) {}
38 36
39 37
40 DefaultPlatform::~DefaultPlatform() { 38 DefaultPlatform::~DefaultPlatform() {
41 base::LockGuard<base::Mutex> guard(&lock_); 39 base::LockGuard<base::Mutex> guard(&lock_);
42 queue_.Terminate(); 40 queue_.Terminate();
43 if (initialized_) { 41 if (initialized_) {
44 for (auto i = thread_pool_.begin(); i != thread_pool_.end(); ++i) { 42 for (auto i = thread_pool_.begin(); i != thread_pool_.end(); ++i) {
(...skipping 14 matching lines...) Expand all
59 i->second.pop(); 57 i->second.pop();
60 } 58 }
61 } 59 }
62 } 60 }
63 61
64 62
65 void DefaultPlatform::SetThreadPoolSize(int thread_pool_size) { 63 void DefaultPlatform::SetThreadPoolSize(int thread_pool_size) {
66 base::LockGuard<base::Mutex> guard(&lock_); 64 base::LockGuard<base::Mutex> guard(&lock_);
67 DCHECK(thread_pool_size >= 0); 65 DCHECK(thread_pool_size >= 0);
68 if (thread_pool_size < 1) { 66 if (thread_pool_size < 1) {
69 thread_pool_size = base::SysInfo::NumberOfProcessors(); 67 thread_pool_size = base::SysInfo::NumberOfProcessors() - 1;
70 } 68 }
71 thread_pool_size_ = 69 thread_pool_size_ =
72 std::max(std::min(thread_pool_size, kMaxThreadPoolSize), 1); 70 std::max(std::min(thread_pool_size, kMaxThreadPoolSize), 1);
73 } 71 }
74 72
75 73
76 void DefaultPlatform::EnsureInitialized() { 74 void DefaultPlatform::EnsureInitialized() {
77 base::LockGuard<base::Mutex> guard(&lock_); 75 base::LockGuard<base::Mutex> guard(&lock_);
78 if (initialized_) return; 76 if (initialized_) return;
79 initialized_ = true; 77 initialized_ = true;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return dummy; 193 return dummy;
196 } 194 }
197 195
198 196
199 size_t DefaultPlatform::NumberOfAvailableBackgroundThreads() { 197 size_t DefaultPlatform::NumberOfAvailableBackgroundThreads() {
200 return static_cast<size_t>(thread_pool_size_); 198 return static_cast<size_t>(thread_pool_size_);
201 } 199 }
202 200
203 } // namespace platform 201 } // namespace platform
204 } // namespace v8 202 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/cctest.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698