[JENKINS-22354]

Avoid using RemoteInputStream that's inherently unsuitable for large
"read till EOF" read workload.
code to measure the performance
[JENKINS-22354]

With cea15ea5cb11dc9cdafb2caa44d18c4c350017fe, a previously hidden dead
lock has surfaced. This change solves that problem.

The dead lock is caused if the written mark is propagated back to master before the SendMark method returns.

This is because the channel from Maven process piggy backs on I/O pipe
writer of master<->slave channel as a tunnel.

In the dead lock below, thread #10 holds the 'markCountLock' and waiting
for the response from SendMark task, which is supposed to come back from
master<->maven channel.

But this response is clogged waiting to be read by IO writer thread
(thread #11 below), which in turn blocks trying to acquire the
markCountLock.

"Computer.threadPoolForRemoting [#11] : IO ID=116 : seq#=115" daemon prio=10 tid=0x00007f29f0035800 nid=0x69d2 waiting for monitor entry [0x00007f29f68c5000]
   java.lang.Thread.State: BLOCKED (on object monitor)
        at hudson.maven.SplittableBuildListener$2.onMarkFound(SplittableBuildListener.java:118)
        - waiting to lock <0x000000078b996388> (a java.lang.Object)
        at jenkins.util.MarkFindingOutputStream.write(MarkFindingOutputStream.java:59)
        at java.io.PrintStream.write(PrintStream.java:447)
        - locked <0x000000078b995e58> (a java.io.PrintStream)
        at hudson.util.DelegatingOutputStream.write(DelegatingOutputStream.java:56)
        at hudson.tasks._maven.MavenConsoleAnnotator.eol(MavenConsoleAnnotator.java:75)
        at hudson.console.LineTransformationOutputStream.eol(LineTransformationOutputStream.java:60)
        at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:56)
        at hudson.console.LineTransformationOutputStream.write(LineTransformationOutputStream.java:74)
        at java.io.OutputStream.write(OutputStream.java:75)
        at hudson.util.DelegatingOutputStream.write(DelegatingOutputStream.java:51)
        at hudson.remoting.ProxyOutputStream$Chunk$1.run(ProxyOutputStream.java:250)
        at hudson.remoting.PipeWriter$1.run(PipeWriter.java:158)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:111)
        at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
        at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:701)

"Computer.threadPoolForRemoting [#10] for Channel to Maven [java, -cp, /tmp/slave1/maven3-agent.jar:/usr/maven3/boot/plexus-classworlds-2.4.jar, org.jvnet.hudson.maven3.agent.Maven3Main, /usr/maven3, /tmp/slave1/slave.jar, /tmp/slave1/maven3-interceptor.jar, /tmp/slave1/maven3-interceptor-commons.jar, 54343] / waiting for hudson.slaves.Channels$1@5cb62a81:Channel to Maven [java, -cp, /tmp/slave1/maven3-agent.jar:/usr/maven3/boot/plexus-classworlds-2.4.jar, org.jvnet.hudson.maven3.agent.Maven3Main, /usr/maven3, /tmp/slave1/slave.jar, /tmp/slave1/maven3-interceptor.jar, /tmp/slave1/maven3-interceptor-commons.jar, 54343]" daemon prio=10 tid=0x00007f29f0033000 nid=0x6171 in Object.wait() [0x00007f29f62be000]
        at hudson.remoting.Request.call(Request.java:146)
        - locked <0x00000007da297040> (a hudson.remoting.UserRequest)
        at hudson.remoting.Channel.call(Channel.java:722)
        at hudson.maven.SplittableBuildListener.synchronizeOnMark(SplittableBuildListener.java:145)
        - locked <0x000000078b996388> (a java.lang.Object)
        at hudson.maven.MavenBuild$ProxyImpl2.sync(MavenBuild.java:606)
        at hudson.maven.MavenBuild$ProxyImpl2.start(MavenBuild.java:556)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:622)
        at hudson.model.Executor$1.call(Executor.java:559)
        at hudson.util.InterceptingProxy$1.invoke(InterceptingProxy.java:23)
        at com.sun.proxy.$Proxy44.start(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:622)
        at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:299)
        at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:280)