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

Solaris pipe-io of child process is very slow

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • sparc
    • solaris_2.5.1



      Name: dbT83986 Date: 07/01/99


      my project used pipe communication of process.
      SOLARIS PIPE-IO is very slow. but, windows is no problem.
      this problem confirmed JDK 1.1.3 and 1.2.0.
      may be, this problem exist all version of 1.1.x and 1.2.x

      ****************************************************************
      Test Program Source
      ****************************************************************
      //
      // pipe communication test program.
      // run: java pipe.Test
      //
      package pipe;

      import java.io.*;

      public class Test {

        void Client() {
          System.out.println("pipe test program");
          try {
            String command = "java -classpath " + System.getProperty("java.class.path") + " " + getClass().getName() + " -S";
            Runtime rt = Runtime.getRuntime();
            Process ps = rt.exec(command);
            InputStream in = ps.getInputStream();
            OutputStream out = ps.getOutputStream();
            System.out.println("wait for pipe server to ready ...");
            synchronized (this) {
              while (in.available() == 0)
                wait(1000);
            }
            long ct = System.currentTimeMillis();
            while (true) {
              int c = in.read();
              out.write(c);
              out.flush();
              if (c == 0)
                break;
              System.out.println("read data = " + c + " (" + (System.currentTimeMillis() - ct) + ")");
            }
            ct = System.currentTimeMillis() - ct;
            System.out.println("pipe communication time = " + ct + " msec");
          }
          catch (Exception e) {
            e.printStackTrace();
          }
          try { System.in.read(); } catch (Exception e) {}
        }

        void Server() {
          try {
            for (int c = 1; c <= 10; c++) {
              System.out.write(c);
              System.out.flush();
              if (System.in.read() != c)
                break;
            }
          }
          catch (Exception e) {
            e.printStackTrace();
          }
          System.out.write(0);
          System.out.flush();
          try { System.in.read(); } catch (Exception e) {}
        }

        public static void main(String[] args) {
          Test test = new Test();
          if ((args.length > 0) && args[0].equals("-S"))
            test.Server();
          else
            test.Client();
        }
      }

      ****************************************************************
      [Result of Windows] (same 1.1.6 and 1.2.1)
      ****************************************************************
      pipe test program
      wait for pipe server to ready ...
      read data = 1 (0)
      read data = 2 (0)
      read data = 3 (0)
      read data = 4 (0)
      read data = 5 (0)
      read data = 6 (0)
      read data = 7 (0)
      read data = 8 (0)
      read data = 9 (60)
      read data = 10 (60)
      pipe communication time = 60 msec

      ****************************************************************
      [Result of Soralis] (same 1.1.3 and 1.2.0)
      ****************************************************************
      pipe test program
      wait for pipe server to ready ...
      read data = 1 (2)
      read data = 2 (1010) problem. ??? 1 second delayed. ???
      read data = 3 (2020) problem. ??? 1 second delayed. ???
      read data = 4 (3030) problem. ??? ... ???
      read data = 5 (4040)
      read data = 6 (5050)
      read data = 7 (6060)
      read data = 8 (7070)
      read data = 9 (8080)
      read data = 10 (9090)
      pipe communication time = 10100 msec

      ****************************************************************
      [Result of Solaris: JDK Core Class to Update] (1.2.0)
      ****************************************************************
      pipe test program
      wait for pipe server to ready ...
      read data = 1 (2)
      read data = 2 (7)
      read data = 3 (8)
      read data = 4 (9)
      read data = 5 (10)
      read data = 6 (11)
      read data = 7 (12)
      read data = 8 (14)
      read data = 9 (15)
      read data = 10 (16)
      pipe communication time = 17 msec

      ****************************************************************
      [Update Point of Solaris JDK Core Class] (1.2.0)
      ****************************************************************
      Source: src/solaris/classes/java/lang/UNIXProcess.java

      class ProcessInputStream extends PipedInputStream implements Runnable {
        public void run() {
          ...
          while (true) {
            try {
              if ((nread = ins.read(buf)) < 0)
                break;
              outs.write(buf, 0, nread);
              ////////////////////////////////////////////////////////
              // point of update.
              // this flush operation are nothing in orignal source.
              outs.flush();
              ////////////////////////////////////////////////////////
            } catch (IOException e) {
              break;
            }
          }
          ...
        }
      }
      (Review ID: 85064)
      ======================================================================

            nsanjeevsunw Naveen Sanjeeva (Inactive)
            dblairsunw Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: