< prev index next >

src/hotspot/share/code/codeHeapState.cpp

Print this page




 513 // This should be done after an analysis session is completed.
 514 void CodeHeapState::discard(outputStream* out, CodeHeap* heap) {
 515   if (!initialization_complete) {
 516     return;
 517   }
 518 
 519   if (nHeaps > 0) {
 520     for (unsigned int ix = 0; ix < nHeaps; ix++) {
 521       get_HeapStatGlobals(out, CodeHeapStatArray[ix].heapName);
 522       discard_StatArray(out);
 523       discard_FreeArray(out);
 524       discard_TopSizeArray(out);
 525       discard_SizeDistArray(out);
 526       set_HeapStatGlobals(out, CodeHeapStatArray[ix].heapName);
 527       CodeHeapStatArray[ix].heapName = NULL;
 528     }
 529     nHeaps = 0;
 530   }
 531 }
 532 
 533 void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granularity) {
 534   unsigned int nBlocks_free    = 0;
 535   unsigned int nBlocks_used    = 0;
 536   unsigned int nBlocks_zomb    = 0;
 537   unsigned int nBlocks_disconn = 0;
 538   unsigned int nBlocks_notentr = 0;
 539 
 540   //---<  max & min of TopSizeArray  >---
 541   //  it is sufficient to have these sizes as 32bit unsigned ints.
 542   //  The CodeHeap is limited in size to 4GB. Furthermore, the sizes
 543   //  are stored in _segment_size units, scaling them down by a factor of 64 (at least).
 544   unsigned int  currMax          = 0;
 545   unsigned int  currMin          = 0;
 546   unsigned int  currMin_ix       = 0;
 547   unsigned long total_iterations = 0;
 548 
 549   bool  done             = false;
 550   const int min_granules = 256;
 551   const int max_granules = 512*K; // limits analyzable CodeHeap (with segment_granules) to 32M..128M
 552                                   // results in StatArray size of 24M (= max_granules * 48 Bytes per element)
 553                                   // For a 1GB CodeHeap, the granule size must be at least 2kB to not violate the max_granles limit.


 595   }
 596 
 597   // Calculate granularity of analysis (and output).
 598   //   The CodeHeap is managed (allocated) in segments (units) of CodeCacheSegmentSize.
 599   //   The CodeHeap can become fairly large, in particular in productive real-life systems.
 600   //
 601   //   It is often neither feasible nor desirable to aggregate the data with the highest possible
 602   //   level of detail, i.e. inspecting and printing each segment on its own.
 603   //
 604   //   The granularity parameter allows to specify the level of detail available in the analysis.
 605   //   It must be a positive multiple of the segment size and should be selected such that enough
 606   //   detail is provided while, at the same time, the printed output does not explode.
 607   //
 608   //   By manipulating the granularity value, we enforce that at least min_granules units
 609   //   of analysis are available. We also enforce an upper limit of max_granules units to
 610   //   keep the amount of allocated storage in check.
 611   //
 612   //   Finally, we adjust the granularity such that each granule covers at most 64k-1 segments.
 613   //   This is necessary to prevent an unsigned short overflow while accumulating space information.
 614   //
 615   assert(granularity > 0, "granularity should be positive.");
 616 
 617   if (granularity > size) {
 618     granularity = size;
 619   }
 620   if (size/granularity < min_granules) {
 621     granularity = size/min_granules;                                   // at least min_granules granules
 622   }
 623   granularity = granularity & (~(seg_size - 1));                       // must be multiple of seg_size
 624   if (granularity < seg_size) {
 625     granularity = seg_size;                                            // must be at least seg_size
 626   }
 627   if (size/granularity > max_granules) {
 628     granularity = size/max_granules;                                   // at most max_granules granules
 629   }
 630   granularity = granularity & (~(seg_size - 1));                       // must be multiple of seg_size
 631   if (granularity>>log2_seg_size >= (1L<<sizeof(unsigned short)*8)) {
 632     granularity = ((1L<<(sizeof(unsigned short)*8))-1)<<log2_seg_size; // Limit: (64k-1) * seg_size
 633   }
 634   segment_granules = granularity == seg_size;
 635   size_t granules  = (size + (granularity-1))/granularity;
 636 




 513 // This should be done after an analysis session is completed.
 514 void CodeHeapState::discard(outputStream* out, CodeHeap* heap) {
 515   if (!initialization_complete) {
 516     return;
 517   }
 518 
 519   if (nHeaps > 0) {
 520     for (unsigned int ix = 0; ix < nHeaps; ix++) {
 521       get_HeapStatGlobals(out, CodeHeapStatArray[ix].heapName);
 522       discard_StatArray(out);
 523       discard_FreeArray(out);
 524       discard_TopSizeArray(out);
 525       discard_SizeDistArray(out);
 526       set_HeapStatGlobals(out, CodeHeapStatArray[ix].heapName);
 527       CodeHeapStatArray[ix].heapName = NULL;
 528     }
 529     nHeaps = 0;
 530   }
 531 }
 532 
 533 void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, const char* granularity_request) {
 534   unsigned int nBlocks_free    = 0;
 535   unsigned int nBlocks_used    = 0;
 536   unsigned int nBlocks_zomb    = 0;
 537   unsigned int nBlocks_disconn = 0;
 538   unsigned int nBlocks_notentr = 0;
 539 
 540   //---<  max & min of TopSizeArray  >---
 541   //  it is sufficient to have these sizes as 32bit unsigned ints.
 542   //  The CodeHeap is limited in size to 4GB. Furthermore, the sizes
 543   //  are stored in _segment_size units, scaling them down by a factor of 64 (at least).
 544   unsigned int  currMax          = 0;
 545   unsigned int  currMin          = 0;
 546   unsigned int  currMin_ix       = 0;
 547   unsigned long total_iterations = 0;
 548 
 549   bool  done             = false;
 550   const int min_granules = 256;
 551   const int max_granules = 512*K; // limits analyzable CodeHeap (with segment_granules) to 32M..128M
 552                                   // results in StatArray size of 24M (= max_granules * 48 Bytes per element)
 553                                   // For a 1GB CodeHeap, the granule size must be at least 2kB to not violate the max_granles limit.


 595   }
 596 
 597   // Calculate granularity of analysis (and output).
 598   //   The CodeHeap is managed (allocated) in segments (units) of CodeCacheSegmentSize.
 599   //   The CodeHeap can become fairly large, in particular in productive real-life systems.
 600   //
 601   //   It is often neither feasible nor desirable to aggregate the data with the highest possible
 602   //   level of detail, i.e. inspecting and printing each segment on its own.
 603   //
 604   //   The granularity parameter allows to specify the level of detail available in the analysis.
 605   //   It must be a positive multiple of the segment size and should be selected such that enough
 606   //   detail is provided while, at the same time, the printed output does not explode.
 607   //
 608   //   By manipulating the granularity value, we enforce that at least min_granules units
 609   //   of analysis are available. We also enforce an upper limit of max_granules units to
 610   //   keep the amount of allocated storage in check.
 611   //
 612   //   Finally, we adjust the granularity such that each granule covers at most 64k-1 segments.
 613   //   This is necessary to prevent an unsigned short overflow while accumulating space information.
 614   //
 615   size_t granularity = strtol(granularity_request, NULL, 0);

 616   if (granularity > size) {
 617     granularity = size;
 618   }
 619   if (size/granularity < min_granules) {
 620     granularity = size/min_granules;                                   // at least min_granules granules
 621   }
 622   granularity = granularity & (~(seg_size - 1));                       // must be multiple of seg_size
 623   if (granularity < seg_size) {
 624     granularity = seg_size;                                            // must be at least seg_size
 625   }
 626   if (size/granularity > max_granules) {
 627     granularity = size/max_granules;                                   // at most max_granules granules
 628   }
 629   granularity = granularity & (~(seg_size - 1));                       // must be multiple of seg_size
 630   if (granularity>>log2_seg_size >= (1L<<sizeof(unsigned short)*8)) {
 631     granularity = ((1L<<(sizeof(unsigned short)*8))-1)<<log2_seg_size; // Limit: (64k-1) * seg_size
 632   }
 633   segment_granules = granularity == seg_size;
 634   size_t granules  = (size + (granularity-1))/granularity;
 635 


< prev index next >