Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lii7F-0005Ot-HL for pgsql-bugs@arkaria.postgresql.org; Mon, 17 May 2021 18:37:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lii7C-0000mc-SN for pgsql-bugs@arkaria.postgresql.org; Mon, 17 May 2021 18:37:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lihqF-0003fz-3X for pgsql-bugs@lists.postgresql.org; Mon, 17 May 2021 18:19:47 +0000 Received: from aserp2130.oracle.com ([141.146.126.79]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lihqC-0006Pj-2g for pgsql-bugs@lists.postgresql.org; Mon, 17 May 2021 18:19:46 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14HIEkHN031591; Mon, 17 May 2021 18:19:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=jSiIfz3CbiHftNRfbCT8F6ZYNo+io/LfsfxBoXNyw8g=; b=C60z+fJBuftpxLKas52DuezXrgJ9xumkYO+G8GoYK4JCp+GGfnUx385Ajfp/OD9nNNU0 2Z5RJl6fA5BEdwxaxa5KwVEn7B78Astgy2RAFrheSn3CZZ0dkfCOBaMI5b25ZIG7M2Bl AxXj3cPqtz45cbSPsKxaKMYrMW3YU19Xyq8AkxroMXm1hVioMtbBDR11U4380Bi9yJqc ld1DorlHfaIojoPnp0KMfUnWBKO1tDiaFr/Llzw3klAKvHNm7lczLzrLpckQ7hKLHb/E OdvgvKD+JOB5MnPQKfFHGMS/93ckfM6qOFWINLDkd6p2I8Itvt04IUpF2OfJI/Xdcjh/ 3w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 38j3tbc63f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 May 2021 18:19:36 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 14HIGBtj079484; Mon, 17 May 2021 18:19:36 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by aserp3030.oracle.com with ESMTP id 38j4bbc85c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 May 2021 18:19:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yh2TK6CWhgMpd/g03XZT8v7PdtpEZDnJiqXb0pfqK5mb0uCdeuJhvd+LkY8XhROD8XSUBNOuKRNQeIKvCcYs0/VCo1Io7iY7NYHNNIu7Un1GMPXXPJY2sFY3R7QGytdRnhHL9CJ/Kta3uJNMzxCpggTvTskbMg/tT8ZFi9W6rcteRyGWdDZXZ3LlHxYtqibFk4GDfaqbOfntOY9PZOMxd9Bvs73b5TP96Mb6AQd1QtDlz0dY+KhqOiW+Vp9JOdPRcgechkC0gSndgP/2m/LVDROgD2aLVH6flaA+6LzPCVBGam4cszlSmqwELp5yMaYZHMvtCe7zSCc3GcaA59ur5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jSiIfz3CbiHftNRfbCT8F6ZYNo+io/LfsfxBoXNyw8g=; b=SQb1DfqW+WUDMQVYCAAMrPSXicRY2WjGAOAP5wdaD23xTTaQD9PzJ8oyyy2/vfd/+odcDXAyHfDo1fHPwrvISlqymSWnTlCzGUsODL9ntFsgxUUj8SH9lswms5tIh59BLE6axg7Fwk7vT6ji1FrANtZn0MYbwxSDhhoCZFksUV1mm2P61rYrvHaHHhbTw+H12IYmVdo7CcO9kQtICvB9PcosNa5/6Ay+huewWTtixNBwe0hc+ITVJI8FHAFF9OMMuGx3rjPbDZIwrLOKnIWZ2YCUA8lZ/ZUlPTpIgFLJUuxnrla+GET+S06tPThLDXLzoN1DOs6FEyrZFvEGy7HYmw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jSiIfz3CbiHftNRfbCT8F6ZYNo+io/LfsfxBoXNyw8g=; b=RAwAl8a++3OeaJDX82QdOX7sorh46KlmhQpyMD8IdIJvD4Vf3RZW+nUJx0C22llCghRulXgYbRW9eOYyTgvZX56knNXJPL9X+AJ7Ao1N/QPUaoL3AFkDfjBjhSPDnkV4bCMO7i8AYhjaBxTfg3PJpX4qNy7QPGlBr2uYtgzo5dM= Authentication-Results: lists.postgresql.org; dkim=none (message not signed) header.d=none;lists.postgresql.org; dmarc=none action=none header.from=oracle.com; Received: from SJ0PR10MB4446.namprd10.prod.outlook.com (2603:10b6:a03:2d9::13) by BY5PR10MB3778.namprd10.prod.outlook.com (2603:10b6:a03:1f5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.28; Mon, 17 May 2021 18:19:34 +0000 Received: from SJ0PR10MB4446.namprd10.prod.outlook.com ([fe80::285b:1ab4:80a5:818]) by SJ0PR10MB4446.namprd10.prod.outlook.com ([fe80::285b:1ab4:80a5:818%3]) with mapi id 15.20.4129.031; Mon, 17 May 2021 18:19:33 +0000 Subject: Re: [External] : Re: BUG #17005: Enhancement request: Improve walsender throughput by aggregating multiple messages in one send To: Andres Freund , Yura Sokolov Cc: pgsql-bugs@lists.postgresql.org References: <17005-3e1030784d5440c4@postgresql.org> <20210516224413.xitbilinlyrlt42m@alap3.anarazel.de> <20210517162753.lmhmnfd72bn3nfms@alap3.anarazel.de> From: Rony Kurniawan Message-ID: <3f60a4c4-71df-bce0-d743-ec06ff1b08fe@oracle.com> Date: Mon, 17 May 2021 11:19:31 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 In-Reply-To: <20210517162753.lmhmnfd72bn3nfms@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [2601:643:c100:76b0:f552:f87f:10a3:ad33] X-ClientProxiedBy: BY5PR17CA0009.namprd17.prod.outlook.com (2603:10b6:a03:1b8::22) To SJ0PR10MB4446.namprd10.prod.outlook.com (2603:10b6:a03:2d9::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2601:643:c100:76b0:f552:f87f:10a3:ad33] (2601:643:c100:76b0:f552:f87f:10a3:ad33) by BY5PR17CA0009.namprd17.prod.outlook.com (2603:10b6:a03:1b8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.32 via Frontend Transport; Mon, 17 May 2021 18:19:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a00e4cd1-4079-44c0-6117-08d919605244 X-MS-TrafficTypeDiagnostic: BY5PR10MB3778: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1jQlkyTvl0EFmM9QQQXzMOPM6QGgwqZ5BJgrY+L8aM29Lxkf3boO197hRBphU9Zry4QeDLjF/rZMerI0DdG6SDaUrjOrtGAjPXlPd68rJhgk8q7DLatuTWALTLANvXcQ5r6s/kpVUStj94mk7LaRAlizGpXI4uxuhScZsySwrFYoCrNSKRpgiTECG197/jpJrpAluyCwEIoOX4wFxl4mfLit3+Jr1EGCO+lMp/SxBPHPXdQ1jwFQzmj8BVVUxOzBYx9uVsPx93velX/Nd0AWKngl0ZHEm7ny9Wk5G80xVHZ87Gr4FH+drfR14+ZJVNcEkJz40eoY84SeMlcWu3tbmVYK2WdVH1HLOiGXV16pjdRKlQOChsescVPM5dIme9H+ffyQqzZh0zOrbLvji1gUjqgCMRv/FSLWnlk/EkrGjWkLaKls3rfodYhx0RXQc/7+AoWuv2n5tXM8BFpcyO54r4IHPtQybruv9hqfd+BldIZomb5dlj0jc5vCG0oNPZ3O+Dl4/5r43CgZ1kJRlslNl6B4wNgFZmyNXAtpIHUrJvCrPr08ts89R9Zo+Q6EVYgMz2YY4RSlQVLi6zImGPL3q2+8zY6nbZ+kCTkF1/0NAgFDjgRWwAkjTYsubfGXQC/IUSN6f+GRy/ZZt6/yr9vhdviHRRGpBtxc5lN5MhQ6Z0D+ffv1VPfKif/NKZPwoyN+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4446.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(39860400002)(136003)(396003)(376002)(346002)(366004)(6486002)(8936002)(83380400001)(53546011)(8676002)(110136005)(31696002)(44832011)(2616005)(66556008)(38100700002)(36756003)(5660300002)(2906002)(31686004)(4326008)(15650500001)(186003)(16526019)(66946007)(478600001)(86362001)(66476007)(316002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?SkN4STkyV3pvY1ZXQUhuQW1zb3JyNlZBaEgraExvSGo0TWNMVFdFSlNxVmR2?= =?utf-8?B?cm40OTdiKytDSjZnN2t5UnZuODhsUGxvOFVhMGw4dm82dENRN2pDaEdFR2hH?= =?utf-8?B?VTVSQUpsSmxpVkwyUWk0dzJ5dldPMWxRalFvN00rNUEvL2p1MGJyamQ2OEMy?= =?utf-8?B?a055S1pPWE90VzZZZ2FoUGJUZ0RjSUR2c1dKVDJObExPMHBXYmNXNjhnYlVa?= =?utf-8?B?L2JIUFlNY1hGckM5RHZ3OGRyVkhQV2EvdnNvSkEwL3JqNnRHMnVGTmdOdVc0?= =?utf-8?B?YmhPR2ZuVFNVLzNiai9IblUzVXljdE1FdkFNbmpMQnFQTEtxVWl1QWxVTkds?= =?utf-8?B?K1BLNTloTkg5WlFYbjhLeTZlUEMwalVQZWFiSVlGcGM3TFl5azVEd2k2dEo1?= =?utf-8?B?VmpnaTVFd0ZETEVIbW40MitmZzk1WXIwbVd4RmU1cFgyOEZyMjY5bmpQLzhN?= =?utf-8?B?ZE9uUXdyUXp3azY2RTU1azBDMkJwaGFuSHptb05wTVJ1NzIyNHBVNUFTZENz?= =?utf-8?B?cUlmS1VxU2ZQSUNocEp6dzZFd3QvSlZGbGszeldlYXdTbEsrWHF5eVg1MXBt?= =?utf-8?B?YWlDMnBZdEVPeThIVU5XUXhWZWdEQ1d5S1YwaFBIQWlIRkR4Ym82SHpobXY2?= =?utf-8?B?T2hKU1FyZlFTcmgwbDRyL3hWQTRkSzVpVWtyd01pdmlIMXM5K3lKTVROcG8x?= =?utf-8?B?QnVxMmxvSDZVRzFManV0bzN5VG9SU2hYVnk3Y2hSMmxwSDdnSzJoOWsyakpR?= =?utf-8?B?SXVqa0xEWUsyYjhWNmFIQTlBVDI5NnRWM3hPZG5yVCtvbVloTXBaaWdl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dmNaVlZVUjdDY0VVTzNZ?= =?utf-8?B?UTNPdnpsVDdLbmQ3UlNmOEc4VVdjWEl4bjdQVFB1bXRkNWZBdkZzQ1RNZTVi?= =?utf-8?B?dlVPN2hHL1V2akZaSFpoYTVWdFhocUVHeHVOWVJHaUpYeGZqNllFYjJQMGww?= =?utf-8?Q?Kmq2OrwhJmOvh?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a00e4cd1-4079-44c0-6117-08d919605244 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4446.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2021 18:19:33.9066 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T1t59vdAJ2F1rrq7QKWJ0/ne0pslkeJ22Fjc5dDtOcfDV26VckIoK06rL2/PZYanHeLy5dJ5t0g81mtvT3x0NzLq5AAWQkTzRu/FGgYVG38= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3778 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9987 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 spamscore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=591 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105170127 X-Proofpoint-ORIG-GUID: 7bM9qcHE1wwqfSS8zmyQJOyEpfpxQi_c X-Proofpoint-GUID: 7bM9qcHE1wwqfSS8zmyQJOyEpfpxQi_c X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9987 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 malwarescore=0 spamscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=844 mlxscore=0 impostorscore=0 adultscore=0 clxscore=1011 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105170127 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 5/17/2021 9:27 AM, Andres Freund wrote: > Hi, > > On 2021-05-17 16:21:36 +0300, Yura Sokolov wrote: >> Andres Freund писал 2021-05-17 01:44: >>> What kind of network is this? I would have expected that if the network >>> can't keep up the small sends would end up getting aggregated into >>> larger packets anyway? Are you hitting a PPS limit due to the small >>> packages, but not yet the throughput limit? >> I believe the reason is more in sys-call and kernel cpu time overhead than >> in network throughput. Especially in this "after meltdown+spectre" time. > Well, enabling Nagle's wouldn't change anything if the issue is just > syscall and not network overhead. Yet the ask was to enable Nagle's... > > Greetings, > > Andres Freun The networks that I tested were gigabits and docker (local). With TCP_NODELAY enabled, the only time small sends would be aggregated is by auto corking in tcp/ip when there is network congestion. But as you can see from the tcpdump output the messages are in individual packet therefore there is no aggregation and no network congestion. There is network overhead in both sender and receiver like tcp/ip header, number of skb, ethernet tx/rx descriptors, and interrupts. Also syscall overhead in pg_recvlogical where for one insert in the example requires 3 recv() calls to read BEGIN, INSERT, COMMIT messages instead of one recv() to read all three messages when Nagle's is enabled. This syscall overhead is the same in transaction case with multiple changes where each change is one recv(). I agree that in some cases low latency in replication is required, but there are also cases where high throughput is desired especially when the standby server is behind due to outage where latency doesn't exist. I experimented by simply disabling TCP_NODELAY in walsender.c:StartLogicalReplication() and the throughput went up by 60%. This is just a prove of concept that some kind of message aggregations would result to higher throughput. Thank you, Rony