REBOL3 tracker
  0.9.12 beta
Ticket #0002160 User: anonymous

Project:

Previous Next
rss
TypeBug Statusreviewed Date11-Jul-2014 12:55
Versionr3 master CategoryPorts Submitted byrebolek
PlatformAll Severitymajor Prioritynormal

Summary Non-linear performance of TCP writes
Description I've been testing my Redis scheme and found a strange thing when writing data to a port. When writing to the TCP port data that are smaller than 256kB, everything works just as expected and the action takes few miliseconds. However, when I hit the 256kB threshold, things are very different. See following table, to see, how much it slows down:

100'000 bytes - 0,006 sec
200'000 bytes - 0,035 sec
250'000 bytes - 0,067 sec
300'000 bytes - 0,197 sec
500'000 bytes - 0,585 sec
1'000'000 bytes - 1,618 sec
2'000'000 bytes - 3,620 sec
4'000'000 bytes - 7,687 sec

@HappySpoon suggested sending data in chunks, so I switch the code to use 32'000 bytes chunk and sending even four megabyte data now take tens to few hundreds of miliseconds as expected.

When using this mode, I observed that there's a delay after each eighth write, so it is probably constructing the 256kB buffer somehow internally. So I tested using 256'000 bytes buffer instead of 32'000 and found that using bigger buffer does not work, the interpreter will hang up and waits (can be interrupted with [ESC] key, however). This will happen with any size from 32'001 up.

Using smaller buffer is also not an option and is even dangerous than bigger buffer. The smallest working buffer is 31'700 bytes, when using buffer of size 31'699 bytes or smaller, REBOL interpreter will crash with error #1412: REBOL System Error.

So, to wrap it up somehow:

1) when writing big data (anything bigger that 256kB) to TCP, buffered writing should be used, otherwise the writing will get extremely slow, and

2) when using buffered writing, buffer must be exactly 32'000 bytes, anything bigger will hang up interpreter and anything smaller than 31'700 will crash the interpreter.
Example code

			

Assigned ton/a Fixed in- Last Update26-Jan-2015 07:36


Comments

Date User Field Action Change
26-Jan-2015 07:36 abolka Severity Modified minor => major
26-Jan-2015 07:36 abolka Status Modified submitted => reviewed
26-Jan-2015 07:36 abolka Type Modified Issue => Bug
26-Jan-2015 07:35 abolka Summary Modified non linear response of the TCP write => Non-linear performance of TCP writes
26-Jan-2015 07:35 abolka Description Modified -
11-Jul-2014 12:55 rebolek Ticket Added -