From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 24 16:20:23 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 986FB16A403 for ; Mon, 24 Apr 2006 16:20:23 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08C4243D49 for ; Mon, 24 Apr 2006 16:20:23 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k3OGKMRt059453 for ; Mon, 24 Apr 2006 16:20:22 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k3OGKMsA059452; Mon, 24 Apr 2006 16:20:22 GMT (envelope-from gnats) Resent-Date: Mon, 24 Apr 2006 16:20:22 GMT Resent-Message-Id: <200604241620.k3OGKMsA059452@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jost Boekemeier Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1BA0A16A404 for ; Mon, 24 Apr 2006 16:19:45 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id D2B1343D45 for ; Mon, 24 Apr 2006 16:19:44 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k3OGJiOi071635 for ; Mon, 24 Apr 2006 16:19:44 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id k3OGJiNI071632; Mon, 24 Apr 2006 16:19:44 GMT (envelope-from nobody) Message-Id: <200604241619.k3OGJiNI071632@www.freebsd.org> Date: Mon, 24 Apr 2006 16:19:44 GMT From: Jost Boekemeier To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: misc/96268: TCP socket performance drops by 3000% if packets are split at the first byte X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Apr 2006 16:20:23 -0000 >Number: 96268 >Category: misc >Synopsis: TCP socket performance drops by 3000% if packets are split at the first byte >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 24 16:20:22 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Jost Boekemeier >Release: 6.0 >Organization: >Environment: Unknown, should be reproduceable on all FreeBSD kernels >Description: See test below. The test is written in java, but it it likely a kernel bug. The time needed to complete Test#2 is independent of the architecture, for 200 iterations it needs ~20 seconds, for 40 interations ~40 seconds etc. It is not a configuration problem, for example socket waiting for a timeout, because the similar Test#1 completes in ~1.2 seconds. >How-To-Repeat: import java.io.*; import java.net.*; import java.util.*; public class TestServ implements Runnable { static final int SIZE=8192; static final int PORT=9767; private String getID(byte[] b, int n) { String str = (new String(b, 0, n)); //System.out.println(str); int idx = str.lastIndexOf("=", 0); idx+=2; int idx2= str.indexOf("\"", idx); return str.substring(idx, idx2); } public void run() { try { doRun(); } catch (Exception e) { e.printStackTrace(); } } public void doRun() throws Exception { int n; ServerSocket ss = new ServerSocket(PORT, 1, InetAddress.getByName("127.0.0.1")); while(true) { byte[] b = new byte[SIZE]; Socket s = ss.accept(); InputStream in = s.getInputStream(); in.read(b, 0, 1); //options n = in.read(b, 0, 51); OutputStream out = s.getOutputStream(); byte[] x = ("").getBytes(); out.write(x, 0, x.length); s.close(); } } private static void runTest1() throws Exception { for(int i=0; i<200; i++) { Socket s = new Socket("127.0.0.1", PORT); InputStream in = s.getInputStream(); OutputStream out = s.getOutputStream(); out.write(("@").getBytes()); byte[] b = new byte[1024]; in.read(b); s.close(); } } // same as above, buf send two packets private static void runTest2() throws Exception { for(int i=0; i<200; i++) { Socket s = new Socket("127.0.0.1", PORT); InputStream in = s.getInputStream(); OutputStream out = s.getOutputStream(); out.write('@'); out.write(("").getBytes()); byte[] b = new byte[1024]; in.read(b); s.close(); } } public static void main(String _s[]) throws Exception { Thread t = new Thread(new TestServ()); t.start(); Thread.sleep(100); long T1 = System.currentTimeMillis(); runTest1(); long T2 = System.currentTimeMillis(); runTest2(); long T3 = System.currentTimeMillis(); System.out.println("The following test demonstrates a bug in the FreeBSD 6 kernel:"); System.out.println("Both tests transfer the same amount of data."); System.out.println("But the second test splits the packet after the first byte."); System.out.println("Test1: "+(T2-T1)); System.out.println("Test2: "+(T3-T2)); short c = (short)((T3-T2)/(T2-T1)); System.out.println("Test2/Test1: "+c); if(c>1) { System.out.println("Test failed"); System.exit(1); } System.out.println("Test okay"); System.exit(0); } } >Fix: >Release-Note: >Audit-Trail: >Unformatted: