< prev index next >

src/hotspot/share/memory/metaspace.hpp

Print this page
rev 57380 : [mq]: metaspace-improvement

*** 108,133 **** MetaspaceTypeCount }; private: - // Align up the word size to the allocation word size - static size_t align_word_size_up(size_t); - // Aligned size of the metaspace. static size_t _compressed_class_space_size; ! static size_t compressed_class_space_size() { ! return _compressed_class_space_size; ! } ! ! static void set_compressed_class_space_size(size_t size) { ! _compressed_class_space_size = size; ! } ! ! static size_t _first_chunk_word_size; ! static size_t _first_class_chunk_word_size; static size_t _commit_alignment; static size_t _reserve_alignment; DEBUG_ONLY(static bool _frozen;) --- 108,122 ---- MetaspaceTypeCount }; private: // Aligned size of the metaspace. static size_t _compressed_class_space_size; ! static size_t compressed_class_space_size() { return _compressed_class_space_size; } ! static void set_compressed_class_space_size(size_t size) { _compressed_class_space_size = size; } static size_t _commit_alignment; static size_t _reserve_alignment; DEBUG_ONLY(static bool _frozen;)
*** 140,157 **** static const MetaspaceTracer* _tracer; static bool _initialized; - public: static metaspace::VirtualSpaceList* space_list() { return _space_list; } static metaspace::VirtualSpaceList* class_space_list() { return _class_space_list; } static metaspace::VirtualSpaceList* get_space_list(MetadataType mdtype) { assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); return mdtype == ClassType ? class_space_list() : space_list(); } static metaspace::ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; } static metaspace::ChunkManager* chunk_manager_class() { return _chunk_manager_class; } static metaspace::ChunkManager* get_chunk_manager(MetadataType mdtype) { assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata(); --- 129,149 ---- static const MetaspaceTracer* _tracer; static bool _initialized; static metaspace::VirtualSpaceList* space_list() { return _space_list; } static metaspace::VirtualSpaceList* class_space_list() { return _class_space_list; } + static metaspace::VirtualSpaceList* get_space_list(MetadataType mdtype) { assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); return mdtype == ClassType ? class_space_list() : space_list(); } + public: + + static metaspace::ChunkManager* chunk_manager_metadata() { return _chunk_manager_metadata; } static metaspace::ChunkManager* chunk_manager_class() { return _chunk_manager_class; } static metaspace::ChunkManager* get_chunk_manager(MetadataType mdtype) { assert(mdtype != MetadataTypeCount, "MetadaTypeCount can't be used as mdtype"); return mdtype == ClassType ? chunk_manager_class() : chunk_manager_metadata();
*** 191,217 **** static void global_initialize(); static void post_initialize(); static void verify_global_initialization(); ! static size_t first_chunk_word_size() { return _first_chunk_word_size; } ! static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } ! static size_t reserve_alignment() { return _reserve_alignment; } static size_t reserve_alignment_words() { return _reserve_alignment / BytesPerWord; } static size_t commit_alignment() { return _commit_alignment; } ! static size_t commit_alignment_words() { return _commit_alignment / BytesPerWord; } static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, TRAPS); static bool contains(const void* ptr); static bool contains_non_shared(const void* ptr); // Free empty virtualspaces static void purge(MetadataType mdtype); - static void purge(); static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS); static const char* metadata_type_name(Metaspace::MetadataType mdtype); --- 183,208 ---- static void global_initialize(); static void post_initialize(); static void verify_global_initialization(); ! // The alignment at which Metaspace mappings are reserved. static size_t reserve_alignment() { return _reserve_alignment; } static size_t reserve_alignment_words() { return _reserve_alignment / BytesPerWord; } + + // The granularity at which Metaspace is committed and uncommitted. static size_t commit_alignment() { return _commit_alignment; } ! static size_t commit_words() { return _commit_alignment / BytesPerWord; } static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, TRAPS); static bool contains(const void* ptr); static bool contains_non_shared(const void* ptr); // Free empty virtualspaces static void purge(MetadataType mdtype); static void report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetaspaceObj::Type type, MetadataType mdtype, TRAPS); static const char* metadata_type_name(Metaspace::MetadataType mdtype);
*** 229,305 **** static bool initialized() { return _initialized; } }; - // Manages the metaspace portion belonging to a class loader - class ClassLoaderMetaspace : public CHeapObj<mtClass> { - friend class CollectedHeap; // For expand_and_allocate() - friend class ZCollectedHeap; // For expand_and_allocate() - friend class ShenandoahHeap; // For expand_and_allocate() - friend class Metaspace; - friend class MetaspaceUtils; - friend class metaspace::PrintCLDMetaspaceInfoClosure; - friend class VM_CollectForMetadataAllocation; // For expand_and_allocate() - - private: - - void initialize(Mutex* lock, Metaspace::MetaspaceType type); - - // Initialize the first chunk for a Metaspace. Used for - // 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); - metaspace::Metachunk* get_initialization_chunk(Metaspace::MetaspaceType type, Metaspace::MetadataType mdtype); - - const Metaspace::MetaspaceType _space_type; - Mutex* const _lock; - metaspace::SpaceManager* _vsm; - metaspace::SpaceManager* _class_vsm; - - metaspace::SpaceManager* vsm() const { return _vsm; } - metaspace::SpaceManager* class_vsm() const { return _class_vsm; } - metaspace::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(metaspace::ClassLoaderMetaspaceStatistics* out) const; - - Metaspace::MetaspaceType space_type() const { return _space_type; } - - 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 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(metaspace::ClassLoaderMetaspaceStatistics* out) const; - - }; // ClassLoaderMetaspace - class MetaspaceUtils : AllStatic { // Spacemanager updates running counters. friend class metaspace::SpaceManager; --- 220,229 ----
*** 329,340 **** static size_t used_words(Metaspace::MetadataType mdtype) { return _used_words[mdtype]; } static size_t overhead_words(Metaspace::MetadataType mdtype) { return _overhead_words[mdtype]; } static size_t free_chunks_total_words(Metaspace::MetadataType mdtype); - // Helper for print_xx_report. - static void print_vs(outputStream* out, size_t scale); public: // Collect used metaspace statistics. This involves walking the CLDG. The resulting // output will be the accumulated values for all live metaspaces. --- 253,262 ----
*** 384,419 **** committed_bytes(Metaspace::NonClassType); } static size_t min_chunk_size_words(); - // Flags for print_report(). - enum ReportFlag { - // Show usage 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), - // If show_loaders: show loaded classes for each loader. - rf_show_classes = (1 << 5) - }; - - // This will print out a basic metaspace usage report but - // unlike print_report() is guaranteed not to lock or to walk the CLDG. - static void print_basic_report(outputStream* st, size_t scale); - - // Prints a report about the current metaspace state. - // Optional parts can be enabled via flags. - // Function will walk the CLDG and will lock the expand lock; if that is not - // convenient, use print_basic_report() instead. - 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); // Log change in used metadata. static void print_metaspace_change(const metaspace::MetaspaceSizesSnapshot& pre_meta_values); --- 306,315 ----
*** 426,483 **** 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 - // Metaspaces. - - class MetaspaceGC : AllStatic { - - // The current high-water-mark for inducing a GC. - // When committed memory of all metaspaces reaches this value, - // a GC is induced and the value is increased. Size is in bytes. - static volatile size_t _capacity_until_GC; - - // For a CMS collection, signal that a concurrent collection should - // be started. - static bool _should_concurrent_collect; - - static uint _shrink_factor; - - static size_t shrink_factor() { return _shrink_factor; } - void set_shrink_factor(uint v) { _shrink_factor = v; } - - public: - - static void initialize(); - static void post_initialize(); - - static size_t capacity_until_GC(); - static bool inc_capacity_until_GC(size_t v, - size_t* new_cap_until_GC = NULL, - size_t* old_cap_until_GC = NULL, - bool* can_retry = NULL); - static size_t dec_capacity_until_GC(size_t v); - - static bool should_concurrent_collect() { return _should_concurrent_collect; } - static void set_should_concurrent_collect(bool v) { - _should_concurrent_collect = v; - } - - // The amount to increase the high-water-mark (_capacity_until_GC) - static size_t delta_capacity_until_GC(size_t bytes); - - // Tells if we have can expand metaspace without hitting set limits. - static bool can_expand(size_t words, bool is_class); - - // Returns amount that we can expand without hitting a GC, - // measured in words. - static size_t allowed_expansion(); - - // Calculate the new high-water mark at which to induce - // a GC. - static void compute_new_size(); - }; - #endif // SHARE_MEMORY_METASPACE_HPP --- 322,327 ----
< prev index next >