< prev index next >

src/hotspot/share/code/codeHeapState.cpp

Print this page

        

*** 21,30 **** --- 21,36 ---- * or visit www.oracle.com if you need additional information or have any * questions. * */ + // With this declaration macro, it is possible to switch between + // - direct output into an argument-passed outputStream and + // - buffered output into a bufferedStream with subsequent flush + // of the filled buffer to the outputStream. + #define USE_BUFFEREDSTREAM + #include "precompiled.hpp" #include "code/codeHeapState.hpp" #include "compiler/compileBroker.hpp" #include "runtime/sweeper.hpp"
*** 71,122 **** // detected. // // The command line option produces output identical to the jcmd function // jcmd <pid> Compiler.CodeHeap_Analytics all 4096 // --------------------------------------------------------------------------------- - - // With this declaration macro, it is possible to switch between - // - direct output into an argument-passed outputStream and - // - buffered output into a bufferedStream with subsequent flush - // of the filled buffer to the outputStream. - #define USE_STRINGSTREAM - #define HEX32_FORMAT "0x%x" // just a helper format string used below multiple times // // Writing to a bufferedStream buffer first has a significant advantage: ! // It uses noticeably less cpu cycles and reduces (when wirting to a ! // network file) the required bandwidth by at least a factor of ten. // That clearly makes up for the increased code complexity. ! #if defined(USE_STRINGSTREAM) ! #define STRINGSTREAM_DECL(_anyst, _outst) \ /* _anyst name of the stream as used in the code */ \ /* _outst stream where final output will go to */ \ ! ResourceMark rm; \ ! bufferedStream _sstobj = bufferedStream(4*K); \ bufferedStream* _sstbuf = &_sstobj; \ outputStream* _outbuf = _outst; \ bufferedStream* _anyst = &_sstobj; /* any stream. Use this to just print - no buffer flush. */ ! #define STRINGSTREAM_FLUSH(termString) \ ! _sstbuf->print("%s", termString); \ _outbuf->print("%s", _sstbuf->as_string()); \ ! _sstbuf->reset(); ! #define STRINGSTREAM_FLUSH_LOCKED(termString) \ ! { ttyLocker ttyl;/* keep this output block together */\ ! STRINGSTREAM_FLUSH(termString) \ } #else ! #define STRINGSTREAM_DECL(_anyst, _outst) \ outputStream* _outbuf = _outst; \ outputStream* _anyst = _outst; /* any stream. Use this to just print - no buffer flush. */ ! #define STRINGSTREAM_FLUSH(termString) \ ! _outbuf->print("%s", termString); ! #define STRINGSTREAM_FLUSH_LOCKED(termString) \ ! _outbuf->print("%s", termString); #endif const char blobTypeChar[] = {' ', 'C', 'N', 'I', 'X', 'Z', 'U', 'R', '?', 'D', 'T', 'E', 'S', 'A', 'M', 'B', 'L' }; const char* blobTypeName[] = {"noType" , "nMethod (under construction)" , "nMethod (active)" --- 77,197 ---- // detected. // // The command line option produces output identical to the jcmd function // jcmd <pid> Compiler.CodeHeap_Analytics all 4096 // --------------------------------------------------------------------------------- // + // There are instances when composing an output line or a small set of + // output lines out of many tty->print() calls creates significant overhead. // Writing to a bufferedStream buffer first has a significant advantage: ! // It uses noticeably less cpu cycles and reduces (when writing to a ! // network file) the required bandwidth by at least a factor of ten. Observed on MacOS. // That clearly makes up for the increased code complexity. ! // ! // Conversion of existing code is easy and straightforward, if the code already ! // uses a parameterized output destination, e.g. "outputStream st". ! // - rename the formal parameter to any other name, e.g. out_st. ! // - at a suitable place in your code, insert ! // BUFFEREDSTEAM_DECL(buf_st, out_st) ! // This will provide all the declarations necessary. After that, all ! // buf_st->print() (and the like) calls will be directed to a bufferedStream object. ! // Once a block of output (a line or a small set of lines) is composed, insert ! // BUFFEREDSTREAM_FLUSH(termstring) ! // to flush the bufferedStream to the final destination out_st. termstring is just ! // an arbitrary string (e.g. "\n") which is appended to the bufferedStream before ! // being written to out_st. Be aware that the last character written MUST be a '\n'. ! // Otherwise, buf_st->position() does not correspond to out_st->position() any longer. ! // BUFFEREDSTREAM_FLUSH_LOCKED(termstring) ! // does the same thing, protected by the ttyLocker lock. ! // BUFFEREDSTREAM_FLUSH_IF(termstring, remSize) ! // does a flush only if the remaining buffer space is less than remSize. ! // ! // To activate, #define USE_BUFFERED_STREAM before including this header. ! // If not activated, output will directly go to the originally used outputStream ! // with no additional overhead. ! // ! #if defined(USE_BUFFEREDSTREAM) ! #define BUFFEREDSTREAM_DECL_SIZE(_anyst, _outst, _capa) \ ! ResourceMark _rm; \ /* _anyst name of the stream as used in the code */ \ /* _outst stream where final output will go to */ \ ! /* _capa allocated capacity of stream buffer */ \ ! size_t _nflush = 0; \ ! size_t _nforcedflush = 0; \ ! size_t _nsavedflush = 0; \ ! size_t _nlockedflush = 0; \ ! size_t _nflush_bytes = 0; \ ! size_t _capacity = _capa; \ ! bufferedStream _sstobj = bufferedStream(_capa); \ bufferedStream* _sstbuf = &_sstobj; \ outputStream* _outbuf = _outst; \ bufferedStream* _anyst = &_sstobj; /* any stream. Use this to just print - no buffer flush. */ ! #define BUFFEREDSTREAM_DECL(_anyst, _outst) \ ! BUFFEREDSTREAM_DECL_SIZE(_anyst, _outst, 4*K); ! ! #define BUFFEREDSTREAM_FLUSH(_termString) \ ! if ((_termString != NULL) && (strlen(_termString) > 0)) { \ ! _sstbuf->print("%s", _termString); \ ! } \ ! if (_sstbuf != _outbuf) { \ ! if (_sstbuf->size() != 0) { \ ! _nforcedflush++; _nflush_bytes += _sstbuf->size(); \ _outbuf->print("%s", _sstbuf->as_string()); \ ! _sstbuf->reset(); \ ! } \ ! } ! ! #define BUFFEREDSTREAM_FLUSH_IF(_termString, _remSize) \ ! if (_sstbuf != _outbuf) { \ ! if ((_capacity - _sstbuf->size()) < (size_t)_remSize) { \ ! _nflush++; _nforcedflush--; \ ! BUFFEREDSTREAM_FLUSH(_termString) \ ! } else { \ ! _nsavedflush++; \ ! } \ ! } ! #define BUFFEREDSTREAM_FLUSH_LOCKED(_termString) \ ! { ttyLocker ttyl;/* keep this output block together */ \ ! _nlockedflush++; \ ! BUFFEREDSTREAM_FLUSH(_termString) \ } + + // #define BUFFEREDSTREAM_FLUSH_STAT() \ + // if (_sstbuf != _outbuf) { \ + // _outbuf->print_cr("%ld flushes (buffer full), %ld forced, %ld locked, %ld bytes total, %ld flushes saved", _nflush, _nforcedflush, _nlockedflush, _nflush_bytes, _nsavedflush); \ + // } + + #define BUFFEREDSTREAM_FLUSH_STAT() #else ! #define BUFFEREDSTREAM_DECL_SIZE(_anyst, _outst, _capa) \ ! size_t _capacity = _capa; \ outputStream* _outbuf = _outst; \ outputStream* _anyst = _outst; /* any stream. Use this to just print - no buffer flush. */ ! #define BUFFEREDSTREAM_DECL(_anyst, _outst) \ ! BUFFEREDSTREAM_DECL_SIZE(_anyst, _outst, 4*K) ! ! #define BUFFEREDSTREAM_FLUSH_IF(_termString, _remSize) \ ! if ((_termString != NULL) && (strlen(_termString) > 0)) { \ ! _outbuf->print("%s", _termString); \ ! } ! ! #define BUFFEREDSTREAM_FLUSH(_termString) \ ! if ((_termString != NULL) && (strlen(_termString) > 0)) { \ ! _outbuf->print("%s", _termString); \ ! } ! #define BUFFEREDSTREAM_FLUSH_LOCKED(_termString) \ ! if ((_termString != NULL) && (strlen(_termString) > 0)) { \ ! _outbuf->print("%s", _termString); \ ! } ! ! #define BUFFEREDSTREAM_FLUSH_STAT() #endif + #define HEX32_FORMAT "0x%x" // just a helper format string used below multiple times const char blobTypeChar[] = {' ', 'C', 'N', 'I', 'X', 'Z', 'U', 'R', '?', 'D', 'T', 'E', 'S', 'A', 'M', 'B', 'L' }; const char* blobTypeName[] = {"noType" , "nMethod (under construction)" , "nMethod (active)"
*** 459,469 **** const int min_granules = 256; const int max_granules = 512*K; // limits analyzable CodeHeap (with segment_granules) to 32M..128M // results in StatArray size of 24M (= max_granules * 48 Bytes per element) // For a 1GB CodeHeap, the granule size must be at least 2kB to not violate the max_granles limit. const char* heapName = get_heapName(heap); ! STRINGSTREAM_DECL(ast, out) if (!initialization_complete) { memset(CodeHeapStatArray, 0, sizeof(CodeHeapStatArray)); initialization_complete = true; --- 534,544 ---- const int min_granules = 256; const int max_granules = 512*K; // limits analyzable CodeHeap (with segment_granules) to 32M..128M // results in StatArray size of 24M (= max_granules * 48 Bytes per element) // For a 1GB CodeHeap, the granule size must be at least 2kB to not violate the max_granles limit. const char* heapName = get_heapName(heap); ! BUFFEREDSTREAM_DECL(ast, out) if (!initialization_complete) { memset(CodeHeapStatArray, 0, sizeof(CodeHeapStatArray)); initialization_complete = true;
*** 475,485 **** " \n" " This function is designed and provided for support engineers\n" " to help them understand and solve issues in customer systems.\n" " It is not intended for use and interpretation by other persons.\n" " \n"); ! STRINGSTREAM_FLUSH("") } get_HeapStatGlobals(out, heapName); // Since we are (and must be) analyzing the CodeHeap contents under the CodeCache_lock, --- 550,560 ---- " \n" " This function is designed and provided for support engineers\n" " to help them understand and solve issues in customer systems.\n" " It is not intended for use and interpretation by other persons.\n" " \n"); ! BUFFEREDSTREAM_FLUSH("") } get_HeapStatGlobals(out, heapName); // Since we are (and must be) analyzing the CodeHeap contents under the CodeCache_lock,
*** 491,507 **** seg_size = heap->segment_size(); log2_seg_size = seg_size == 0 ? 0 : exact_log2(seg_size); // This is a global static value. if (seg_size == 0) { printBox(ast, '-', "Heap not fully initialized yet, segment size is zero for segment ", heapName); ! STRINGSTREAM_FLUSH("") return; } if (!CodeCache_lock->owned_by_self()) { printBox(ast, '-', "aggregate function called without holding the CodeCache_lock for ", heapName); ! STRINGSTREAM_FLUSH("") return; } // Calculate granularity of analysis (and output). // The CodeHeap is managed (allocated) in segments (units) of CodeCacheSegmentSize. --- 566,582 ---- seg_size = heap->segment_size(); log2_seg_size = seg_size == 0 ? 0 : exact_log2(seg_size); // This is a global static value. if (seg_size == 0) { printBox(ast, '-', "Heap not fully initialized yet, segment size is zero for segment ", heapName); ! BUFFEREDSTREAM_FLUSH("") return; } if (!CodeCache_lock->owned_by_self()) { printBox(ast, '-', "aggregate function called without holding the CodeCache_lock for ", heapName); ! BUFFEREDSTREAM_FLUSH("") return; } // Calculate granularity of analysis (and output). // The CodeHeap is managed (allocated) in segments (units) of CodeCacheSegmentSize.
*** 553,563 **** size/(size_t)K, size/(size_t)M, res_size/(size_t)K, res_size/(size_t)M, (unsigned int)(100.0*size/res_size)); ast->print_cr(" CodeHeap allocation segment size is " SIZE_FORMAT " bytes. This is the smallest possible granularity.", seg_size); ast->print_cr(" CodeHeap (committed part) is mapped to " SIZE_FORMAT " granules of size " SIZE_FORMAT " bytes.", granules, granularity); ast->print_cr(" Each granule takes " SIZE_FORMAT " bytes of C heap, that is " SIZE_FORMAT "K in total for statistics data.", sizeof(StatElement), (sizeof(StatElement)*granules)/(size_t)K); ast->print_cr(" The number of granules is limited to %dk, requiring a granules size of at least %d bytes for a 1GB heap.", (unsigned int)(max_granules/K), (unsigned int)(G/max_granules)); ! STRINGSTREAM_FLUSH("\n") while (!done) { //---< reset counters with every aggregation >--- nBlocks_t1 = 0; --- 628,638 ---- size/(size_t)K, size/(size_t)M, res_size/(size_t)K, res_size/(size_t)M, (unsigned int)(100.0*size/res_size)); ast->print_cr(" CodeHeap allocation segment size is " SIZE_FORMAT " bytes. This is the smallest possible granularity.", seg_size); ast->print_cr(" CodeHeap (committed part) is mapped to " SIZE_FORMAT " granules of size " SIZE_FORMAT " bytes.", granules, granularity); ast->print_cr(" Each granule takes " SIZE_FORMAT " bytes of C heap, that is " SIZE_FORMAT "K in total for statistics data.", sizeof(StatElement), (sizeof(StatElement)*granules)/(size_t)K); ast->print_cr(" The number of granules is limited to %dk, requiring a granules size of at least %d bytes for a 1GB heap.", (unsigned int)(max_granules/K), (unsigned int)(G/max_granules)); ! BUFFEREDSTREAM_FLUSH("\n") while (!done) { //---< reset counters with every aggregation >--- nBlocks_t1 = 0;
*** 642,652 **** } if (ix_beg > ix_end) { insane = true; ast->print_cr("Sanity check: end index (%d) lower than begin index (%d)", ix_end, ix_beg); } if (insane) { ! STRINGSTREAM_FLUSH("") continue; } if (h->free()) { nBlocks_free++; --- 717,727 ---- } if (ix_beg > ix_end) { insane = true; ast->print_cr("Sanity check: end index (%d) lower than begin index (%d)", ix_end, ix_beg); } if (insane) { ! BUFFEREDSTREAM_FLUSH("") continue; } if (h->free()) { nBlocks_free++;
*** 1031,1041 **** ast->print_cr("max. hotness = %6d", maxTemp); } else { avgTemp = 0; ast->print_cr("No hotness data available"); } ! STRINGSTREAM_FLUSH("\n") // This loop is intentionally printing directly to "out". // It should not print anything, anyway. out->print("Verifying collected data..."); size_t granule_segs = granule_size>>log2_seg_size; --- 1106,1116 ---- ast->print_cr("max. hotness = %6d", maxTemp); } else { avgTemp = 0; ast->print_cr("No hotness data available"); } ! BUFFEREDSTREAM_FLUSH("\n") // This loop is intentionally printing directly to "out". // It should not print anything, anyway. out->print("Verifying collected data..."); size_t granule_segs = granule_size>>log2_seg_size;
*** 1113,1123 **** printBox(ast, '=', "C O D E H E A P A N A L Y S I S (free blocks) for segment ", heapName); ast->print_cr(" The aggregate step collects information about all free blocks in CodeHeap.\n" " Subsequent print functions create their output based on this snapshot.\n"); ast->print_cr(" Free space in %s is distributed over %d free blocks.", heapName, nBlocks_free); ast->print_cr(" Each free block takes " SIZE_FORMAT " bytes of C heap for statistics data, that is " SIZE_FORMAT "K in total.", sizeof(FreeBlk), (sizeof(FreeBlk)*nBlocks_free)/K); ! STRINGSTREAM_FLUSH("\n") //---------------------------------------- //-- Prepare the FreeArray of FreeBlks -- //---------------------------------------- --- 1188,1198 ---- printBox(ast, '=', "C O D E H E A P A N A L Y S I S (free blocks) for segment ", heapName); ast->print_cr(" The aggregate step collects information about all free blocks in CodeHeap.\n" " Subsequent print functions create their output based on this snapshot.\n"); ast->print_cr(" Free space in %s is distributed over %d free blocks.", heapName, nBlocks_free); ast->print_cr(" Each free block takes " SIZE_FORMAT " bytes of C heap for statistics data, that is " SIZE_FORMAT "K in total.", sizeof(FreeBlk), (sizeof(FreeBlk)*nBlocks_free)/K); ! BUFFEREDSTREAM_FLUSH("\n") //---------------------------------------- //-- Prepare the FreeArray of FreeBlks -- //----------------------------------------
*** 1149,1159 **** ix++; } if (ix != alloc_freeBlocks) { ast->print_cr("Free block count mismatch. Expected %d free blocks, but found %d.", alloc_freeBlocks, ix); ast->print_cr("I will update the counter and retry data collection"); ! STRINGSTREAM_FLUSH("\n") nBlocks_free = ix; continue; } done = true; } --- 1224,1234 ---- ix++; } if (ix != alloc_freeBlocks) { ast->print_cr("Free block count mismatch. Expected %d free blocks, but found %d.", alloc_freeBlocks, ix); ast->print_cr("I will update the counter and retry data collection"); ! BUFFEREDSTREAM_FLUSH("\n") nBlocks_free = ix; continue; } done = true; }
*** 1163,1173 **** printBox(ast, '-', "no free blocks found in ", heapName); } else if (!done) { ast->print_cr("Free block count mismatch could not be resolved."); ast->print_cr("Try to run \"aggregate\" function to update counters"); } ! STRINGSTREAM_FLUSH("") //---< discard old array and update global values >--- discard_FreeArray(out); set_HeapStatGlobals(out, heapName); return; --- 1238,1248 ---- printBox(ast, '-', "no free blocks found in ", heapName); } else if (!done) { ast->print_cr("Free block count mismatch could not be resolved."); ast->print_cr("Try to run \"aggregate\" function to update counters"); } ! BUFFEREDSTREAM_FLUSH("") //---< discard old array and update global values >--- discard_FreeArray(out); set_HeapStatGlobals(out, heapName); return;
*** 1197,1207 **** } } set_HeapStatGlobals(out, heapName); printBox(ast, '=', "C O D E H E A P A N A L Y S I S C O M P L E T E for segment ", heapName); ! STRINGSTREAM_FLUSH("\n") } void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) { if (!initialization_complete) { --- 1272,1282 ---- } } set_HeapStatGlobals(out, heapName); printBox(ast, '=', "C O D E H E A P A N A L Y S I S C O M P L E T E for segment ", heapName); ! BUFFEREDSTREAM_FLUSH("\n") } void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) { if (!initialization_complete) {
*** 1212,1222 **** get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (TopSizeArray == NULL) || (used_topSizeBlocks == 0)) { return; } ! STRINGSTREAM_DECL(ast, out) { printBox(ast, '=', "U S E D S P A C E S T A T I S T I C S for ", heapName); ast->print_cr("Note: The Top%d list of the largest used blocks associates method names\n" " and other identifying information with the block size data.\n" --- 1287,1297 ---- get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (TopSizeArray == NULL) || (used_topSizeBlocks == 0)) { return; } ! BUFFEREDSTREAM_DECL(ast, out) { printBox(ast, '=', "U S E D S P A C E S T A T I S T I C S for ", heapName); ast->print_cr("Note: The Top%d list of the largest used blocks associates method names\n" " and other identifying information with the block size data.\n"
*** 1224,1234 **** " Method names are dynamically retrieved from the code cache at print time.\n" " Due to the living nature of the code cache and because the CodeCache_lock\n" " is not continuously held, the displayed name might be wrong or no name\n" " might be found at all. The likelihood for that to happen increases\n" " over time passed between analysis and print step.\n", used_topSizeBlocks); ! STRINGSTREAM_FLUSH_LOCKED("\n") } //---------------------------- //-- Print Top Used Blocks -- //---------------------------- --- 1299,1309 ---- " Method names are dynamically retrieved from the code cache at print time.\n" " Due to the living nature of the code cache and because the CodeCache_lock\n" " is not continuously held, the displayed name might be wrong or no name\n" " might be found at all. The likelihood for that to happen increases\n" " over time passed between analysis and print step.\n", used_topSizeBlocks); ! BUFFEREDSTREAM_FLUSH_LOCKED("\n") } //---------------------------- //-- Print Top Used Blocks -- //----------------------------
*** 1244,1254 **** ast->fill_to(56); ast->print("%9s", "compiler"); ast->fill_to(66); ast->print_cr("%6s", "method"); ast->print_cr("%18s %13s %17s %4s %9s %5s %s", "Addr(module) ", "offset", "size", "type", " type lvl", " temp", "Name"); ! STRINGSTREAM_FLUSH_LOCKED("") //---< print Top Ten Used Blocks >--- if (used_topSizeBlocks > 0) { unsigned int printed_topSizeBlocks = 0; for (unsigned int i = 0; i != tsbStopper; i = TopSizeArray[i].index) { --- 1319,1329 ---- ast->fill_to(56); ast->print("%9s", "compiler"); ast->fill_to(66); ast->print_cr("%6s", "method"); ast->print_cr("%18s %13s %17s %4s %9s %5s %s", "Addr(module) ", "offset", "size", "type", " type lvl", " temp", "Name"); ! BUFFEREDSTREAM_FLUSH_LOCKED("") //---< print Top Ten Used Blocks >--- if (used_topSizeBlocks > 0) { unsigned int printed_topSizeBlocks = 0; for (unsigned int i = 0; i != tsbStopper; i = TopSizeArray[i].index) {
*** 1322,1342 **** ast->fill_to(56); //---< name and signature >--- ast->fill_to(67+6); ast->print("%s", blob_name); } ! STRINGSTREAM_FLUSH_LOCKED("\n") } if (used_topSizeBlocks != printed_topSizeBlocks) { ast->print_cr("used blocks: %d, printed blocks: %d", used_topSizeBlocks, printed_topSizeBlocks); - STRINGSTREAM_FLUSH("") for (unsigned int i = 0; i < alloc_topSizeBlocks; i++) { ast->print_cr(" TopSizeArray[%d].index = %d, len = %d", i, TopSizeArray[i].index, TopSizeArray[i].len); ! STRINGSTREAM_FLUSH("") } } ! STRINGSTREAM_FLUSH_LOCKED("\n\n") } } //----------------------------- //-- Print Usage Histogram -- --- 1397,1417 ---- ast->fill_to(56); //---< name and signature >--- ast->fill_to(67+6); ast->print("%s", blob_name); } ! ast->cr(); ! BUFFEREDSTREAM_FLUSH_IF("", 512) } if (used_topSizeBlocks != printed_topSizeBlocks) { ast->print_cr("used blocks: %d, printed blocks: %d", used_topSizeBlocks, printed_topSizeBlocks); for (unsigned int i = 0; i < alloc_topSizeBlocks; i++) { ast->print_cr(" TopSizeArray[%d].index = %d, len = %d", i, TopSizeArray[i].index, TopSizeArray[i].len); ! BUFFEREDSTREAM_FLUSH_IF("", 512) } } ! BUFFEREDSTREAM_FLUSH("\n\n") } } //----------------------------- //-- Print Usage Histogram --
*** 1357,1367 **** ast->print_cr("Note: The histogram indicates how many blocks (as a percentage\n" " of all blocks) have a size in the given range.\n" " %ld characters are printed per percentage point.\n", pctFactor/100); ast->print_cr("total size of all blocks: %7ldM", (total_size<<log2_seg_size)/M); ast->print_cr("total number of all blocks: %7ld\n", total_count); ! STRINGSTREAM_FLUSH_LOCKED("") ast->print_cr("[Size Range)------avg.-size-+----count-+"); for (unsigned int i = 0; i < nSizeDistElements; i++) { if (SizeDistributionArray[i].rangeStart<<log2_seg_size < K) { ast->print("[" SIZE_FORMAT_W(5) " .." SIZE_FORMAT_W(5) " ): " --- 1432,1442 ---- ast->print_cr("Note: The histogram indicates how many blocks (as a percentage\n" " of all blocks) have a size in the given range.\n" " %ld characters are printed per percentage point.\n", pctFactor/100); ast->print_cr("total size of all blocks: %7ldM", (total_size<<log2_seg_size)/M); ast->print_cr("total number of all blocks: %7ld\n", total_count); ! BUFFEREDSTREAM_FLUSH_LOCKED("") ast->print_cr("[Size Range)------avg.-size-+----count-+"); for (unsigned int i = 0; i < nSizeDistElements; i++) { if (SizeDistributionArray[i].rangeStart<<log2_seg_size < K) { ast->print("[" SIZE_FORMAT_W(5) " .." SIZE_FORMAT_W(5) " ): "
*** 1386,1406 **** unsigned int percent = pctFactor*SizeDistributionArray[i].count/total_count; for (unsigned int j = 1; j <= percent; j++) { ast->print("%c", (j%((pctFactor/100)*10) == 0) ? ('0'+j/(((unsigned int)pctFactor/100)*10)) : '*'); } ast->cr(); } ! ast->print_cr("----------------------------+----------+\n\n"); ! STRINGSTREAM_FLUSH_LOCKED("\n") printBox(ast, '-', "Contribution per size range to total size for ", heapName); ast->print_cr("Note: The histogram indicates how much space (as a percentage of all\n" " occupied space) is used by the blocks in the given size range.\n" " %ld characters are printed per percentage point.\n", pctFactor/100); ast->print_cr("total size of all blocks: %7ldM", (total_size<<log2_seg_size)/M); ast->print_cr("total number of all blocks: %7ld\n", total_count); ! STRINGSTREAM_FLUSH_LOCKED("") ast->print_cr("[Size Range)------avg.-size-+----count-+"); for (unsigned int i = 0; i < nSizeDistElements; i++) { if (SizeDistributionArray[i].rangeStart<<log2_seg_size < K) { ast->print("[" SIZE_FORMAT_W(5) " .." SIZE_FORMAT_W(5) " ): " --- 1461,1482 ---- unsigned int percent = pctFactor*SizeDistributionArray[i].count/total_count; for (unsigned int j = 1; j <= percent; j++) { ast->print("%c", (j%((pctFactor/100)*10) == 0) ? ('0'+j/(((unsigned int)pctFactor/100)*10)) : '*'); } ast->cr(); + BUFFEREDSTREAM_FLUSH_IF("", 512) } ! ast->print_cr("----------------------------+----------+"); ! BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") printBox(ast, '-', "Contribution per size range to total size for ", heapName); ast->print_cr("Note: The histogram indicates how much space (as a percentage of all\n" " occupied space) is used by the blocks in the given size range.\n" " %ld characters are printed per percentage point.\n", pctFactor/100); ast->print_cr("total size of all blocks: %7ldM", (total_size<<log2_seg_size)/M); ast->print_cr("total number of all blocks: %7ld\n", total_count); ! BUFFEREDSTREAM_FLUSH_LOCKED("") ast->print_cr("[Size Range)------avg.-size-+----count-+"); for (unsigned int i = 0; i < nSizeDistElements; i++) { if (SizeDistributionArray[i].rangeStart<<log2_seg_size < K) { ast->print("[" SIZE_FORMAT_W(5) " .." SIZE_FORMAT_W(5) " ): "
*** 1425,1437 **** unsigned int percent = pctFactor*(unsigned long)SizeDistributionArray[i].lenSum/total_size; for (unsigned int j = 1; j <= percent; j++) { ast->print("%c", (j%((pctFactor/100)*10) == 0) ? ('0'+j/(((unsigned int)pctFactor/100)*10)) : '*'); } ast->cr(); } ast->print_cr("----------------------------+----------+"); ! STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } } --- 1501,1514 ---- unsigned int percent = pctFactor*(unsigned long)SizeDistributionArray[i].lenSum/total_size; for (unsigned int j = 1; j <= percent; j++) { ast->print("%c", (j%((pctFactor/100)*10) == 0) ? ('0'+j/(((unsigned int)pctFactor/100)*10)) : '*'); } ast->cr(); + BUFFEREDSTREAM_FLUSH_IF("", 512) } ast->print_cr("----------------------------+----------+"); ! BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } } }
*** 1444,1468 **** get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (FreeArray == NULL) || (alloc_granules == 0)) { return; } ! STRINGSTREAM_DECL(ast, out) { printBox(ast, '=', "F R E E S P A C E S T A T I S T I C S for ", heapName); ast->print_cr("Note: in this context, a gap is the occupied space between two free blocks.\n" " Those gaps are of interest if there is a chance that they become\n" " unoccupied, e.g. by class unloading. Then, the two adjacent free\n" " blocks, together with the now unoccupied space, form a new, large\n" " free block."); ! STRINGSTREAM_FLUSH_LOCKED("\n") } { printBox(ast, '-', "List of all Free Blocks in ", heapName); - STRINGSTREAM_FLUSH_LOCKED("") unsigned int ix = 0; for (ix = 0; ix < alloc_freeBlocks-1; ix++) { ast->print(INTPTR_FORMAT ": Len[%4d] = " HEX32_FORMAT ",", p2i(FreeArray[ix].start), ix, FreeArray[ix].len); ast->fill_to(38); --- 1521,1544 ---- get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (FreeArray == NULL) || (alloc_granules == 0)) { return; } ! BUFFEREDSTREAM_DECL(ast, out) { printBox(ast, '=', "F R E E S P A C E S T A T I S T I C S for ", heapName); ast->print_cr("Note: in this context, a gap is the occupied space between two free blocks.\n" " Those gaps are of interest if there is a chance that they become\n" " unoccupied, e.g. by class unloading. Then, the two adjacent free\n" " blocks, together with the now unoccupied space, form a new, large\n" " free block."); ! BUFFEREDSTREAM_FLUSH_LOCKED("\n") } { printBox(ast, '-', "List of all Free Blocks in ", heapName); unsigned int ix = 0; for (ix = 0; ix < alloc_freeBlocks-1; ix++) { ast->print(INTPTR_FORMAT ": Len[%4d] = " HEX32_FORMAT ",", p2i(FreeArray[ix].start), ix, FreeArray[ix].len); ast->fill_to(38);
*** 1470,1483 **** ast->fill_to(71); ast->print("block count: %6d", FreeArray[ix].n_gapBlocks); if (FreeArray[ix].stubs_in_gap) { ast->print(" !! permanent gap, contains stubs and/or blobs !!"); } ! STRINGSTREAM_FLUSH_LOCKED("\n") } ast->print_cr(INTPTR_FORMAT ": Len[%4d] = " HEX32_FORMAT, p2i(FreeArray[ix].start), ix, FreeArray[ix].len); ! STRINGSTREAM_FLUSH_LOCKED("\n\n") } //----------------------------------------- //-- Find and Print Top Ten Free Blocks -- --- 1546,1560 ---- ast->fill_to(71); ast->print("block count: %6d", FreeArray[ix].n_gapBlocks); if (FreeArray[ix].stubs_in_gap) { ast->print(" !! permanent gap, contains stubs and/or blobs !!"); } ! ast->cr(); ! BUFFEREDSTREAM_FLUSH_IF("", 512) } ast->print_cr(INTPTR_FORMAT ": Len[%4d] = " HEX32_FORMAT, p2i(FreeArray[ix].start), ix, FreeArray[ix].len); ! BUFFEREDSTREAM_FLUSH_LOCKED("\n\n") } //----------------------------------------- //-- Find and Print Top Ten Free Blocks --
*** 1517,1527 **** currMax10 = currSize; } } } } ! STRINGSTREAM_FLUSH_LOCKED("") { printBox(ast, '-', "Top Ten Free Blocks in ", heapName); //---< print Top Ten Free Blocks >--- --- 1594,1604 ---- currMax10 = currSize; } } } } ! BUFFEREDSTREAM_FLUSH_IF("", 512) { printBox(ast, '-', "Top Ten Free Blocks in ", heapName); //---< print Top Ten Free Blocks >---
*** 1534,1546 **** ast->print("Gap (to next) " HEX32_FORMAT ",", FreeTopTen[iy]->gap); ast->fill_to(63); ast->print("#blocks (in gap) %d", FreeTopTen[iy]->n_gapBlocks); } ast->cr(); } - STRINGSTREAM_FLUSH_LOCKED("\n\n") } //-------------------------------------------------------- //-- Find and Print Top Ten Free-Occupied-Free Triples -- //-------------------------------------------------------- --- 1611,1624 ---- ast->print("Gap (to next) " HEX32_FORMAT ",", FreeTopTen[iy]->gap); ast->fill_to(63); ast->print("#blocks (in gap) %d", FreeTopTen[iy]->n_gapBlocks); } ast->cr(); + BUFFEREDSTREAM_FLUSH_IF("", 512) } } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n") //-------------------------------------------------------- //-- Find and Print Top Ten Free-Occupied-Free Triples -- //--------------------------------------------------------
*** 1581,1591 **** currMax10 = lenTriple; } } } } ! STRINGSTREAM_FLUSH_LOCKED("") { printBox(ast, '-', "Top Ten Free-Occupied-Free Triples in ", heapName); ast->print_cr(" Use this information to judge how likely it is that a large(r) free block\n" " might get created by code cache sweeping.\n" --- 1659,1669 ---- currMax10 = lenTriple; } } } } ! BUFFEREDSTREAM_FLUSH_IF("", 512) { printBox(ast, '-', "Top Ten Free-Occupied-Free Triples in ", heapName); ast->print_cr(" Use this information to judge how likely it is that a large(r) free block\n" " might get created by code cache sweeping.\n"
*** 1599,1611 **** ast->fill_to(39); ast->print("Gap (to next) " HEX32_FORMAT ",", FreeTopTenTriple[iy]->gap); ast->fill_to(63); ast->print("#blocks (in gap) %d", FreeTopTenTriple[iy]->n_gapBlocks); ast->cr(); } - STRINGSTREAM_FLUSH_LOCKED("\n\n") } } void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { if (!initialization_complete) { --- 1677,1690 ---- ast->fill_to(39); ast->print("Gap (to next) " HEX32_FORMAT ",", FreeTopTenTriple[iy]->gap); ast->fill_to(63); ast->print("#blocks (in gap) %d", FreeTopTenTriple[iy]->n_gapBlocks); ast->cr(); + BUFFEREDSTREAM_FLUSH_IF("", 512) } } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n") } void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) { if (!initialization_complete) {
*** 1616,1626 **** get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (alloc_granules == 0)) { return; } ! STRINGSTREAM_DECL(ast, out) unsigned int granules_per_line = 32; char* low_bound = heap->low_boundary(); { --- 1695,1705 ---- get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (alloc_granules == 0)) { return; } ! BUFFEREDSTREAM_DECL(ast, out) unsigned int granules_per_line = 32; char* low_bound = heap->low_boundary(); {
*** 1632,1778 **** " As a result, each granule contains exactly one block (or a part of one block)\n" " or is displayed as empty (' ') if it's BlobType does not match the selection.\n" " Occupied granules show their BlobType character, see legend.\n"); print_blobType_legend(ast); } ! STRINGSTREAM_FLUSH_LOCKED("") } { if (segment_granules) { printBox(ast, '-', "Total (all types) count for granule size == segment size", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_blobType_single(ast, StatArray[ix].type); } } else { printBox(ast, '-', "Total (all tiers) count, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); unsigned int count = StatArray[ix].t1_count + StatArray[ix].t2_count + StatArray[ix].tx_count + StatArray[ix].stub_count + StatArray[ix].dead_count; print_count_single(ast, count); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } { if (nBlocks_t1 > 0) { printBox(ast, '-', "Tier1 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].t1_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].t1_count); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Tier1 nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_t2 > 0) { printBox(ast, '-', "Tier2 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].t2_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].t2_count); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Tier2 nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_alive > 0) { printBox(ast, '-', "not_used/not_entrant/not_installed nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].tx_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].tx_count); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No not_used/not_entrant nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_stub > 0) { printBox(ast, '-', "Stub & Blob count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].stub_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].stub_count); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Stubs and Blobs found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_dead > 0) { printBox(ast, '-', "Dead nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].dead_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].dead_count); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No dead nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (!segment_granules) { // Prevent totally redundant printouts printBox(ast, '-', "Count by tier (combined, no dead blocks): <#t1>:<#t2>:<#s>, 0x0..0xf. '*' indicates >= 16 blocks", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 24; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); --- 1711,1849 ---- " As a result, each granule contains exactly one block (or a part of one block)\n" " or is displayed as empty (' ') if it's BlobType does not match the selection.\n" " Occupied granules show their BlobType character, see legend.\n"); print_blobType_legend(ast); } ! BUFFEREDSTREAM_FLUSH_LOCKED("") } { if (segment_granules) { printBox(ast, '-', "Total (all types) count for granule size == segment size", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_blobType_single(ast, StatArray[ix].type); } } else { printBox(ast, '-', "Total (all tiers) count, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); unsigned int count = StatArray[ix].t1_count + StatArray[ix].t2_count + StatArray[ix].tx_count + StatArray[ix].stub_count + StatArray[ix].dead_count; print_count_single(ast, count); } } ! BUFFEREDSTREAM_FLUSH_LOCKED("|\n\n\n") } { if (nBlocks_t1 > 0) { printBox(ast, '-', "Tier1 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].t1_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].t1_count); } } ! ast->print("|"); } else { ast->print("No Tier1 nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_t2 > 0) { printBox(ast, '-', "Tier2 nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].t2_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].t2_count); } } ! ast->print("|"); } else { ast->print("No Tier2 nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_alive > 0) { printBox(ast, '-', "not_used/not_entrant/not_installed nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].tx_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].tx_count); } } ! ast->print("|"); } else { ast->print("No not_used/not_entrant nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_stub > 0) { printBox(ast, '-', "Stub & Blob count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].stub_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].stub_count); } } ! ast->print("|"); } else { ast->print("No Stubs and Blobs found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_dead > 0) { printBox(ast, '-', "Dead nMethod count only, 0x1..0xf. '*' indicates >= 16 blocks, ' ' indicates empty", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].dead_count > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_count_single(ast, StatArray[ix].dead_count); } } ! ast->print("|"); } else { ast->print("No dead nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (!segment_granules) { // Prevent totally redundant printouts printBox(ast, '-', "Count by tier (combined, no dead blocks): <#t1>:<#t2>:<#s>, 0x0..0xf. '*' indicates >= 16 blocks", NULL); granules_per_line = 24; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line);
*** 1785,1795 **** } else { print_count_single(ast, StatArray[ix].stub_count); } ast->print(" "); } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } } } --- 1856,1866 ---- } else { print_count_single(ast, StatArray[ix].stub_count); } ast->print(" "); } ! BUFFEREDSTREAM_FLUSH_LOCKED("|\n\n\n") } } }
*** 1802,1812 **** get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (alloc_granules == 0)) { return; } ! STRINGSTREAM_DECL(ast, out) unsigned int granules_per_line = 32; char* low_bound = heap->low_boundary(); { --- 1873,1883 ---- get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (alloc_granules == 0)) { return; } ! BUFFEREDSTREAM_DECL(ast, out) unsigned int granules_per_line = 32; char* low_bound = heap->low_boundary(); {
*** 1821,1898 **** print_blobType_legend(ast); } else { ast->print_cr(" These digits represent a fill percentage range (see legend).\n"); print_space_legend(ast); } ! STRINGSTREAM_FLUSH_LOCKED("") } { if (segment_granules) { printBox(ast, '-', "Total (all types) space consumption for granule size == segment size", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_blobType_single(ast, StatArray[ix].type); } } else { printBox(ast, '-', "Total (all types) space consumption. ' ' indicates empty, '*' indicates full.", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); unsigned int space = StatArray[ix].t1_space + StatArray[ix].t2_space + StatArray[ix].tx_space + StatArray[ix].stub_space + StatArray[ix].dead_space; print_space_single(ast, space); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } { if (nBlocks_t1 > 0) { printBox(ast, '-', "Tier1 space consumption. ' ' indicates empty, '*' indicates full", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].t1_space > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_space_single(ast, StatArray[ix].t1_space); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Tier1 nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_t2 > 0) { printBox(ast, '-', "Tier2 space consumption. ' ' indicates empty, '*' indicates full", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].t2_space > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_space_single(ast, StatArray[ix].t2_space); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Tier2 nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_alive > 0) { printBox(ast, '-', "not_used/not_entrant/not_installed space consumption. ' ' indicates empty, '*' indicates full", NULL); --- 1892,1965 ---- print_blobType_legend(ast); } else { ast->print_cr(" These digits represent a fill percentage range (see legend).\n"); print_space_legend(ast); } ! BUFFEREDSTREAM_FLUSH_LOCKED("") } { if (segment_granules) { printBox(ast, '-', "Total (all types) space consumption for granule size == segment size", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_blobType_single(ast, StatArray[ix].type); } } else { printBox(ast, '-', "Total (all types) space consumption. ' ' indicates empty, '*' indicates full.", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); unsigned int space = StatArray[ix].t1_space + StatArray[ix].t2_space + StatArray[ix].tx_space + StatArray[ix].stub_space + StatArray[ix].dead_space; print_space_single(ast, space); } } ! BUFFEREDSTREAM_FLUSH_LOCKED("|\n\n\n") } { if (nBlocks_t1 > 0) { printBox(ast, '-', "Tier1 space consumption. ' ' indicates empty, '*' indicates full", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].t1_space > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_space_single(ast, StatArray[ix].t1_space); } } ! ast->print("|"); } else { ast->print("No Tier1 nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_t2 > 0) { printBox(ast, '-', "Tier2 space consumption. ' ' indicates empty, '*' indicates full", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].t2_space > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_space_single(ast, StatArray[ix].t2_space); } } ! ast->print("|"); } else { ast->print("No Tier2 nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_alive > 0) { printBox(ast, '-', "not_used/not_entrant/not_installed space consumption. ' ' indicates empty, '*' indicates full", NULL);
*** 1904,1962 **** print_blobType_single(ast, StatArray[ix].type); } else { print_space_single(ast, StatArray[ix].tx_space); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Tier2 nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_stub > 0) { printBox(ast, '-', "Stub and Blob space consumption. ' ' indicates empty, '*' indicates full", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].stub_space > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_space_single(ast, StatArray[ix].stub_space); } } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Stubs and Blobs found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_dead > 0) { printBox(ast, '-', "Dead space consumption. ' ' indicates empty, '*' indicates full", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_space_single(ast, StatArray[ix].dead_space); } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No dead nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (!segment_granules) { // Prevent totally redundant printouts printBox(ast, '-', "Space consumption by tier (combined): <t1%>:<t2%>:<s%>. ' ' indicates empty, '*' indicates full", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 24; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); --- 1971,2026 ---- print_blobType_single(ast, StatArray[ix].type); } else { print_space_single(ast, StatArray[ix].tx_space); } } ! ast->print("|"); } else { ast->print("No Tier2 nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_stub > 0) { printBox(ast, '-', "Stub and Blob space consumption. ' ' indicates empty, '*' indicates full", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); if (segment_granules && StatArray[ix].stub_space > 0) { print_blobType_single(ast, StatArray[ix].type); } else { print_space_single(ast, StatArray[ix].stub_space); } } ! ast->print("|"); } else { ast->print("No Stubs and Blobs found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_dead > 0) { printBox(ast, '-', "Dead space consumption. ' ' indicates empty, '*' indicates full", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_space_single(ast, StatArray[ix].dead_space); } ! ast->print("|"); } else { ast->print("No dead nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (!segment_granules) { // Prevent totally redundant printouts printBox(ast, '-', "Space consumption by tier (combined): <t1%>:<t2%>:<s%>. ' ' indicates empty, '*' indicates full", NULL); granules_per_line = 24; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line);
*** 1977,1987 **** } else { print_space_single(ast, StatArray[ix].stub_space); } ast->print(" "); } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } } } void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) { --- 2041,2052 ---- } else { print_space_single(ast, StatArray[ix].stub_space); } ast->print(" "); } ! ast->print("|"); ! BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } } } void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) {
*** 1993,2003 **** get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (alloc_granules == 0)) { return; } ! STRINGSTREAM_DECL(ast, out) unsigned int granules_per_line = 32; char* low_bound = heap->low_boundary(); { --- 2058,2068 ---- get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (alloc_granules == 0)) { return; } ! BUFFEREDSTREAM_DECL(ast, out) unsigned int granules_per_line = 32; char* low_bound = heap->low_boundary(); {
*** 2007,2022 **** " Age information is available for tier1 and tier2 methods only. There is no\n" " age information for stubs and blobs, because they have no compilation ID assigned.\n" " Information for the youngest method (highest ID) in the granule is printed.\n" " Refer to the legend to learn how method age is mapped to the displayed digit."); print_age_legend(ast); ! STRINGSTREAM_FLUSH_LOCKED("") } { printBox(ast, '-', "Age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); unsigned int age1 = StatArray[ix].t1_age; --- 2072,2086 ---- " Age information is available for tier1 and tier2 methods only. There is no\n" " age information for stubs and blobs, because they have no compilation ID assigned.\n" " Information for the youngest method (highest ID) in the granule is printed.\n" " Refer to the legend to learn how method age is mapped to the displayed digit."); print_age_legend(ast); ! BUFFEREDSTREAM_FLUSH_LOCKED("") } { printBox(ast, '-', "Age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); unsigned int age1 = StatArray[ix].t1_age;
*** 2024,2101 **** unsigned int agex = StatArray[ix].tx_age; unsigned int age = age1 > age2 ? age1 : age2; age = age > agex ? age : agex; print_age_single(ast, age); } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } { if (nBlocks_t1 > 0) { printBox(ast, '-', "Tier1 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_age_single(ast, StatArray[ix].t1_age); } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Tier1 nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_t2 > 0) { printBox(ast, '-', "Tier2 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_age_single(ast, StatArray[ix].t2_age); } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Tier2 nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (nBlocks_alive > 0) { printBox(ast, '-', "not_used/not_entrant/not_installed age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_age_single(ast, StatArray[ix].tx_age); } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } else { ast->print("No Tier2 nMethods found in CodeHeap."); - STRINGSTREAM_FLUSH_LOCKED("\n\n\n") } } { if (!segment_granules) { // Prevent totally redundant printouts printBox(ast, '-', "age distribution by tier <a1>:<a2>. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); - STRINGSTREAM_FLUSH_LOCKED("") granules_per_line = 32; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_age_single(ast, StatArray[ix].t1_age); ast->print(":"); print_age_single(ast, StatArray[ix].t2_age); ast->print(" "); } ! STRINGSTREAM_FLUSH_LOCKED("|\n\n\n") } } } --- 2088,2163 ---- unsigned int agex = StatArray[ix].tx_age; unsigned int age = age1 > age2 ? age1 : age2; age = age > agex ? age : agex; print_age_single(ast, age); } ! ast->print("|"); ! BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_t1 > 0) { printBox(ast, '-', "Tier1 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_age_single(ast, StatArray[ix].t1_age); } ! ast->print("|"); } else { ast->print("No Tier1 nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_t2 > 0) { printBox(ast, '-', "Tier2 age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_age_single(ast, StatArray[ix].t2_age); } ! ast->print("|"); } else { ast->print("No Tier2 nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (nBlocks_alive > 0) { printBox(ast, '-', "not_used/not_entrant/not_installed age distribution. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); granules_per_line = 128; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_age_single(ast, StatArray[ix].tx_age); } ! ast->print("|"); } else { ast->print("No Tier2 nMethods found in CodeHeap."); } + BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } { if (!segment_granules) { // Prevent totally redundant printouts printBox(ast, '-', "age distribution by tier <a1>:<a2>. '0' indicates youngest 1/256, '8': oldest half, ' ': no age information", NULL); granules_per_line = 32; for (unsigned int ix = 0; ix < alloc_granules; ix++) { print_line_delim(out, ast, low_bound, ix, granules_per_line); print_age_single(ast, StatArray[ix].t1_age); ast->print(":"); print_age_single(ast, StatArray[ix].t2_age); ast->print(" "); } ! ast->print("|"); ! BUFFEREDSTREAM_FLUSH_LOCKED("\n\n\n") } } }
*** 2108,2118 **** get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (alloc_granules == 0)) { return; } ! STRINGSTREAM_DECL(ast, out) unsigned int granules_per_line = 128; char* low_bound = heap->low_boundary(); CodeBlob* last_blob = NULL; bool name_in_addr_range = true; --- 2170,2180 ---- get_HeapStatGlobals(out, heapName); if ((StatArray == NULL) || (alloc_granules == 0)) { return; } ! BUFFEREDSTREAM_DECL(ast, out) unsigned int granules_per_line = 128; char* low_bound = heap->low_boundary(); CodeBlob* last_blob = NULL; bool name_in_addr_range = true;
*** 2127,2137 **** ast->print_cr(" Method names are dynamically retrieved from the code cache at print time.\n" " Due to the living nature of the code heap and because the CodeCache_lock\n" " is not continuously held, the displayed name might be wrong or no name\n" " might be found at all. The likelihood for that to happen increases\n" " over time passed between aggregtion and print steps.\n"); ! STRINGSTREAM_FLUSH_LOCKED("") for (unsigned int ix = 0; ix < alloc_granules; ix++) { //---< print a new blob on a new line >--- if (ix%granules_per_line == 0) { if (!name_in_addr_range) { --- 2189,2199 ---- ast->print_cr(" Method names are dynamically retrieved from the code cache at print time.\n" " Due to the living nature of the code heap and because the CodeCache_lock\n" " is not continuously held, the displayed name might be wrong or no name\n" " might be found at all. The likelihood for that to happen increases\n" " over time passed between aggregtion and print steps.\n"); ! BUFFEREDSTREAM_FLUSH_LOCKED("") for (unsigned int ix = 0; ix < alloc_granules; ix++) { //---< print a new blob on a new line >--- if (ix%granules_per_line == 0) { if (!name_in_addr_range) {
*** 2142,2152 **** size_t end_ix = (ix+granules_per_line <= alloc_granules) ? ix+granules_per_line : alloc_granules; ast->cr(); ast->print_cr("--------------------------------------------------------------------"); ast->print_cr("Address range [" INTPTR_FORMAT "," INTPTR_FORMAT "), " SIZE_FORMAT "k", p2i(low_bound+ix*granule_size), p2i(low_bound + end_ix*granule_size), (end_ix - ix)*granule_size/(size_t)K); ast->print_cr("--------------------------------------------------------------------"); ! STRINGSTREAM_FLUSH_LOCKED("") } // Only check granule if it contains at least one blob. unsigned int nBlobs = StatArray[ix].t1_count + StatArray[ix].t2_count + StatArray[ix].tx_count + StatArray[ix].stub_count + StatArray[ix].dead_count; if (nBlobs > 0 ) { --- 2204,2214 ---- size_t end_ix = (ix+granules_per_line <= alloc_granules) ? ix+granules_per_line : alloc_granules; ast->cr(); ast->print_cr("--------------------------------------------------------------------"); ast->print_cr("Address range [" INTPTR_FORMAT "," INTPTR_FORMAT "), " SIZE_FORMAT "k", p2i(low_bound+ix*granule_size), p2i(low_bound + end_ix*granule_size), (end_ix - ix)*granule_size/(size_t)K); ast->print_cr("--------------------------------------------------------------------"); ! BUFFEREDSTREAM_FLUSH_IF("", 512) } // Only check granule if it contains at least one blob. unsigned int nBlobs = StatArray[ix].t1_count + StatArray[ix].t2_count + StatArray[ix].tx_count + StatArray[ix].stub_count + StatArray[ix].dead_count; if (nBlobs > 0 ) {
*** 2190,2200 **** ast->fill_to(51); ast->print("%9s", "compiler"); ast->fill_to(61); ast->print_cr("%6s", "method"); ast->print_cr("%18s %13s %17s %9s %5s %18s %s", "Addr(module) ", "offset", "size", " type lvl", " temp", "blobType ", "Name"); ! STRINGSTREAM_FLUSH_LOCKED("") } //---< print line prefix (address and offset from CodeHeap start) >--- ast->print(INTPTR_FORMAT, p2i(this_blob)); ast->fill_to(19); --- 2252,2262 ---- ast->fill_to(51); ast->print("%9s", "compiler"); ast->fill_to(61); ast->print_cr("%6s", "method"); ast->print_cr("%18s %13s %17s %9s %5s %18s %s", "Addr(module) ", "offset", "size", " type lvl", " temp", "blobType ", "Name"); ! BUFFEREDSTREAM_FLUSH_IF("", 512) } //---< print line prefix (address and offset from CodeHeap start) >--- ast->print(INTPTR_FORMAT, p2i(this_blob)); ast->fill_to(19);
*** 2246,2264 **** ast->print("%s", blob_name); } else { ast->fill_to(62+6); ast->print("<stale blob>"); } ! STRINGSTREAM_FLUSH_LOCKED("\n") } else if (!blob_is_safe && (this_blob != last_blob) && (this_blob != NULL)) { last_blob = this_blob; - STRINGSTREAM_FLUSH_LOCKED("\n") } } } // nBlobs > 0 } ! STRINGSTREAM_FLUSH_LOCKED("\n\n") } void CodeHeapState::printBox(outputStream* ast, const char border, const char* text1, const char* text2) { unsigned int lineLen = 1 + 2 + 2 + 1; --- 2308,2326 ---- ast->print("%s", blob_name); } else { ast->fill_to(62+6); ast->print("<stale blob>"); } ! ast->cr(); ! BUFFEREDSTREAM_FLUSH_IF("", 512) } else if (!blob_is_safe && (this_blob != last_blob) && (this_blob != NULL)) { last_blob = this_blob; } } } // nBlobs > 0 } ! BUFFEREDSTREAM_FLUSH_LOCKED("\n\n") } void CodeHeapState::printBox(outputStream* ast, const char border, const char* text1, const char* text2) { unsigned int lineLen = 1 + 2 + 2 + 1;
*** 2391,2401 **** if (ix > 0) { ast->print("|"); } ast->cr(); ! { // can't use STRINGSTREAM_FLUSH_LOCKED("") here. ttyLocker ttyl; out->print("%s", ast->as_string()); ast->reset(); } --- 2453,2467 ---- if (ix > 0) { ast->print("|"); } ast->cr(); ! // can't use BUFFEREDSTREAM_FLUSH_IF("", 512) here. ! // can't use this expression. bufferedStream::capacity() does not exist. ! // if ((ast->capacity() - ast->size()) < 512) { ! // Assume instead that default bufferedStream capacity (4K) was used. ! if (ast->size() > 3*K) { ttyLocker ttyl; out->print("%s", ast->as_string()); ast->reset(); }
< prev index next >