steve g <Sgon…@gmail.com> wrote:
> Alexander Schreiber <a…@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