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

(so) Suppress creation of SocketImpl in SocketAdaptor's constructor

    XMLWordPrintable

Details

    • b17
    • generic
    • generic
    • Verified

    Backports

      Description

        I'd like to propose the following change to JDK's sun.nio.ch.SocketAdaptor:

        In OpenJDK 6, 7 and 8, sun.nio.ch.SocketAdaptor is used to adapt a SocketChannelImpl to a java.net.Socket.

        A comment in the constructor of SocketAdaptor says "super will create a useless impl", but it actually doesn't have to. AFAICT the SocksSocketImpl instance created here really isn't used at all in SocketAdaptor, unless someone invokes non-public methods on java.net.Socket via reflection.

        At a glance, creating a useless SocksSocketImpl for every SocketAdaptor seems innocent. But that's not the case when the allocation rate/heap memory pressure is high. SocksSocketImpl has a finalizer (inherited from PlainSocketImpl), and when:
         * old generation is large
         * there are a lot of ready-to-die SocksSocketImpl instances
        these instances can be queued up in the finalizer queue, which increases the heap pressure.
         
        In one of our Hadoop NameNode nodes in production, excessive SocksSocketImpl instances had been causing frequent CMS collections + long reference processing pause. Using this patch helps side-steping the problem.

        see futher discussion on the nio-dev mailing list:
          http://mail.openjdk.java.net/pipermail/nio-dev/2011-November/001479.html

        Attachments

          Issue Links

            Activity

              People

                chegar Chris Hegarty
                chegar Chris Hegarty
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: