read() performance - Linux.too?

Dave Dave_member at pathlink.com
Mon Jul 24 15:45:19 PDT 2006


Bob W wrote:
> "Dave" <Dave_member at pathlink.com> wrote in message 
> news:ea1g68$nhl$1 at digitaldaemon.com...
>> It's more than likely the GC, the same happens w/ a program like this:
>>
>> import std.outbuffer;
>> import std.string : atoi;
>> import std.stdio  : wrl = writefln;
>>
>> void main(char[][] args)
>> {
>>     int n = args.length > 1 ? atoi(args[1]) : 10_000_000;
>>     OutBuffer b = new OutBuffer;
>>     for(int i = 0; i < n; i++)
>>     {
>>         b.write("hello\n");
>>     }
>>     wrl(b.toString.length);
>> }
>>
>> Run w/o an argument (n = 10_000_000), on Windows it takes forever (starts 
>> swapping), on Linux it takes about a second.
> 
> 
> Thanks for your info - I'll remember it as a warning.
> 
> But this is probably a different case. Your program is
> dynamically resizing b's buffer. This requires more
> overhead than just releasing a piece of memory which
> was allocated in one single step.
> 

It seems to be "thrashing" during the full collection at program exit, 
but I haven't looked into it fully. I think that is probably what is 
happening in your case as well (that's why I mentioned it, but I should 
have explained that better).



More information about the Digitalmars-d mailing list