coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why the memory usage of sort does not seem to increase as the input


From: Pádraig Brady
Subject: Re: Why the memory usage of sort does not seem to increase as the input file size increases?
Date: Mon, 26 May 2014 16:51:06 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 05/26/2014 04:38 PM, Peng Yu wrote:
> Hi,
> 
> I tried "sort" on some large file. But the memory usage of "sort" does
> not seem to be large. This seems to be strange to me, as I think that
> sort need to see all the data before completing the sorting process.
> Shouldn't the memory usage of "sort" increase as the input size
> increases? Thanks.

Sort takes a divide and conquer approach,
by sorting parts of the input to temporary files,
and then merging the results with a bounded amount of memory.

sort currently defaults to using a large memory buffer
to minimize overhead associated with writing and reading
temp files, so you may be seeing just this large memory
allocation each time.

The memory allocation can be controlled with --buffer-size

thanks,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]