From owner-freebsd-hackers Wed Jul 28 2: 9:36 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from celery.dragondata.com (celery.dragondata.com [205.253.12.6]) by hub.freebsd.org (Postfix) with ESMTP id ABE2415434 for ; Wed, 28 Jul 1999 02:09:32 -0700 (PDT) (envelope-from toasty@celery.dragondata.com) Received: (from toasty@localhost) by celery.dragondata.com (8.9.3/8.9.3) id EAA07996 for hackers@freebsd.org; Wed, 28 Jul 1999 04:08:48 -0500 (CDT) (envelope-from toasty) From: Kevin Day Message-Id: <199907280908.EAA07996@celery.dragondata.com> Subject: Replace/rewrite reverse.c for tail(1) To: hackers@freebsd.org Date: Wed, 28 Jul 1999 04:08:48 -0500 (CDT) X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG An application I use quite often requires me to reverse the lines in the file to get the desired output. 'tail -r' appears to be very inefficient in it's use of mmap(). It mmap's the entire file in, which encourages the kernel to swap out the rest of the system to keep pages of the input file in memory. 58350 root 54 0 412M 85244K RUN 0:14 19.78% 19.19% tail Out of 128M of ram, it's swapped nearly everything else out to keep 85M of this 400M file in ram, even though it will never touch it again. :) I see two possible fixes for this. One could be madvise'ing periodically with MADV_DONTNEED. If I understand correctly, this would help a bit, right? Or, mmap smaller regions of the file, and keep moving the buffer. This would also help with files exceeding mmap's limits. Any thoughts? Kevin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message