Commit 5c9e5814 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Add worklist tracing in concurrent marker.

BUG=chromium:694255

Change-Id: I49618ccb7e7c87dfd8ba8b2359c4384198fd1c30
Reviewed-on: https://chromium-review.googlesource.com/568306
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46597}
parent 1f9734d5
...@@ -293,7 +293,7 @@ ConcurrentMarking::ConcurrentMarking(Heap* heap, MarkingWorklist* shared, ...@@ -293,7 +293,7 @@ ConcurrentMarking::ConcurrentMarking(Heap* heap, MarkingWorklist* shared,
void ConcurrentMarking::Run(int task_id, base::Mutex* lock) { void ConcurrentMarking::Run(int task_id, base::Mutex* lock) {
ConcurrentMarkingVisitor visitor(shared_, bailout_, task_id); ConcurrentMarkingVisitor visitor(shared_, bailout_, task_id);
double time_ms = heap_->MonotonicallyIncreasingTimeInMs(); double time_ms;
size_t bytes_marked = 0; size_t bytes_marked = 0;
{ {
TimedScope scope(&time_ms); TimedScope scope(&time_ms);
...@@ -327,6 +327,9 @@ void ConcurrentMarking::Run(int task_id, base::Mutex* lock) { ...@@ -327,6 +327,9 @@ void ConcurrentMarking::Run(int task_id, base::Mutex* lock) {
void ConcurrentMarking::Start() { void ConcurrentMarking::Start() {
if (!FLAG_concurrent_marking) return; if (!FLAG_concurrent_marking) return;
if (FLAG_trace_concurrent_marking) {
heap_->isolate()->PrintWithTimestamp("Starting concurrent marking\n");
}
pending_task_count_ = kTasks; pending_task_count_ = kTasks;
for (int i = 0; i < kTasks; i++) { for (int i = 0; i < kTasks; i++) {
int task_id = i + 1; int task_id = i + 1;
......
...@@ -1210,6 +1210,10 @@ size_t IncrementalMarking::Step(size_t bytes_to_process, ...@@ -1210,6 +1210,10 @@ size_t IncrementalMarking::Step(size_t bytes_to_process,
size_t bytes_processed = 0; size_t bytes_processed = 0;
if (state_ == MARKING) { if (state_ == MARKING) {
if (FLAG_trace_incremental_marking && FLAG_trace_concurrent_marking &&
FLAG_trace_gc_verbose) {
marking_worklist()->Print();
}
bytes_processed = ProcessMarkingWorklist(bytes_to_process); bytes_processed = ProcessMarkingWorklist(bytes_to_process);
if (step_origin == StepOrigin::kTask) { if (step_origin == StepOrigin::kTask) {
bytes_marked_ahead_of_schedule_ += bytes_processed; bytes_marked_ahead_of_schedule_ += bytes_processed;
......
...@@ -455,7 +455,36 @@ class MarkCompactCollector final : public MarkCompactCollectorBase { ...@@ -455,7 +455,36 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
void SetOverflowed() {} void SetOverflowed() {}
bool overflowed() const { return false; } bool overflowed() const { return false; }
void Print() {
PrintWorklist("shared", &shared_);
PrintWorklist("bailout", &bailout_);
}
private: private:
// Prints the stats about the global pool of the worklist.
void PrintWorklist(const char* worklist_name,
ConcurrentMarkingWorklist* worklist) {
std::map<InstanceType, int> count;
int total_count = 0;
worklist->IterateGlobalPool([&count, &total_count](HeapObject* obj) {
++total_count;
count[obj->map()->instance_type()]++;
});
std::vector<std::pair<int, InstanceType>> rank;
for (auto i : count) {
rank.push_back(std::make_pair(i.second, i.first));
}
std::map<InstanceType, std::string> instance_type_name;
#define INSTANCE_TYPE_NAME(name) instance_type_name[name] = #name;
INSTANCE_TYPE_LIST(INSTANCE_TYPE_NAME)
#undef INSTANCE_TYPE_NAME
std::sort(rank.begin(), rank.end(),
std::greater<std::pair<int, InstanceType>>());
PrintF("Worklist %s: %d\n", worklist_name, total_count);
for (auto i : rank) {
PrintF(" [%s]: %d\n", instance_type_name[i.second].c_str(), i.first);
}
}
ConcurrentMarkingWorklist shared_; ConcurrentMarkingWorklist shared_;
ConcurrentMarkingWorklist bailout_; ConcurrentMarkingWorklist bailout_;
}; };
......
...@@ -169,6 +169,14 @@ class Worklist { ...@@ -169,6 +169,14 @@ class Worklist {
} }
} }
template <typename Callback>
void IterateGlobalPool(Callback callback) {
base::LockGuard<base::Mutex> guard(&lock_);
for (size_t i = 0; i < global_pool_.size(); i++) {
global_pool_[i]->Iterate(callback);
}
}
void FlushToGlobal(int task_id) { void FlushToGlobal(int task_id) {
PublishPushSegmentToGlobal(task_id); PublishPushSegmentToGlobal(task_id);
PublishPopSegmentToGlobal(task_id); PublishPopSegmentToGlobal(task_id);
...@@ -220,6 +228,13 @@ class Worklist { ...@@ -220,6 +228,13 @@ class Worklist {
index_ = new_index; index_ = new_index;
} }
template <typename Callback>
void Iterate(Callback callback) {
for (size_t i = 0; i < index_; i++) {
callback(entries_[i]);
}
}
private: private:
size_t index_; size_t index_;
EntryType entries_[kCapacity]; EntryType entries_[kCapacity];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment