< prev index next >

src/hotspot/share/memory/metaspace.hpp

Print this page
rev 49736 : [mq]: metaspace-additions-to-jcmd

*** 55,64 **** --- 55,65 ---- // +-------------------+ // class ChunkManager; class ClassLoaderData; + class ClassLoaderMetaspaceStatistics; class Metablock; class Metachunk; class MetaspaceTracer; class MetaWord; class Mutex;
*** 92,105 **** ClassType, NonClassType, MetadataTypeCount }; enum MetaspaceType { ! StandardMetaspaceType, ! BootMetaspaceType, ! AnonymousMetaspaceType, ! ReflectionMetaspaceType }; private: // Align up the word size to the allocation word size --- 93,110 ---- ClassType, NonClassType, MetadataTypeCount }; enum MetaspaceType { ! ZeroMetaspaceType = 0, ! //... ! StandardMetaspaceType = ZeroMetaspaceType, ! BootMetaspaceType = StandardMetaspaceType + 1, ! AnonymousMetaspaceType = BootMetaspaceType + 1, ! ReflectionMetaspaceType = AnonymousMetaspaceType + 1, ! //.. ! MetaspaceTypeCount }; private: // Align up the word size to the allocation word size
*** 236,335 **** // special cases such as the boot class loader, reflection // class loader and anonymous class loader. void initialize_first_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype); Metachunk* get_initialization_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype); SpaceManager* _vsm; - SpaceManager* vsm() const { return _vsm; } - SpaceManager* _class_vsm; SpaceManager* class_vsm() const { return _class_vsm; } SpaceManager* get_space_manager(Metaspace::MetadataType mdtype) { assert(mdtype != Metaspace::MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); return mdtype == Metaspace::ClassType ? class_vsm() : vsm(); } MetaWord* expand_and_allocate(size_t size, Metaspace::MetadataType mdtype); size_t class_chunk_size(size_t word_size); public: ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType type); ~ClassLoaderMetaspace(); // Allocate space for metadata of type mdtype. This is space // within a Metachunk and is used by // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS) MetaWord* allocate(size_t word_size, Metaspace::MetadataType mdtype); - size_t used_words_slow(Metaspace::MetadataType mdtype) const; - size_t free_words_slow(Metaspace::MetadataType mdtype) const; - size_t capacity_words_slow(Metaspace::MetadataType mdtype) const; - - size_t used_bytes_slow(Metaspace::MetadataType mdtype) const; - size_t capacity_bytes_slow(Metaspace::MetadataType mdtype) const; - size_t allocated_blocks_bytes() const; size_t allocated_chunks_bytes() const; void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); - void dump(outputStream* const out) const; - void print_on(outputStream* st) const; // Debugging support void verify(); ! }; // ClassLoaderMetaspace class MetaspaceUtils : AllStatic { static size_t free_chunks_total_words(Metaspace::MetadataType mdtype); ! // These methods iterate over the classloader data graph ! // for the given Metaspace type. These are slow. ! static size_t used_bytes_slow(Metaspace::MetadataType mdtype); ! static size_t free_bytes_slow(Metaspace::MetadataType mdtype); ! static size_t capacity_bytes_slow(Metaspace::MetadataType mdtype); ! static size_t capacity_bytes_slow(); ! ! // Running sum of space in all Metachunks that has been ! // allocated to a Metaspace. This is used instead of ! // iterating over all the classloaders. One for each ! // type of Metadata ! static size_t _capacity_words[Metaspace:: MetadataTypeCount]; ! // Running sum of space in all Metachunks that ! // are being used for metadata. One for each ! // type of Metadata. ! static volatile size_t _used_words[Metaspace:: MetadataTypeCount]; ! public: ! // Decrement and increment _allocated_capacity_words ! static void dec_capacity(Metaspace::MetadataType type, size_t words); ! static void inc_capacity(Metaspace::MetadataType type, size_t words); ! ! // Decrement and increment _allocated_used_words ! static void dec_used(Metaspace::MetadataType type, size_t words); ! static void inc_used(Metaspace::MetadataType type, size_t words); ! ! // Total of space allocated to metadata in all Metaspaces. ! // This sums the space used in each Metachunk by ! // iterating over the classloader data graph ! static size_t used_bytes_slow() { ! return used_bytes_slow(Metaspace::ClassType) + ! used_bytes_slow(Metaspace::NonClassType); ! } // Used by MetaspaceCounters static size_t free_chunks_total_words(); static size_t free_chunks_total_bytes(); static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype); - static size_t capacity_words(Metaspace::MetadataType mdtype) { - return _capacity_words[mdtype]; - } static size_t capacity_words() { return capacity_words(Metaspace::NonClassType) + capacity_words(Metaspace::ClassType); } static size_t capacity_bytes(Metaspace::MetadataType mdtype) { --- 241,348 ---- // special cases such as the boot class loader, reflection // class loader and anonymous class loader. void initialize_first_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype); Metachunk* get_initialization_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype); + const Metaspace::MetaspaceType _space_type; + Mutex* const _lock; SpaceManager* _vsm; SpaceManager* _class_vsm; + + SpaceManager* vsm() const { return _vsm; } SpaceManager* class_vsm() const { return _class_vsm; } SpaceManager* get_space_manager(Metaspace::MetadataType mdtype) { assert(mdtype != Metaspace::MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); return mdtype == Metaspace::ClassType ? class_vsm() : vsm(); } + Mutex* lock() const { return _lock; } + MetaWord* expand_and_allocate(size_t size, Metaspace::MetadataType mdtype); size_t class_chunk_size(size_t word_size); + // Adds to the given statistic object. Must be locked with CLD metaspace lock. + void add_to_statistics_locked(ClassLoaderMetaspaceStatistics* out) const; + public: ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType type); ~ClassLoaderMetaspace(); + Metaspace::MetaspaceType space_type() const { return _space_type; } + // Allocate space for metadata of type mdtype. This is space // within a Metachunk and is used by // allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS) MetaWord* allocate(size_t word_size, Metaspace::MetadataType mdtype); size_t allocated_blocks_bytes() const; size_t allocated_chunks_bytes() const; void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); void print_on(outputStream* st) const; // Debugging support void verify(); ! // Adds to the given statistic object. Will lock with CLD metaspace lock. ! void add_to_statistics(ClassLoaderMetaspaceStatistics* out) const; + }; // ClassLoaderMetaspace class MetaspaceUtils : AllStatic { static size_t free_chunks_total_words(Metaspace::MetadataType mdtype); ! // Running counters for statistics concerning in-use chunks. ! enum StatType { ! stat_overhead = 0, ! stat_capacity, ! stat_used, ! stat_free, ! stat_waste, ! stat_num_values ! }; ! volatile size_t _in_use_stats[stat_num_values][Metaspace::MetadataTypeCount]; ! template <StatType e> static void inc_stat_value(Metaspace::MetadataType mdtype, size_t words); ! template <StatType e> static void dec_stat_value(Metaspace::MetadataType mdtype, size_t words); ! template <StatType e> static size_t get_stat_value(Metaspace::MetadataType mdtype) const; ! ! public: ! ! // Collect used metaspace statistics. This involves walking the CLDG. The resulting ! // output will be the accumulated values for all live metaspaces. ! // Note: method does not do any locking. ! static void collect_statistics(ClassLoaderMetaspaceStatistics* out); ! ! // Atomically decrement or increment in-use statistic counters. ! static void dec_capacity(Metaspace::MetadataType mdtype, size_t words) { dec_stat_value<stat_capacity>(mdtype, words); } ! static void inc_capacity(Metaspace::MetadataType mdtype, size_t words) { inc_stat_value<stat_capacity>(mdtype, words); } ! static size_t capacity_words(Metaspace::MetadataType mdtype) const { return get_stat_value<stat_capacity>(mdtype); } ! ! static void dec_used(Metaspace::MetadataType mdtype, size_t words) { dec_stat_value<stat_used>(mdtype, words); } ! static void inc_used(Metaspace::MetadataType mdtype, size_t words) { inc_stat_value<stat_used>(mdtype, words); } ! static size_t used_words(Metaspace::MetadataType mdtype) const { return get_stat_value<stat_used>(mdtype); } ! ! static void dec_overhead(Metaspace::MetadataType mdtype, size_t words) { dec_stat_value<stat_overhead>(mdtype, words); } ! static void inc_overhead(Metaspace::MetadataType mdtype, size_t words) { inc_stat_value<stat_overhead>(mdtype, words); } ! static size_t overhead_words(Metaspace::MetadataType mdtype) const { return get_stat_value<stat_overhead>(mdtype); } ! ! static void dec_free(Metaspace::MetadataType mdtype, size_t words) { dec_stat_value<stat_free>(mdtype, words); } ! static void inc_free(Metaspace::MetadataType mdtype, size_t words) { inc_stat_value<stat_free>(mdtype, words); } ! static size_t free_words(Metaspace::MetadataType mdtype) const { return get_stat_value<stat_free>(mdtype); } ! ! static void dec_waste(Metaspace::MetadataType mdtype, size_t words) { dec_stat_value<stat_waste>(mdtype, words); } ! static void inc_waste(Metaspace::MetadataType mdtype, size_t words) { inc_stat_value<stat_waste>(mdtype, words); } ! static size_t waste_words(Metaspace::MetadataType mdtype) const { return get_stat_value<stat_waste>(mdtype); } // Used by MetaspaceCounters static size_t free_chunks_total_words(); static size_t free_chunks_total_bytes(); static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype); static size_t capacity_words() { return capacity_words(Metaspace::NonClassType) + capacity_words(Metaspace::ClassType); } static size_t capacity_bytes(Metaspace::MetadataType mdtype) {
*** 337,349 **** } static size_t capacity_bytes() { return capacity_words() * BytesPerWord; } - static size_t used_words(Metaspace::MetadataType mdtype) { - return _used_words[mdtype]; - } static size_t used_words() { return used_words(Metaspace::NonClassType) + used_words(Metaspace::ClassType); } static size_t used_bytes(Metaspace::MetadataType mdtype) { --- 350,359 ----
*** 371,402 **** static size_t min_chunk_size_words(); static size_t min_chunk_size_bytes() { return min_chunk_size_words() * BytesPerWord; } ! static void print_metadata_for_nmt(outputStream* out, size_t scale = K); static bool has_chunk_free_list(Metaspace::MetadataType mdtype); static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype); // Print change in used metadata. static void print_metaspace_change(size_t prev_metadata_used); static void print_on(outputStream * out); - static void print_on(outputStream * out, Metaspace::MetadataType mdtype); - - static void print_class_waste(outputStream* out); - static void print_waste(outputStream* out); // Prints an ASCII representation of the given space. static void print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype); static void dump(outputStream* out); static void verify_free_chunks(); ! // Checks that the values returned by allocated_capacity_bytes() and ! // capacity_bytes_slow() are the same. ! static void verify_capacity(); ! static void verify_used(); static void verify_metrics(); }; // Metaspace are deallocated when their class loader are GC'ed. // This class implements a policy for inducing GC's to recover --- 381,427 ---- static size_t min_chunk_size_words(); static size_t min_chunk_size_bytes() { return min_chunk_size_words() * BytesPerWord; } ! // Flags for print_report(). ! enum ReportFlag { ! // Breaks report down by class loader. ! rf_show_loaders = (1 << 0), ! // Breaks report down by chunk type (small, medium, ...). ! rf_break_down_by_chunktype = (1 << 1), ! // Breaks report down by space type (anonymous, reflection, ...). ! rf_break_down_by_spacetype = (1 << 2), ! // Print details about the underlying virtual spaces. ! rf_show_vslist = (1 << 3), ! // Print metaspace map. ! rf_show_vsmap = (1 << 4), ! // Print details about the free chunk list. ! rf_show_chunk_freelist = (1 << 5), ! }; ! ! // Prints a report about the current metaspace state. Form of report is defined ! // by flags (see ReportFlags). In its most basic form (flags == 0), a short ! // overview is printed. ! // Scale is one of 1, K, M, G - in which case numbers are printed as bytes, ! // KB, MB, GB, respectively - or 0, in which case the most suitable scale ! // is chosen dynamically. ! static void print_report(outputStream* out, size_t scale = 0, int flags = 0); static bool has_chunk_free_list(Metaspace::MetadataType mdtype); static MetaspaceChunkFreeListSummary chunk_free_list_summary(Metaspace::MetadataType mdtype); // Print change in used metadata. static void print_metaspace_change(size_t prev_metadata_used); static void print_on(outputStream * out); // Prints an ASCII representation of the given space. static void print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype); static void dump(outputStream* out); static void verify_free_chunks(); ! // Check internal counters (capacity, used). static void verify_metrics(); }; // Metaspace are deallocated when their class loader are GC'ed. // This class implements a policy for inducing GC's to recover
< prev index next >