[Tutor] A further question about opening and closing files
Alan Gauld
alan.gauld at btinternet.com
Thu Sep 10 00:19:43 CEST 2015
On 09/09/15 20:42, Laura Creighton wrote:
> In a message of Wed, 09 Sep 2015 20:25:06 +0100, Alan Gauld writes:
>> On 09/09/15 19:20, Laura Creighton wrote:
>> If you are working on a small platform - think mobile device - and it has
>> a single channel bus to the storage area then one of the worst things
>> you can do is write lots of small chunks of data to it. The overhead
>> (in hardware) of opening and locking the bus is almost as much as
>> the data transit time and so can choke the bus for a significant amount
>> of time (I'm talking milliseconds here but in real-time that's significant).
> But if I shoot you with my laser cannon, I want you to get the
> message that you are dead _now_ and not when some buffer fills up ...
There are two things about that:
1) human reaction time is measured in 100s of milliseconds so the delay
is not likely to be meaningful. If you do the flushes every 10ms
instead
of every write (assuming you are writing frequently) nobody is
likely to
notice.
2) Gamers tend not to be doing other things while playing, so you can
pretty
much monopolize the bus if you want to,
So if you know that you're the only game in town(sic) then go ahead and
flush everything to disk. It won't do much harm. But...
..., if your game engine is running on a server shared by other users and
some of them are running critical apps (think a businesses billing or
accounting suite that must complete its run within a 1 hour window say)
then
you become very unpopular quickly. In practice that means the sys admin
will
see who is flattening the bus and nice that process down till it stops
hurting
the others. That means your game now runs at 10% the CPU power it had
a while ago...
As programmers we very rarely have the control over our environment that
we like to think we do.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list