9
votes

Im trying to figure out what is the most "optimized" socket buffer size on iOS, when I query KIPC_MAXSOCKBUF with sysctl it returns a 4Mb buffer size which seems to me pretty high... From my experience socket recv performance seems better when using the "default_continuous_buffer_size" of the system (Unix guy speaking here!) however I cannot run a sysctl -a on iOS to get that info... and its also not available through the C interface for sysctl (or does it have a different name?).

Does anyone else have tested what is the most performant recv socket buffer size on iOS?

2
Never tested performance, but I normally use 1024KB (so 1MB). But this answer isn't very helpfull i guess.. :P - stackr

2 Answers

3
votes

I think its 1024 KB (1 MB), but I am not pretty sure.Using MAC OS's getsockopt(2), SO_SNDBUF and SO_RCVBUF are options to adjust the normal buffer sizes respectively. The buffer size may be increased for high-volume connections, or may be decreased to limit the possible backlog of incoming data. The system places an absolute limit on these values.

More information can be found on Mac OS X Manual Page For getsockopt(2)

0
votes

I'm not sure there is a single best size. On general principle, regardless of platform, it seems likely to vary greatly depending on the application (your code). It also seems hardware in use (various kinds of cellular, WiFi, or even Ethernet in uncommon cases) is likely to be important.

Also, according to some experiments I just ran on macOS, the value of SO_RCVBUF seems to change after a read (started at ~400K, I set it to 10 to test my code with small buffer sizes, and it jumped back to ~200K after the first read), so the system may be doing some empirical analysis it believes to be optimizing on the fly. (Behavior on iOS may of course vary from that of macOS.)

Yes, I answer old questions. What of it?