Article View: comp.lang.lisp
Article #77Re: read-file for sbcl
From: Alexander Schreiber
Date: Sat, 28 Nov 2026 11:34
Date: Sat, 28 Nov 2026 11:34
71 lines
3721 bytes
3721 bytes
steve g <Sgonedes1977@gmail.com> wrote:
> Madhu <enometh@meer.net> writes:
>
>> * steve g <87ld6gl8ah.fsf@gmail.com> :
>> Wrote on Wed, 25 Nov 2026 19:56:38 -0500:
>>
>>> I am working on a project and came across the need to read files very
>>> easily. I created this package for SBCL. If you need or want a rather
>>> fast read-file function; Just run make, load, the compile.
>>>
>>> I know this is not a binary group, I'll try try and attach the base64.
>>>
>>> I have been using this version of file-length-by-name for quite some
>>> time. It seems more accurate that stat. It just uses lseek.
>>
>> "more accurate" ? when are they never equal?
>
> I do not feel like exploring memory access time.
>
>>> The attachments should be alright. Let me know if you have any questions
>>> or unexpressed anger...
>>
>> 1. "sbcl-only" is a virtue only for claude code customers
>
> I do not know what claud is. Any info would be appreciated.
LLM based AI system, great for slopping stuff together, not great for
actually writing good software especially if skill and judgement are
lacking in the operator.
>> 2. if sbcl-only then why the posix c sharedlib, just use cffi for
>> syscalls
>
> I use POSIX because I am not stupid. Please, you must be kinding me? I
> need 23,000 lines of quicklisp code to read the size of a file.
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"))
>> 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). All because the inode on ext4 by default is an absolutely massive
256 bytes. And that assumes fully cold caches.
> 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?
And how do you think that informations "gets kinda loaded in memory" (and
that phrase is quite telling)? Yes, the kernel reads the inode from disk.
Although in reality, is has done so when you opened the file for lseek(2)
so for the stat call it already has that data.
> 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.
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:
<slrn11glf2d.1hn9k.als@mordor.angband.thangorodrim.de>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!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>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!weretis.net!feeder8.news.weretis.net!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: Sat, 28 Nov 2026 12:34:37 +0100 Organization: Not much. Lines: 71 Message-ID: <slrn11glf2d.1hn9k.als@mordor.angband.thangorodrim.de> References: <87ld6gl8ah.fsf@gmail.com> <m3wlq0ut1c.fsf@pison.robolove.meer.net> <87ld6dhbsc.fsf@gmail.com> Reply-To: als@usenet.thangorodrim.de X-Trace: individual.net /KVbjHDwWWUXFFmgeyBH1wlJccqIMp3SqNCNFeHwGncAu6dH8Q X-Orig-Path: frodo.angband.thangorodrim.de!not-for-mail Cancel-Lock: sha1:dL/cjTXoa+QeEsPxeeAsKVP1lJg= sha256:cpnpNlrmtQAzUWPIgaysYEJepULi/+CrYUBa4v8V00k= User-Agent: slrn/1.0.3 (Linux)