Re: Using mmap(2) in sort(1) instead of temp files

2024-04-04 Thread Joerg Sonnenberger
On Thursday, April 4, 2024 11:28:13 PM CEST Robert Elz wrote: > Yes, in cases where temp files are actually needed, using mmap() is a > very minor gain indeed - the buffering cost might be saved, but sorting > a large file is a cpu costly endeavour (lots of comparisons, lots of times > even with th

Re: Using mmap(2) in sort(1) instead of temp files

2024-04-04 Thread Robert Elz
Date:Thu, 4 Apr 2024 10:05:17 -0400 (EDT) From:Mouse Message-ID: <202404041405.kaa01...@stone.rodents-montreal.org> | Actually, if you mmap it PROT_WRITE and MAP_PRIVATE, you could go right | ahead. But that'll cost RAM or swap space when the COW fault happens.

Re: Using mmap(2) in sort(1) instead of temp files

2024-04-04 Thread Mouse
>> Given the issues about using mmap, can anybody suggest how I should >> proceed with the implementation, or if I should at all? > There are two potential ways where mmap(2) could help improve the speed > of sort: > - If you know the input file name, use a read-only mmap() of that file >and

Re: Using mmap(2) in sort(1) instead of temp files

2024-04-04 Thread Martin Husemann
On Thu, Apr 04, 2024 at 12:02:30PM +, Ice Cream wrote: > Given the issues about using mmap, can anybody suggest how > I should proceed with the implementation, or if I should at all? There are two potential ways where mmap(2) could help improve the speed of sort: - If you know the input file

Using mmap(2) in sort(1) instead of temp files

2024-04-04 Thread Ice Cream
I originally sent this email to tech-kern but was told it would be better suited for discussion here. --- I'm trying to speed up sort(1) by using mmap(2) instead of temp files. ftmp() (see code below) is called in the sort functions to create and return a temp file. mkstemp() is