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

Side by Side Diff: src/isolate.cc

Issue 2392183004: Added zone pool metrics to gc-trace. (Closed)
Patch Set: Added recent master changes Created 4 years, 2 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 | src/zone/accounting-allocator.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/isolate.h" 5 #include "src/isolate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <fstream> // NOLINT(readability/streams) 9 #include <fstream> // NOLINT(readability/streams)
10 #include <sstream> 10 #include <sstream>
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 PrintF("Isolate %p (id %d)" #tag "\n", \ 1923 PrintF("Isolate %p (id %d)" #tag "\n", \
1924 reinterpret_cast<void*>(this), id()); \ 1924 reinterpret_cast<void*>(this), id()); \
1925 } \ 1925 } \
1926 } while (false) 1926 } while (false)
1927 #else 1927 #else
1928 #define TRACE_ISOLATE(tag) 1928 #define TRACE_ISOLATE(tag)
1929 #endif 1929 #endif
1930 1930
1931 class VerboseAccountingAllocator : public AccountingAllocator { 1931 class VerboseAccountingAllocator : public AccountingAllocator {
1932 public: 1932 public:
1933 VerboseAccountingAllocator(Heap* heap, size_t sample_bytes) 1933 VerboseAccountingAllocator(Heap* heap, size_t allocation_sample_bytes,
1934 : heap_(heap), last_memory_usage_(0), sample_bytes_(sample_bytes) {} 1934 size_t pool_sample_bytes)
1935 : heap_(heap),
1936 last_memory_usage_(0),
1937 last_pool_size_(0),
1938 allocation_sample_bytes_(allocation_sample_bytes),
1939 pool_sample_bytes_(pool_sample_bytes) {}
1935 1940
1936 v8::internal::Segment* GetSegment(size_t size) override { 1941 v8::internal::Segment* GetSegment(size_t size) override {
1937 v8::internal::Segment* memory = AccountingAllocator::GetSegment(size); 1942 v8::internal::Segment* memory = AccountingAllocator::GetSegment(size);
1938 if (memory) { 1943 if (memory) {
1939 size_t current = GetCurrentMemoryUsage(); 1944 size_t malloced_current = GetCurrentMemoryUsage();
1940 if (last_memory_usage_.Value() + sample_bytes_ < current) { 1945 size_t pooled_current = GetCurrentPoolSize();
1941 PrintJSON(current); 1946
1942 last_memory_usage_.SetValue(current); 1947 if (last_memory_usage_.Value() + allocation_sample_bytes_ <
1948 malloced_current ||
1949 last_pool_size_.Value() + pool_sample_bytes_ < pooled_current) {
1950 PrintJSON(malloced_current, pooled_current);
1951 last_memory_usage_.SetValue(malloced_current);
1952 last_pool_size_.SetValue(pooled_current);
1943 } 1953 }
1944 } 1954 }
1945 return memory; 1955 return memory;
1946 } 1956 }
1947 1957
1948 void ReturnSegment(v8::internal::Segment* memory) override { 1958 void ReturnSegment(v8::internal::Segment* memory) override {
1949 AccountingAllocator::ReturnSegment(memory); 1959 AccountingAllocator::ReturnSegment(memory);
1950 size_t current = GetCurrentMemoryUsage(); 1960 size_t malloced_current = GetCurrentMemoryUsage();
1951 if (current + sample_bytes_ < last_memory_usage_.Value()) { 1961 size_t pooled_current = GetCurrentPoolSize();
1952 PrintJSON(current); 1962
1953 last_memory_usage_.SetValue(current); 1963 if (malloced_current + allocation_sample_bytes_ <
1964 last_memory_usage_.Value() ||
1965 pooled_current + pool_sample_bytes_ < last_pool_size_.Value()) {
1966 PrintJSON(malloced_current, pooled_current);
1967 last_memory_usage_.SetValue(malloced_current);
1968 last_pool_size_.SetValue(pooled_current);
1954 } 1969 }
1955 } 1970 }
1956 1971
1957 private: 1972 private:
1958 void PrintJSON(size_t sample) { 1973 void PrintJSON(size_t malloced, size_t pooled) {
1959 // Note: Neither isolate, nor heap is locked, so be careful with accesses 1974 // Note: Neither isolate, nor heap is locked, so be careful with accesses
1960 // as the allocator is potentially used on a concurrent thread. 1975 // as the allocator is potentially used on a concurrent thread.
1961 double time = heap_->isolate()->time_millis_since_init(); 1976 double time = heap_->isolate()->time_millis_since_init();
1962 PrintF( 1977 PrintF(
1963 "{" 1978 "{"
1964 "\"type\": \"malloced\", " 1979 "\"type\": \"zone\", "
1965 "\"isolate\": \"%p\", " 1980 "\"isolate\": \"%p\", "
1966 "\"time\": %f, " 1981 "\"time\": %f, "
1967 "\"value\": %zu" 1982 "\"allocated\": %zu,"
1983 "\"pooled\": %zu"
1968 "}\n", 1984 "}\n",
1969 reinterpret_cast<void*>(heap_->isolate()), time, sample); 1985 reinterpret_cast<void*>(heap_->isolate()), time, malloced, pooled);
1970 } 1986 }
1971 1987
1972 Heap* heap_; 1988 Heap* heap_;
1973 base::AtomicNumber<size_t> last_memory_usage_; 1989 base::AtomicNumber<size_t> last_memory_usage_;
1974 size_t sample_bytes_; 1990 base::AtomicNumber<size_t> last_pool_size_;
1991 size_t allocation_sample_bytes_, pool_sample_bytes_;
1975 }; 1992 };
1976 1993
1977 Isolate::Isolate(bool enable_serializer) 1994 Isolate::Isolate(bool enable_serializer)
1978 : embedder_data_(), 1995 : embedder_data_(),
1979 entry_stack_(NULL), 1996 entry_stack_(NULL),
1980 stack_trace_nesting_level_(0), 1997 stack_trace_nesting_level_(0),
1981 incomplete_message_(NULL), 1998 incomplete_message_(NULL),
1982 bootstrapper_(NULL), 1999 bootstrapper_(NULL),
1983 runtime_profiler_(NULL), 2000 runtime_profiler_(NULL),
1984 compilation_cache_(NULL), 2001 compilation_cache_(NULL),
1985 counters_(NULL), 2002 counters_(NULL),
1986 logger_(NULL), 2003 logger_(NULL),
1987 stats_table_(NULL), 2004 stats_table_(NULL),
1988 load_stub_cache_(NULL), 2005 load_stub_cache_(NULL),
1989 store_stub_cache_(NULL), 2006 store_stub_cache_(NULL),
1990 code_aging_helper_(NULL), 2007 code_aging_helper_(NULL),
1991 deoptimizer_data_(NULL), 2008 deoptimizer_data_(NULL),
1992 deoptimizer_lazy_throw_(false), 2009 deoptimizer_lazy_throw_(false),
1993 materialized_object_store_(NULL), 2010 materialized_object_store_(NULL),
1994 capture_stack_trace_for_uncaught_exceptions_(false), 2011 capture_stack_trace_for_uncaught_exceptions_(false),
1995 stack_trace_for_uncaught_exceptions_frame_limit_(0), 2012 stack_trace_for_uncaught_exceptions_frame_limit_(0),
1996 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview), 2013 stack_trace_for_uncaught_exceptions_options_(StackTrace::kOverview),
1997 keyed_lookup_cache_(NULL), 2014 keyed_lookup_cache_(NULL),
1998 context_slot_cache_(NULL), 2015 context_slot_cache_(NULL),
1999 descriptor_lookup_cache_(NULL), 2016 descriptor_lookup_cache_(NULL),
2000 handle_scope_implementer_(NULL), 2017 handle_scope_implementer_(NULL),
2001 unicode_cache_(NULL), 2018 unicode_cache_(NULL),
2002 allocator_(FLAG_trace_gc_object_stats 2019 allocator_(FLAG_trace_gc_object_stats ? new VerboseAccountingAllocator(
2003 ? new VerboseAccountingAllocator(&heap_, 256 * KB) 2020 &heap_, 256 * KB, 128 * KB)
2004 : new AccountingAllocator()), 2021 : new AccountingAllocator()),
2005 inner_pointer_to_code_cache_(NULL), 2022 inner_pointer_to_code_cache_(NULL),
2006 global_handles_(NULL), 2023 global_handles_(NULL),
2007 eternal_handles_(NULL), 2024 eternal_handles_(NULL),
2008 thread_manager_(NULL), 2025 thread_manager_(NULL),
2009 has_installed_extensions_(false), 2026 has_installed_extensions_(false),
2010 regexp_stack_(NULL), 2027 regexp_stack_(NULL),
2011 date_cache_(NULL), 2028 date_cache_(NULL),
2012 call_descriptor_data_(NULL), 2029 call_descriptor_data_(NULL),
2013 // TODO(bmeurer) Initialized lazily because it depends on flags; can 2030 // TODO(bmeurer) Initialized lazily because it depends on flags; can
2014 // be fixed once the default isolate cleanup is done. 2031 // be fixed once the default isolate cleanup is done.
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
3310 // Then check whether this scope intercepts. 3327 // Then check whether this scope intercepts.
3311 if ((flag & intercept_mask_)) { 3328 if ((flag & intercept_mask_)) {
3312 intercepted_flags_ |= flag; 3329 intercepted_flags_ |= flag;
3313 return true; 3330 return true;
3314 } 3331 }
3315 return false; 3332 return false;
3316 } 3333 }
3317 3334
3318 } // namespace internal 3335 } // namespace internal
3319 } // namespace v8 3336 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/zone/accounting-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698