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

Add API to check if event will be committed before writing all the data of the event

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 8u60, 9
    • hotspot
    • None
    • jfr

      Consider these events in the socket code:

      int read(byte b[], int off, int length, int timeout) throws IOException {
          if (!VMJFR.socketReadToken.isEnabled()) {
              return read(b, off, length, timeout);
          }
          SocketReadEvent event = new SocketReadEvent(VMJFR.socketReadToken);
          int bytesRead = -1;
          try {
              event.begin();
              bytesRead = read(b, off, length, timeout);
          } finally {
              String hostString = impl.address.toString();
              int delimiterIndex = hostString.lastIndexOf('/');

              event.host = hostString.substring(0, delimiterIndex);
              event.address = hostString.substring(delimiterIndex + 1);
              event.port = impl.port;
              event.bytesRead = bytesRead;
              event.timeout = timeout;

              event.commit();
          }
          return bytesRead;
      }

      Before calling address.toString and doing manipulations of the string, it would be good if we could check if the duration of the event was above the threshold. That would make the cost of the instrumentation lower for short-duration events.

      (Suggested by Tony Vlatas)

            Unassigned Unassigned
            sla Staffan Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: