Java Code Examples for sun.hotspot.WhiteBox#getVMPageSize()

The following examples show how to use sun.hotspot.WhiteBox#getVMPageSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestLargePageUseForAuxMemory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.isDebugBuild()) {
        System.out.println("Skip tests on non-debug builds because the required option TracePageSizes is a debug-only option.");
        return;
    }

    WhiteBox wb = WhiteBox.getWhiteBox();
    smallPageSize = wb.getVMPageSize();
    largePageSize = wb.getVMLargePageSize();

    if (largePageSize == 0) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform.");
        return;
    }

    // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size).
    // 32 bit systems will have problems reserving such an amount of contiguous space, so skip the
    // test there.
    if (!Platform.is32bit()) {
        // Size that a single card covers.
        final int cardSize = 512;

        final long heapSizeForCardTableUsingLargePages = largePageSize * cardSize;

        testVM(heapSizeForCardTableUsingLargePages, true, true);
        testVM(heapSizeForCardTableUsingLargePages + HEAP_REGION_SIZE, true, true);
        testVM(heapSizeForCardTableUsingLargePages - HEAP_REGION_SIZE, false, true);
    }

    // Minimum heap requirement to get large pages for bitmaps is 128M heap. This seems okay to test
    // everywhere.
    final int bitmapTranslationFactor = 8 * 8; // ObjectAlignmentInBytes * BitsPerByte
    final long heapSizeForBitmapUsingLargePages = largePageSize * bitmapTranslationFactor;

    testVM(heapSizeForBitmapUsingLargePages, false, true);
    testVM(heapSizeForBitmapUsingLargePages + HEAP_REGION_SIZE, false, true);
    testVM(heapSizeForBitmapUsingLargePages - HEAP_REGION_SIZE, false, false);
}
 
Example 2
Source File: ReadVMPageSize.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  int pageSize = wb.getVMPageSize();
  if (pageSize < 0) {
    throw new Exception("pageSize < 0");
  } else {
    System.out.println("Page size = " + pageSize);
  }
}
 
Example 3
Source File: TestLargePageUseForAuxMemory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.isDebugBuild()) {
        System.out.println("Skip tests on non-debug builds because the required option TracePageSizes is a debug-only option.");
        return;
    }

    WhiteBox wb = WhiteBox.getWhiteBox();
    smallPageSize = wb.getVMPageSize();
    largePageSize = wb.getVMLargePageSize();

    if (largePageSize == 0) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform.");
        return;
    }

    // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size).
    // 32 bit systems will have problems reserving such an amount of contiguous space, so skip the
    // test there.
    if (!Platform.is32bit()) {
        // Size that a single card covers.
        final int cardSize = 512;

        final long heapSizeForCardTableUsingLargePages = largePageSize * cardSize;

        testVM(heapSizeForCardTableUsingLargePages, true, true);
        testVM(heapSizeForCardTableUsingLargePages + HEAP_REGION_SIZE, true, true);
        testVM(heapSizeForCardTableUsingLargePages - HEAP_REGION_SIZE, false, true);
    }

    // Minimum heap requirement to get large pages for bitmaps is 128M heap. This seems okay to test
    // everywhere.
    final int bitmapTranslationFactor = 8 * 8; // ObjectAlignmentInBytes * BitsPerByte
    final long heapSizeForBitmapUsingLargePages = largePageSize * bitmapTranslationFactor;

    testVM(heapSizeForBitmapUsingLargePages, false, true);
    testVM(heapSizeForBitmapUsingLargePages + HEAP_REGION_SIZE, false, true);
    testVM(heapSizeForBitmapUsingLargePages - HEAP_REGION_SIZE, false, false);
}
 
Example 4
Source File: ReadVMPageSize.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  int pageSize = wb.getVMPageSize();
  if (pageSize < 0) {
    throw new Exception("pageSize < 0");
  } else {
    System.out.println("Page size = " + pageSize);
  }
}
 
Example 5
Source File: TestLargePageUseForAuxMemory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.isDebugBuild()) {
        System.out.println("Skip tests on non-debug builds because the required option TracePageSizes is a debug-only option.");
        return;
    }

    WhiteBox wb = WhiteBox.getWhiteBox();
    smallPageSize = wb.getVMPageSize();
    largePageSize = wb.getVMLargePageSize();

    if (largePageSize == 0) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform.");
        return;
    }

    // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size).
    // 32 bit systems will have problems reserving such an amount of contiguous space, so skip the
    // test there.
    if (!Platform.is32bit()) {
        // Size that a single card covers.
        final int cardSize = 512;

        final long heapSizeForCardTableUsingLargePages = largePageSize * cardSize;

        testVM(heapSizeForCardTableUsingLargePages, true, true);
        testVM(heapSizeForCardTableUsingLargePages + HEAP_REGION_SIZE, true, true);
        testVM(heapSizeForCardTableUsingLargePages - HEAP_REGION_SIZE, false, true);
    }

    // Minimum heap requirement to get large pages for bitmaps is 128M heap. This seems okay to test
    // everywhere.
    final int bitmapTranslationFactor = 8 * 8; // ObjectAlignmentInBytes * BitsPerByte
    final long heapSizeForBitmapUsingLargePages = largePageSize * bitmapTranslationFactor;

    testVM(heapSizeForBitmapUsingLargePages, false, true);
    testVM(heapSizeForBitmapUsingLargePages + HEAP_REGION_SIZE, false, true);
    testVM(heapSizeForBitmapUsingLargePages - HEAP_REGION_SIZE, false, false);
}
 
Example 6
Source File: ReadVMPageSize.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  int pageSize = wb.getVMPageSize();
  if (pageSize < 0) {
    throw new Exception("pageSize < 0");
  } else {
    System.out.println("Page size = " + pageSize);
  }
}
 
Example 7
Source File: TestLargePageUseForAuxMemory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.isDebugBuild()) {
        System.out.println("Skip tests on non-debug builds because the required option TracePageSizes is a debug-only option.");
        return;
    }

    WhiteBox wb = WhiteBox.getWhiteBox();
    smallPageSize = wb.getVMPageSize();
    largePageSize = wb.getVMLargePageSize();

    if (largePageSize == 0) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform.");
        return;
    }

    // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size).
    // 32 bit systems will have problems reserving such an amount of contiguous space, so skip the
    // test there.
    if (!Platform.is32bit()) {
        // Size that a single card covers.
        final int cardSize = 512;

        final long heapSizeForCardTableUsingLargePages = largePageSize * cardSize;

        testVM(heapSizeForCardTableUsingLargePages, true, true);
        testVM(heapSizeForCardTableUsingLargePages + HEAP_REGION_SIZE, true, true);
        testVM(heapSizeForCardTableUsingLargePages - HEAP_REGION_SIZE, false, true);
    }

    // Minimum heap requirement to get large pages for bitmaps is 128M heap. This seems okay to test
    // everywhere.
    final int bitmapTranslationFactor = 8 * 8; // ObjectAlignmentInBytes * BitsPerByte
    final long heapSizeForBitmapUsingLargePages = largePageSize * bitmapTranslationFactor;

    testVM(heapSizeForBitmapUsingLargePages, false, true);
    testVM(heapSizeForBitmapUsingLargePages + HEAP_REGION_SIZE, false, true);
    testVM(heapSizeForBitmapUsingLargePages - HEAP_REGION_SIZE, false, false);
}
 
Example 8
Source File: ReadVMPageSize.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  int pageSize = wb.getVMPageSize();
  if (pageSize < 0) {
    throw new Exception("pageSize < 0");
  } else {
    System.out.println("Page size = " + pageSize);
  }
}
 
Example 9
Source File: TestSmallHeap.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Do all work in the VM driving the test, the VM
    // with the small heap size should do as little as
    // possible to avoid hitting an OOME.
    WhiteBox wb = WhiteBox.getWhiteBox();
    int pageSize = wb.getVMPageSize();
    int heapBytesPerCard = 512;
    long expectedMaxHeap = pageSize * heapBytesPerCard;

    verifySmallHeapSize("-XX:+UseParallelGC", expectedMaxHeap);
    verifySmallHeapSize("-XX:+UseSerialGC", expectedMaxHeap);
    verifySmallHeapSize("-XX:+UseG1GC", expectedMaxHeap);
    verifySmallHeapSize("-XX:+UseConcMarkSweepGC", expectedMaxHeap);
}
 
Example 10
Source File: ReadVMPageSize.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  int pageSize = wb.getVMPageSize();
  if (pageSize < 0) {
    throw new Exception("pageSize < 0");
  } else {
    System.out.println("Page size = " + pageSize);
  }
}
 
Example 11
Source File: TestLargePageUseForAuxMemory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (!Platform.isDebugBuild()) {
        System.out.println("Skip tests on non-debug builds because the required option TracePageSizes is a debug-only option.");
        return;
    }

    WhiteBox wb = WhiteBox.getWhiteBox();
    smallPageSize = wb.getVMPageSize();
    largePageSize = wb.getVMLargePageSize();

    if (largePageSize == 0) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform.");
        return;
    }

    // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size).
    // 32 bit systems will have problems reserving such an amount of contiguous space, so skip the
    // test there.
    if (!Platform.is32bit()) {
        // Size that a single card covers.
        final int cardSize = 512;

        final long heapSizeForCardTableUsingLargePages = largePageSize * cardSize;

        testVM(heapSizeForCardTableUsingLargePages, true, true);
        testVM(heapSizeForCardTableUsingLargePages + HEAP_REGION_SIZE, true, true);
        testVM(heapSizeForCardTableUsingLargePages - HEAP_REGION_SIZE, false, true);
    }

    // Minimum heap requirement to get large pages for bitmaps is 128M heap. This seems okay to test
    // everywhere.
    final int bitmapTranslationFactor = 8 * 8; // ObjectAlignmentInBytes * BitsPerByte
    final long heapSizeForBitmapUsingLargePages = largePageSize * bitmapTranslationFactor;

    testVM(heapSizeForBitmapUsingLargePages, false, true);
    testVM(heapSizeForBitmapUsingLargePages + HEAP_REGION_SIZE, false, true);
    testVM(heapSizeForBitmapUsingLargePages - HEAP_REGION_SIZE, false, false);
}
 
Example 12
Source File: ReadVMPageSize.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
  WhiteBox wb = WhiteBox.getWhiteBox();
  int pageSize = wb.getVMPageSize();
  if (pageSize < 0) {
    throw new Exception("pageSize < 0");
  } else {
    System.out.println("Page size = " + pageSize);
  }
}
 
Example 13
Source File: TestLargePageUseForAuxMemory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Size that a single card covers.
    final int cardSize = 512;
    WhiteBox wb = WhiteBox.getWhiteBox();
    smallPageSize = wb.getVMPageSize();
    largePageSize = wb.getVMLargePageSize();
    allocGranularity = wb.getVMAllocationGranularity();
    final long heapAlignment = lcm(cardSize * smallPageSize, largePageSize);

    if (largePageSize == 0) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform.");
        return;
    }
    if (largePageSize == smallPageSize) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform." +
                           "Small and large page size are the same.");
        return;
    }

    // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size).
    // 32 bit systems will have problems reserving such an amount of contiguous space, so skip the
    // test there.
    if (!Platform.is32bit()) {
        final long heapSizeForCardTableUsingLargePages = largePageSize * cardSize;
        final long heapSizeDiffForCardTable = Math.max(Math.max(allocGranularity * cardSize, HEAP_REGION_SIZE), largePageSize);

        Asserts.assertGT(heapSizeForCardTableUsingLargePages, heapSizeDiffForCardTable,
                         "To test we would require to use an invalid heap size");
        testVM("case1: card table and bitmap use large pages (barely)", heapSizeForCardTableUsingLargePages, true, true);
        testVM("case2: card table and bitmap use large pages (extra slack)", heapSizeForCardTableUsingLargePages + heapSizeDiffForCardTable, true, true);
        testVM("case3: only bitmap uses large pages (barely not)", heapSizeForCardTableUsingLargePages - heapSizeDiffForCardTable, false, true);
    }

    // Minimum heap requirement to get large pages for bitmaps is 128M heap. This seems okay to test
    // everywhere.
    final int bitmapTranslationFactor = 8 * 8; // ObjectAlignmentInBytes * BitsPerByte
    final long heapSizeForBitmapUsingLargePages = largePageSize * bitmapTranslationFactor;
    final long heapSizeDiffForBitmap = Math.max(Math.max(allocGranularity * bitmapTranslationFactor, HEAP_REGION_SIZE),
                                                Math.max(largePageSize, heapAlignment));

    Asserts.assertGT(heapSizeForBitmapUsingLargePages, heapSizeDiffForBitmap,
                     "To test we would require to use an invalid heap size");

    testVM("case4: only bitmap uses large pages (barely)", heapSizeForBitmapUsingLargePages, false, true);
    testVM("case5: only bitmap uses large pages (extra slack)", heapSizeForBitmapUsingLargePages + heapSizeDiffForBitmap, false, true);
    testVM("case6: nothing uses large pages (barely not)", heapSizeForBitmapUsingLargePages - heapSizeDiffForBitmap, false, false);
}