diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index e50577e431..c7c1bfad2b 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -1317,7 +1317,14 @@ public final class FilePath implements Serializable { byte[] buf = new byte[8192]; - TarOutputStream tar = new TarOutputStream(new BufferedOutputStream(out)); + TarOutputStream tar = new TarOutputStream(new BufferedOutputStream(out) { + // TarOutputStream uses TarBuffer internally, + // which flushes the stream for each block. this creates unnecessary + // data stream fragmentation, and flush request to a remote, which slows things down. + public void flush() throws IOException { + // so don't do anything in flush + } + }); tar.setLongFileMode(TarOutputStream.LONGFILE_GNU); String[] files; if(baseDir.exists()) { diff --git a/remoting/src/main/java/hudson/remoting/Command.java b/remoting/src/main/java/hudson/remoting/Command.java index f8acc46066..a0112331be 100644 --- a/remoting/src/main/java/hudson/remoting/Command.java +++ b/remoting/src/main/java/hudson/remoting/Command.java @@ -44,7 +44,20 @@ abstract class Command implements Serializable { protected Command() { - this.createdAt = new Source(); + this(true); + } + + /** + * @param recordCreatedAt + * If false, skip the recording of where the command is created. This makes the trouble-shooting + * and cause/effect correlation hard in case of a failure, but it will reduce the amount of the data + * transferred. + */ + protected Command(boolean recordCreatedAt) { + if(recordCreatedAt) + this.createdAt = new Source(); + else + this.createdAt = null; } /** diff --git a/remoting/src/main/java/hudson/remoting/ProxyOutputStream.java b/remoting/src/main/java/hudson/remoting/ProxyOutputStream.java index 70b31b346c..d7ceee650d 100644 --- a/remoting/src/main/java/hudson/remoting/ProxyOutputStream.java +++ b/remoting/src/main/java/hudson/remoting/ProxyOutputStream.java @@ -150,6 +150,10 @@ final class ProxyOutputStream extends OutputStream { private final byte[] buf; public Chunk(int oid, byte[] buf) { + // to improve the performance when a channel is used purely as a pipe, + // don't record the stack trace. On FilePath.writeToTar case, the stack trace and the OOS header + // takes up about 1.5K. + super(false); this.oid = oid; this.buf = buf; } @@ -177,6 +181,7 @@ final class ProxyOutputStream extends OutputStream { private final int oid; public Flush(int oid) { + super(false); this.oid = oid; }