Article View: comp.lang.lisp
Article #99Re: read-file for sbcl
From: Alexander Schreiber
Date: Mon, 30 Nov 2026 10:04
Date: Mon, 30 Nov 2026 10:04
113 lines
5214 bytes
5214 bytes
steve g <Sgonedes1977@gmail.com> wrote:
> Alexander Schreiber <als@usenet.thangorodrim.de> writes:
>
>> What ... are you doing? In SBCL with the sb-posix module (and all of that
>> is about 3300 lines of Lisp, which includes win32 support as well as tests)
>> getting the size of the file via sb-posix via libc via the kernel is just
>> one line: (sb-posix:stat-size (sb-posix:stat "/etc/hosts"))
>
>
> Again I am using LSEEK to preload the cache.
What for? Just calling lseek(2) merely positions the file pointer, it does
not read through the entire file to that position - that would be both silly
and wasteful. The only I/O lseek triggers is maybe some metadata I/O to read
the block pointers.
> _This is implementation
> specific_. If you enabled the caching option in your linux kernel, This
> will probably work a bit better.
"enable the caching option in your kernel" What? In Linux, the buffer cache
is always on. There are ways to explicitly circumvent it (i.e. direct I/O)
if needed, but it is not something that has to be explicitly enabled.
>>>> 4. i cant imagine in 2020s linux hw where this would make a practical
>>>> difference
>>>
>>> That's what I said 20 years ago.
>>>
>>> Stat must load lots of stuff into memory.
>>
>> Yeah, it has to read an entire block from storage (512/4096 bytes depending
>> on details).
>
> Linux likes number 4096.
No, it does not "like number 4096". The standard page size on both i386 and
amd64 is 4096 bytes. And the 512/4096 was a reference to block device native
block sizes, which used to be mostly 512 bytes for typical machines, but
these days the larger HDDs generally have 4096 byte blocks - but still do
emulate 512 byte sectors.
>> All because the inode on ext4 by default is an absolutely massive
>> 256 bytes. And that assumes fully cold caches.
>
> ext2 is much faster.
The benchmarks I've seen very clearly say otherwise, except in some corner
cases.
>>> When using lseek to get the
>>> length of the file it is ``kinda loaded into memory'' or a cache.
>>
>
>> About that ... where do you think the kernel gets the size of the file?
>
> from the inode?
Full marks for that one.
>> And how do you think that informations "gets kinda loaded in memory" (and
>> that phrase is quite telling)?
>
> Ummm? Like I said there is a kerel option for caching. Maybe the kernel?
The kernel does caching by default. Turning it off requires extra action and
even then can't be done for the whole machine.
>> Yes, the kernel reads the inode from disk.
>> Although in reality, is has done so when you opened the file for
>> lseek(2)
>
> Correct.
>
>> so for the stat call it already has that data.
>
>
> stat uses memory that I do not need.
Seriously? The information held in the in-memory structure for stat is a
bunch of bytes. I assume you also run your system with a.out binaries
instead of ELF because the ELF dynamic symbol resolution wastes memory?
>
>>> Believe me my SCSI drives definitely knew the difference between cached
>>> io and scatter brain read.
>
>> Because cached IO (at the OS level) doesn't touch the drive.
>
> SCSI drives run on their own bios before loading the operating system.
All somewhat modern drives (and I cheerfully include IDE in that set) run
their own firmware on the drive controllers. And any kind of SCSI controller
BIOS stops running the moment the Linux kernel boots - this is not DOS.
> This is usually done in the SCSI bios. it depends on your scsi
> disk controller.
And the purpose of that is mostly to make the drives available for the BIOS
so the system can boot off them - a similiar setup is done for EFI. Once the
OS kernel has booted, that stops (yes, the OS _can_ use EFI I/O services,
but that usually means performance sucks badly, so that's only done in edge
cases).
> Anyways, why do you care?
Because, kind Sir, you seem to be spouting nonsense.
Kind regards,
Alex.
--
"Opportunity is missed by most people because it is dressed in overalls and
looks like work." -- Thomas A. Edison
Technical Details
Message-ID:
<slrn11gqiha.kv1s.als@frodo.angband.thangorodrim.de>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.in-chemnitz.de!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mailReferences:
<87ld6gl8ah.fsf@gmail.com> <m3wlq0ut1c.fsf@pison.robolove.meer.net> <87ld6dhbsc.fsf@gmail.com> <slrn11glf2d.1hn9k.als@mordor.angband.thangorodrim.de> <878q2bdxn1.fsf@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.in-chemnitz.de!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Alexander Schreiber <als@usenet.thangorodrim.de> Newsgroups: comp.lang.lisp Subject: Re: read-file for sbcl Date: Mon, 30 Nov 2026 11:04:26 +0100 Organization: Not much. Lines: 113 Message-ID: <slrn11gqiha.kv1s.als@frodo.angband.thangorodrim.de> References: <87ld6gl8ah.fsf@gmail.com> <m3wlq0ut1c.fsf@pison.robolove.meer.net> <87ld6dhbsc.fsf@gmail.com> <slrn11glf2d.1hn9k.als@mordor.angband.thangorodrim.de> <878q2bdxn1.fsf@gmail.com> Reply-To: als@usenet.thangorodrim.de X-Trace: individual.net jXwQfwFwS+PyI7RFlMzBVQEND6ZbZ7e1wXzB5/vTDuM5ZQ5bb/ X-Orig-Path: frodo.angband.thangorodrim.de!not-for-mail Cancel-Lock: sha1:nL0iqiJnOvpzTWrzWy9KpmZPz/U= sha256:8bk4fATrPrPoSrIrnF5ixfZ2tkFdnHaRbu7saTuX4cQ= User-Agent: slrn/1.0.3 (Linux)