Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8283285

Consider adding fast path to ::malloc()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • tbd
    • 19
    • hotspot

      Currently ::malloc() can be called by many places, including

      ResourceObj::operator new()
      -> AllocateHeap()
        -> os::malloc(size_t, MEMFLAGS flags, const NativeCallStack&)

      Inside os::malloc(), many checks are done related to NMT (and after JDK-8253495, checking DumpSharedSpaces).

      During the review of JDK-8253495, it was suggested that we should try to reduce the overheads in os::malloc(). Maybe we should have a fast path when both NMT and DumpSharedSpaces, we should directly call into os::malloc() and avoid all the unnecessary checks.

      I.e., add something like this at various places??

      char* AllocateHeap(size_t size,
                         MEMFLAGS flags,
                         const NativeCallStack& stack,
                         AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) {

      + if (_os_malloc_fast_path) {
      + return os::fast_malloc(size);
      + }

        char* p = (char*) os::malloc(size, flags, stack);
        if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
          vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
        }
        return p;
      }

      (Note: it's unclear how much this would save.)

            Unassigned Unassigned
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: