Skip to main content


Okay, so this is going to cross some borders about where the issue might be... I'm not sure where the issue is, but hopefully someone might at least have a thought.

I long ago started writing an AFP client stack in Perl. Yes, I did that. The question isn't if that's possible. (If you're interested in seeing it, it's [https://github.com/demonfoo/afp-perl](here).)

When trying to run the code on UN*X platforms (Linux, macOS, *BSD, Solaris/OpenIndiana), it works well. I've even added sendfile() support for uploading, for the platforms that support it. Over my home network, from my Linux machine to my TrueNAS Core NAS, I can transfer data over 10GbE at 5-6 Gbps. So I like to think it's pretty efficient... but Windows is a whole other world of pain.

I've recently been optimizing it, and Devel::NYTProf has been very helpful. I'd tried running it on Windows in the past, and running into issues. I originally thought it might be an issue with Perl threads (yes, it's using those too...), but based on profiling, it's not. It sends a command packet, which is just 36 bytes long, which apparently Windows' TCP stack doesn't much appreciate. It sits there for a really long time waiting for the command data to send while uploading, and I'm not sure why; using Sys::Sendfile, which wraps the Win32 TransmitFile() function, takes 5x less time for some reason, even though each call to it sends 512 KiB. And yes, I am disabling Nagle's algorithm, and setsockopt() seems to indicate it worked.

Thoughts on what I'm doing wrong?

submitted by /u/demonfoo
[link] [comments]