From 0be514a68c9c4e42e428619b82de48fffec6225f Mon Sep 17 00:00:00 2001 From: "iposva@google.com" Date: Wed, 16 Oct 2013 23:15:11 +0000 Subject: [PATCH] - Add more data collection to the scavenger. - Fix runtime/PRESUBMIT.py script. R=asiva@google.com Review URL: https://codereview.chromium.org//27604002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28759 260f80e4-7a28-3924-810f-c04153c831b5 --- runtime/PRESUBMIT.py | 46 ++++++++++++++++------------------------- runtime/vm/scavenger.cc | 20 ++++++++++++++---- runtime/vm/scavenger.h | 4 +++- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/runtime/PRESUBMIT.py b/runtime/PRESUBMIT.py index ccaa35d3aa5..ca55214e37d 100644 --- a/runtime/PRESUBMIT.py +++ b/runtime/PRESUBMIT.py @@ -14,6 +14,14 @@ class PathHackException(Exception): def __str__(self): return repr(self.error_msg) +def AddSvnPathIfNeeded(runtime_path): + # Add the .svn into the runtime directory if needed for git or svn 1.7. + fake_svn_path = os.path.join(runtime_path, '.svn') + if os.path.exists(fake_svn_path): + return None + open(fake_svn_path, 'w').close() + return lambda: os.remove(fake_svn_path) + def TrySvnPathHack(parent_path): orig_path = os.path.join(parent_path, '.svn') @@ -31,27 +39,6 @@ def TrySvnPathHack(parent_path): return lambda: os.rename(renamed_path, orig_path) -def TryGitPathHack(filename, parent_path): - def CommonSubdirectory(parent, child): - while len(child) > len(parent): - child, tail = os.path.split(child) - if child == parent: - return os.path.join(parent, tail) - if os.path.exists(os.path.join(parent_path, '.git')): - runtime_path = CommonSubdirectory(parent_path, filename) - if runtime_path is not None: - fake_svn_path = os.path.join(runtime_path, '.svn') - if os.path.exists(fake_svn_path): - error_msg = '".svn" exists in presubmit parent subdirectory(' - error_msg += fake_svn_path - error_msg += '). Consider removing it manually.' - raise PathHackException(error_msg) - # Deposit a file named ".svn" in the runtime directory to fool - # cpplint into thinking it is the source root. - open(fake_svn_path, 'w').close() - return lambda: os.remove(fake_svn_path) - - def RunLint(input_api, output_api): result = [] cpplint._cpplint_state.ResetErrorCounts() @@ -60,19 +47,22 @@ def RunLint(input_api, output_api): for svn_file in input_api.AffectedTextFiles(): filename = svn_file.AbsoluteLocalPath() if filename.endswith('.cc') or filename.endswith('.h'): - cleanup = None - parent_path = os.path.dirname(input_api.PresubmitLocalPath()) + cleanup_parent = None + cleanup_runtime = None try: + runtime_path = input_api.PresubmitLocalPath() + parent_path = os.path.dirname(runtime_path) if filename.endswith('.h'): - cleanup = TrySvnPathHack(parent_path) - if cleanup is None: - cleanup = TryGitPathHack(filename, parent_path) + cleanup_runtime = AddSvnPathIfNeeded(runtime_path) + cleanup_parent = TrySvnPathHack(parent_path) except PathHackException, exception: return [output_api.PresubmitError(str(exception))] # Run cpplint on the file. cpplint.ProcessFile(filename, 1) - if cleanup is not None: - cleanup() + if cleanup_parent is not None: + cleanup_parent() + if cleanup_runtime is not None: + cleanup_runtime() # memcpy does not handle overlapping memory regions. Even though this # is well documented it seems to be used in error quite often. To avoid # problems we disallow the direct use of memcpy. The exceptions are in diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc index efcdf74c0f4..d6f108d7f14 100644 --- a/runtime/vm/scavenger.cc +++ b/runtime/vm/scavenger.cc @@ -73,6 +73,8 @@ class ScavengerVisitor : public ObjectPointerVisitor { scavenger_(scavenger), heap_(scavenger->heap_), vm_heap_(Dart::vm_isolate()->heap()), + visited_count_(0), + handled_count_(0), delayed_weak_stack_(), growth_policy_(PageSpace::kControlGrowth), bytes_promoted_(0), @@ -113,6 +115,8 @@ class ScavengerVisitor : public ObjectPointerVisitor { } } + intptr_t visited_count() const { return visited_count_; } + intptr_t handled_count() const { return handled_count_; } intptr_t bytes_promoted() const { return bytes_promoted_; } private: @@ -137,6 +141,7 @@ class ScavengerVisitor : public ObjectPointerVisitor { BoolScope bs(&in_scavenge_pointer_, true); #endif + visited_count_++; RawObject* raw_obj = *p; // Fast exit if the raw object is a Smi or an old object. @@ -153,6 +158,7 @@ class ScavengerVisitor : public ObjectPointerVisitor { return; } + handled_count_++; // Read the header word of the object and determine if the object has // already been copied. uword header = *reinterpret_cast(raw_addr); @@ -237,6 +243,8 @@ class ScavengerVisitor : public ObjectPointerVisitor { Scavenger* scavenger_; Heap* heap_; Heap* vm_heap_; + intptr_t visited_count_; + intptr_t handled_count_; typedef std::multimap DelaySet; DelaySet delay_set_; GrowableArray delayed_weak_stack_; @@ -379,16 +387,16 @@ void Scavenger::Epilogue(Isolate* isolate, bool invoke_api_callbacks) { void Scavenger::IterateStoreBuffers(Isolate* isolate, ScavengerVisitor* visitor) { StoreBuffer* buffer = isolate->store_buffer(); - heap_->RecordData(kStoreBufferBlockEntries, buffer->Count()); + heap_->RecordData(kStoreBufferEntries, buffer->Count()); // Iterating through the store buffers. // Grab the deduplication sets out of the store buffer. StoreBufferBlock* pending = isolate->store_buffer()->Blocks(); - intptr_t entries = 0; + intptr_t visited_count_before = visitor->visited_count(); + intptr_t handled_count_before = visitor->handled_count(); while (pending != NULL) { StoreBufferBlock* next = pending->next(); intptr_t count = pending->Count(); - entries += count; for (intptr_t i = 0; i < count; i++) { RawObject* raw_object = pending->At(i); ASSERT(raw_object->IsRemembered()); @@ -399,7 +407,10 @@ void Scavenger::IterateStoreBuffers(Isolate* isolate, delete pending; pending = next; } - heap_->RecordData(kStoreBufferEntries, entries); + heap_->RecordData(kStoreBufferVisited, + visitor->visited_count() - visited_count_before); + heap_->RecordData(kStoreBufferPointers, + visitor->handled_count() - handled_count_before); // Done iterating through old objects remembered in the store buffers. visitor->VisitingOldObject(NULL); } @@ -428,6 +439,7 @@ void Scavenger::IterateRoots(Isolate* isolate, IterateStoreBuffers(isolate, visitor); IterateObjectIdTable(isolate, visitor); int64_t end = OS::GetCurrentTimeMicros(); + heap_->RecordData(kToKBAfterStoreBuffer, (in_use() + (KB >> 1)) >> KBLog2); heap_->RecordTime(kVisitIsolateRoots, middle - start); heap_->RecordTime(kIterateStoreBuffers, end - middle); } diff --git a/runtime/vm/scavenger.h b/runtime/vm/scavenger.h index 8dd60abe8b7..d5263abbd0f 100644 --- a/runtime/vm/scavenger.h +++ b/runtime/vm/scavenger.h @@ -97,7 +97,9 @@ class Scavenger { kIterateWeaks = 3, // Data kStoreBufferEntries = 0, - kStoreBufferBlockEntries = 1 + kStoreBufferVisited = 1, + kStoreBufferPointers = 2, + kToKBAfterStoreBuffer = 3 }; uword FirstObjectStart() const { return to_->start() | object_alignment_; }