Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#9947) insane inefficiency in packet sending
Home

[Freeciv-Dev] (PR#9947) insane inefficiency in packet sending

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9947) insane inefficiency in packet sending
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 4 Sep 2004 22:43:07 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9947 >

packets.c:148

       pc->compression.queued_packets = 
fc_realloc(pc->compression.queued_packets, new_size);

because a realloc is done every time a packet is sent, this makes 
sending packets O(n^2).

For instance if you have Apollo's, at the end of the turn you'll receive 
4000 packets of (maybe) 5 bytes on average.  This means 4000 reallocs of 
average size 10,000.  That's 40 megabytes of memcpying.

Hopefully you're not playing on a 200x100 map.  Because that means 5x as 
many packets and 25x as much memcpying.

People complain about server speeds.  But I suspect fixing this one line 
would have a bigger effect than hours of trying to figure out which 
functions to inline.  Of course it won't show up in any autogame timing 
since no packets are sent out.

jason




[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9947) insane inefficiency in packet sending, Jason Short <=