NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/60443: ftp ASCII transfers are too slow
The following reply was made to PR bin/60443; it has been noted by GNATS.
From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/60443: ftp ASCII transfers are too slow
Date: Mon, 13 Jul 2026 01:36:03 +0000 (UTC)
On Sun, 12 Jul 2026, Michael van Elst via gnats wrote:
> gnats-admin%NetBSD.org@localhost ("rvp%SDF.ORG@localhost via gnats") writes:
>
> >FTP ASCII transfers seem to interact badly with Nagle's algorithm
> >because ASCII xfers rely on libc's BUFSIZ (1KB) internal buffer.
>
> I doubt that Nagle's algorithm has any effect here. After all,
> it would just improve throughput at the cost of latency.
>
> What you see is the higher overhead from stdio.
>
Right, of course stdio plays a part, but because, I think, of the 1KB at-a-time
writes. And, I reached for an interaction with Nagle because:
a) 200ms packet delay (see tcpdump log below).
b) situation improved if I used a 4KB stdio buffer.
c) things also zip along if I set TCP_NODELAY on the xfer sockets (see log).
> ftp> get in.txt
> local: in.txt remote: in.txt
> 229 Entering Extended Passive Mode (|||62337|)
> 150 Opening ASCII mode data connection for 'in.txt' (306788817 bytes).
> 226 Transfer complete.
> 312122680 bytes received in 00:08 (34.99 MiB/s)
> [...]
> In all cases the ftpd was CPU limited (on a 1.6GHz Atom N3150).
>
I get better speeds with both my patches on an
"Intel(R) Core(TM) i3-1005G1 CPU @ 1.20GHz"
Otherwise, with a large enough file, ASCII xfers eventually just crawls--like
settling on ~70KB/sec xfer rates.
I don't know how you're getting 35MB/sec w/o any tweaking. Michael, can you try
with both server and client on localhost like I did?
-RVP
---START tcpdump output---
04:42:56.720934 IP6 ::1.65426 > ::1.21: Flags [S], seq 62646337, win 32768, options [mss 33564,nop,wscale 3,sackOK,TS val 1 ecr 0], length 0
04:42:56.720954 IP6 ::1.21 > ::1.65426: Flags [S.], seq 59295266, ack 62646338, win 32768, options [mss 33564,nop,wscale 3,sackOK,TS val 1 ecr 1], length 0
04:42:56.720965 IP6 ::1.65426 > ::1.21: Flags [.], ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 0
04:42:56.726401 IP6 ::1.21 > ::1.65426: Flags [P.], seq 1:57, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 56: FTP: 220 localhost FTP server (NetBSD-ftpd 20230930) ready.
04:42:56.925619 IP6 ::1.65426 > ::1.21: Flags [.], ack 57, win 4096, options [nop,nop,TS val 1 ecr 1], length 0
04:42:58.819652 IP6 ::1.65426 > ::1.21: Flags [P.], seq 1:11, ack 57, win 4096, options [nop,nop,TS val 5 ecr 1], length 10: FTP: USER rvp
04:42:58.831280 IP6 ::1.21 > ::1.65426: Flags [P.], seq 57:122, ack 11, win 4096, options [nop,nop,TS val 5 ecr 5], length 65: FTP: 331 User rvp accepted, provide password for rvp@CoreBook.local.
04:42:59.030621 IP6 ::1.65426 > ::1.21: Flags [.], ack 122, win 4096, options [nop,nop,TS val 6 ecr 5], length 0
04:43:01.603623 IP6 ::1.65426 > ::1.21: Flags [P.], seq 11:26, ack 122, win 4096, options [nop,nop,TS val 11 ecr 5], length 15: FTP: PASS bh33ns11
04:43:01.692169 IP6 ::1.21 > ::1.65426: Flags [P.], seq 122:128, ack 26, win 4096, options [nop,nop,TS val 11 ecr 11], length 6: FTP: 230-
04:43:01.891621 IP6 ::1.65426 > ::1.21: Flags [.], ack 128, win 4096, options [nop,nop,TS val 11 ecr 11], length 0
04:43:01.891652 IP6 ::1.21 > ::1.65426: Flags [P.], seq 128:475, ack 26, win 4096, options [nop,nop,TS val 11 ecr 11], length 347: FTP: NetBSD 11.99.4 (COREBOOK_DIAG) #0: Sun Dec 7 04:08:07 UTC 2025
04:43:01.893119 IP6 ::1.65426 > ::1.21: Flags [P.], seq 26:32, ack 475, win 4096, options [nop,nop,TS val 11 ecr 11], length 6: FTP: SYST
04:43:01.893271 IP6 ::1.21 > ::1.65426: Flags [P.], seq 475:524, ack 32, win 4096, options [nop,nop,TS val 11 ecr 11], length 49: FTP: 215 UNIX Type: L8 Version: NetBSD-ftpd 20230930
04:43:01.893540 IP6 ::1.65426 > ::1.21: Flags [P.], seq 32:38, ack 524, win 4096, options [nop,nop,TS val 11 ecr 11], length 6: FTP: FEAT
04:43:01.893600 IP6 ::1.21 > ::1.65426: Flags [P.], seq 524:548, ack 38, win 4096, options [nop,nop,TS val 11 ecr 11], length 24: FTP: 211-Features supported
04:43:02.093622 IP6 ::1.65426 > ::1.21: Flags [.], ack 548, win 4096, options [nop,nop,TS val 12 ecr 11], length 0
04:43:02.093655 IP6 ::1.21 > ::1.65426: Flags [P.], seq 548:634, ack 38, win 4096, options [nop,nop,TS val 12 ecr 12], length 86: FTP: MDTM
04:43:02.293636 IP6 ::1.65426 > ::1.21: Flags [.], ack 634, win 4096, options [nop,nop,TS val 12 ecr 12], length 0
04:43:07.003663 IP6 ::1.65426 > ::1.21: Flags [P.], seq 38:46, ack 634, win 4096, options [nop,nop,TS val 22 ecr 12], length 8: FTP: TYPE A
04:43:07.003726 IP6 ::1.21 > ::1.65426: Flags [P.], seq 634:654, ack 46, win 4096, options [nop,nop,TS val 22 ecr 22], length 20: FTP: 200 Type set to A.
04:43:07.203615 IP6 ::1.65426 > ::1.21: Flags [.], ack 654, win 4096, options [nop,nop,TS val 22 ecr 22], length 0
04:43:13.003639 IP6 ::1.65426 > ::1.21: Flags [P.], seq 46:56, ack 654, win 4096, options [nop,nop,TS val 34 ecr 22], length 10: FTP: CWD /tmp
04:43:13.003733 IP6 ::1.21 > ::1.65426: Flags [P.], seq 654:683, ack 56, win 4096, options [nop,nop,TS val 34 ecr 34], length 29: FTP: 250 CWD command successful.
04:43:13.203610 IP6 ::1.65426 > ::1.21: Flags [.], ack 683, win 4096, options [nop,nop,TS val 34 ecr 34], length 0
04:43:20.163696 IP6 ::1.65426 > ::1.21: Flags [P.], seq 56:69, ack 683, win 4096, options [nop,nop,TS val 48 ecr 34], length 13: FTP: SIZE in.txt
04:43:20.163806 IP6 ::1.21 > ::1.65426: Flags [P.], seq 683:721, ack 69, win 4096, options [nop,nop,TS val 48 ecr 48], length 38: FTP: 550 in.txt: file too large for SIZE.
04:43:20.164028 IP6 ::1.65426 > ::1.21: Flags [P.], seq 69:75, ack 721, win 4096, options [nop,nop,TS val 48 ecr 48], length 6: FTP: EPSV
04:43:20.164176 IP6 ::1.21 > ::1.65426: Flags [P.], seq 721:769, ack 75, win 4096, options [nop,nop,TS val 48 ecr 48], length 48: FTP: 229 Entering Extended Passive Mode (|||65425|)
04:43:20.164443 IP6 ::1.65424 > ::1.65425: Flags [S], seq 1247060766, win 32768, options [mss 33564,nop,wscale 3,sackOK,TS val 1 ecr 0], length 0
04:43:20.164458 IP6 ::1.65425 > ::1.65424: Flags [S.], seq 1239190458, ack 1247060767, win 32768, options [mss 33564,nop,wscale 3,sackOK,TS val 1 ecr 1], length 0
04:43:20.164469 IP6 ::1.65424 > ::1.65425: Flags [.], ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.164506 IP6 ::1.65426 > ::1.21: Flags [P.], seq 75:88, ack 769, win 4096, options [nop,nop,TS val 48 ecr 48], length 13: FTP: RETR in.txt
04:43:20.164641 IP6 ::1.21 > ::1.65426: Flags [P.], seq 769:841, ack 88, win 4096, options [nop,nop,TS val 48 ecr 48], length 72: FTP: 150 Opening ASCII mode data connection for 'in.txt' (476494829 bytes).
04:43:20.164731 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 1:1025, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 1024
04:43:20.165003 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 1025:17409, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 16384
04:43:20.165027 IP6 ::1.65424 > ::1.65425: Flags [.], ack 17409, win 1920, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.165045 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 17409:18433, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 1024
04:43:20.165292 IP6 ::1.65424 > ::1.65425: Flags [.], ack 18433, win 3840, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.165308 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 18433:34817, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 16384
04:43:20.165529 IP6 ::1.65424 > ::1.65425: Flags [.], ack 34817, win 3840, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.165547 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 34817:46081, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 11264
04:43:20.165783 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 46081:62465, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 16384
04:43:20.165808 IP6 ::1.65424 > ::1.65425: Flags [.], ack 62465, win 2048, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.165834 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 62465:63489, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 1024
04:43:20.166023 IP6 ::1.65424 > ::1.65425: Flags [.], ack 63489, win 3968, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.166038 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 63489:74753, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 11264
04:43:20.166267 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 74753:91137, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 16384
04:43:20.166293 IP6 ::1.65424 > ::1.65425: Flags [.], ack 91137, win 2048, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.166311 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 91137:92161, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 1024
04:43:20.166463 IP6 ::1.65424 > ::1.65425: Flags [.], ack 92161, win 3968, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.166477 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 92161:103425, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 11264
04:43:20.166696 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 103425:119809, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 16384
04:43:20.166740 IP6 ::1.65424 > ::1.65425: Flags [.], ack 119809, win 2048, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.166761 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 119809:120833, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 1024
04:43:20.166920 IP6 ::1.65424 > ::1.65425: Flags [.], ack 120833, win 3968, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.166962 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 120833:135169, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 14336
04:43:20.364623 IP6 ::1.65426 > ::1.21: Flags [.], ack 841, win 4096, options [nop,nop,TS val 48 ecr 48], length 0
04:43:20.366588 IP6 ::1.65424 > ::1.65425: Flags [.], ack 135169, win 4096, options [nop,nop,TS val 1 ecr 1], length 0
04:43:20.366627 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 135169:148481, ack 1, win 4096, options [nop,nop,TS val 1 ecr 1], length 13312
04:43:20.566609 IP6 ::1.65424 > ::1.65425: Flags [.], ack 148481, win 4096, options [nop,nop,TS val 2 ecr 1], length 0
04:43:20.566638 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 148481:162817, ack 1, win 4096, options [nop,nop,TS val 2 ecr 2], length 14336
04:43:20.766615 IP6 ::1.65424 > ::1.65425: Flags [.], ack 162817, win 4096, options [nop,nop,TS val 2 ecr 2], length 0
04:43:20.766643 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 162817:176129, ack 1, win 4096, options [nop,nop,TS val 2 ecr 2], length 13312
04:43:20.966615 IP6 ::1.65424 > ::1.65425: Flags [.], ack 176129, win 4096, options [nop,nop,TS val 3 ecr 2], length 0
04:43:20.966643 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 176129:190465, ack 1, win 4096, options [nop,nop,TS val 3 ecr 3], length 14336
04:43:21.166615 IP6 ::1.65424 > ::1.65425: Flags [.], ack 190465, win 4096, options [nop,nop,TS val 3 ecr 3], length 0
04:43:21.166644 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 190465:203777, ack 1, win 4096, options [nop,nop,TS val 3 ecr 3], length 13312
04:43:21.366614 IP6 ::1.65424 > ::1.65425: Flags [.], ack 203777, win 4096, options [nop,nop,TS val 3 ecr 3], length 0
04:43:21.366641 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 203777:218113, ack 1, win 4096, options [nop,nop,TS val 3 ecr 3], length 14336
04:43:21.566615 IP6 ::1.65424 > ::1.65425: Flags [.], ack 218113, win 4096, options [nop,nop,TS val 4 ecr 3], length 0
04:43:21.566642 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 218113:231425, ack 1, win 4096, options [nop,nop,TS val 4 ecr 4], length 13312
04:43:21.766614 IP6 ::1.65424 > ::1.65425: Flags [.], ack 231425, win 4096, options [nop,nop,TS val 4 ecr 4], length 0
04:43:21.766643 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 231425:245761, ack 1, win 4096, options [nop,nop,TS val 4 ecr 4], length 14336
04:43:21.966614 IP6 ::1.65424 > ::1.65425: Flags [.], ack 245761, win 4096, options [nop,nop,TS val 5 ecr 4], length 0
04:43:21.966642 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 245761:259073, ack 1, win 4096, options [nop,nop,TS val 5 ecr 5], length 13312
04:43:22.166615 IP6 ::1.65424 > ::1.65425: Flags [.], ack 259073, win 4096, options [nop,nop,TS val 5 ecr 5], length 0
04:43:22.166643 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 259073:273409, ack 1, win 4096, options [nop,nop,TS val 5 ecr 5], length 14336
04:43:22.366622 IP6 ::1.65424 > ::1.65425: Flags [.], ack 273409, win 4096, options [nop,nop,TS val 5 ecr 5], length 0
04:43:22.366653 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 273409:286721, ack 1, win 4096, options [nop,nop,TS val 5 ecr 5], length 13312
04:43:22.566614 IP6 ::1.65424 > ::1.65425: Flags [.], ack 286721, win 4096, options [nop,nop,TS val 6 ecr 5], length 0
04:43:22.566643 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 286721:301057, ack 1, win 4096, options [nop,nop,TS val 6 ecr 6], length 14336
04:43:22.766617 IP6 ::1.65424 > ::1.65425: Flags [.], ack 301057, win 4096, options [nop,nop,TS val 6 ecr 6], length 0
04:43:22.766645 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 301057:314369, ack 1, win 4096, options [nop,nop,TS val 6 ecr 6], length 13312
04:43:22.966615 IP6 ::1.65424 > ::1.65425: Flags [.], ack 314369, win 4096, options [nop,nop,TS val 7 ecr 6], length 0
04:43:22.966644 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 314369:328705, ack 1, win 4096, options [nop,nop,TS val 7 ecr 7], length 14336
04:43:23.166607 IP6 ::1.65424 > ::1.65425: Flags [.], ack 328705, win 4096, options [nop,nop,TS val 7 ecr 7], length 0
04:43:23.166636 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 328705:342017, ack 1, win 4096, options [nop,nop,TS val 7 ecr 7], length 13312
04:43:23.366620 IP6 ::1.65424 > ::1.65425: Flags [.], ack 342017, win 4096, options [nop,nop,TS val 7 ecr 7], length 0
04:43:23.366660 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 342017:356353, ack 1, win 4096, options [nop,nop,TS val 7 ecr 7], length 14336
04:43:23.566617 IP6 ::1.65424 > ::1.65425: Flags [.], ack 356353, win 4096, options [nop,nop,TS val 8 ecr 7], length 0
04:43:23.566647 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 356353:369665, ack 1, win 4096, options [nop,nop,TS val 8 ecr 8], length 13312
04:43:23.766607 IP6 ::1.65424 > ::1.65425: Flags [.], ack 369665, win 4096, options [nop,nop,TS val 8 ecr 8], length 0
04:43:23.766636 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 369665:384001, ack 1, win 4096, options [nop,nop,TS val 8 ecr 8], length 14336
04:43:23.966614 IP6 ::1.65424 > ::1.65425: Flags [.], ack 384001, win 4096, options [nop,nop,TS val 9 ecr 8], length 0
04:43:23.966644 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 384001:397313, ack 1, win 4096, options [nop,nop,TS val 9 ecr 9], length 13312
04:43:24.166610 IP6 ::1.65424 > ::1.65425: Flags [.], ack 397313, win 4096, options [nop,nop,TS val 9 ecr 9], length 0
04:43:24.166639 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 397313:411649, ack 1, win 4096, options [nop,nop,TS val 9 ecr 9], length 14336
04:43:24.366616 IP6 ::1.65424 > ::1.65425: Flags [.], ack 411649, win 4096, options [nop,nop,TS val 9 ecr 9], length 0
04:43:24.366644 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 411649:424961, ack 1, win 4096, options [nop,nop,TS val 9 ecr 9], length 13312
04:43:24.566616 IP6 ::1.65424 > ::1.65425: Flags [.], ack 424961, win 4096, options [nop,nop,TS val 10 ecr 9], length 0
04:43:24.566645 IP6 ::1.65425 > ::1.65424: Flags [P.], seq 424961:439297, ack 1, win 4096, options [nop,nop,TS val 10 ecr 10], length 14336
---END tcpdump output---
---START TCP_NODELAY log---
$ /tmp/obj/usr/src/usr.bin/ftp/ftp localhost
Trying [::1]:21 ...
Connected to localhost.
220 localhost FTP server (NetBSD-ftpd 20230930) ready.
Name (localhost:rvp):
331 User rvp accepted, provide password for rvp@CoreBook.local.
Password:
230-
NetBSD 11.99.6 (GENERIC) #0: Fri Jul 10 21:54:30 UTC 2026
Welcome to NetBSD!
This is a development snapshot of NetBSD for testing -- user beware!
Bug reports: https://www.NetBSD.org/support/send-pr.html
Donations to the NetBSD Foundation: https://www.NetBSD.org/donations/
230 User rvp logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ascii
200 Type set to A.
ftp> progress
Progress bar off.
ftp> cd /tmp
250 CWD command successful.
ftp> get in.txt out.txt
local: out.txt remote: in.txt
229 Entering Extended Passive Mode (|||65505|)
150 Opening ASCII mode data connection for 'in.txt' (306795321 bytes).
226 Transfer complete.
312128515 bytes received in 00:02 (145.34 MiB/s)
ftp> put in.txt out.txt
local: in.txt remote: out.txt
229 Entering Extended Passive Mode (|||65503|)
150 Opening ASCII mode data connection for 'out.txt'.
226 Transfer complete.
312128515 bytes sent in 00:02 (116.24 MiB/s)
ftp> passive
Passive mode: off; fallback to active mode: off.
ftp> get in.txt out.txt
local: out.txt remote: in.txt
200 EPRT command successful.
150 Opening ASCII mode data connection for 'in.txt' (306795321 bytes).
226 Transfer complete.
312128515 bytes received in 00:02 (140.56 MiB/s)
ftp> put in.txt out.txt
local: in.txt remote: out.txt
200 EPRT command successful.
150 Opening ASCII mode data connection for 'out.txt'.
226 Transfer complete.
312128515 bytes sent in 00:01 (148.86 MiB/s)
ftp> ^D
221-
Data traffic for this session was 1237847672 bytes in 4 files.
Total traffic for this session was 1237849263 bytes in 4 transfers.
221 Thank you for using the FTP service on localhost.
$
---END TCP_NODELAY log---
Home |
Main Index |
Thread Index |
Old Index