0

Calling a particular executable (Jadeo) via commons-exec (using pipes for it's I/O) is causing massive CPU usage (over 30x) compared to calling same executable from the terminal. Idle wakeups are huge.

I've talked to the developer of the executable and they suggest that using blocking I/O may be causing these excessive wake ups.

Is there a way to use non blocking I/O with Apache commons-exec instead?

Or is there another library that uses non blocking I/O?

John Baker
  • 89
  • 12
  • blocking I/O should be fine provided it is buffered. The number of wakes is about the same for block and non-bocking. Non-blocking allows you to share many of these with one thread. – Peter Lawrey Nov 26 '18 at 20:04
  • I think it is all buffered. Sending happens like this. Is this fine? PipedInputStream sendIn = new PipedInputStream; PipedOutputStream sendOut = new PipedOutputStream(sendIn); send = new PrintWriter(new OutputStreamWriter(sendOut), true); That is used to create the PumpStreamHandler. – John Baker Nov 26 '18 at 22:08
  • If it's buffered then you will already be doing a minimum of systems calls and "wake ups" – Peter Lawrey Nov 26 '18 at 22:25
  • Except it's definitely not. The difference is huge. I really don't understand why doing it manually from the terminal would perform way better compared to doing same from java streams. – John Baker Nov 26 '18 at 23:39
  • I would expect any console to use blocking IO. You should be able to compare them with strace on both programs. – Peter Lawrey Nov 26 '18 at 23:40
  • Curiously when hooking up to System.in and System.out the problem doesn't occur. So there must be something going on with using the Piped streams. Will try your strace/dtrace idea next. – John Baker Nov 27 '18 at 12:25
  • After a bit of reading around it seems that java Piped streams are not very well designed and the common recommendation is to avoid them if using different threads at each end, which would be the case with a process. So what is the alternative? To use callbacks? – John Baker Nov 27 '18 at 12:58

0 Answers0