On Thu, 27 Jun 2024 17:39:46 +0000, MitchAlsup1 wrote:
I did; TSS 360/67 CMU, and I did; both PL/C and PL/1.
Did you make much use of LOCATE-style I/O?
Virtual memory was pretty new technology at the time, and required a
disk or drum. The central idea of /360 was having the same ISA across
a wide range of machines, and virtual memory wasn't affordable at the
low end at the time, AFAICS.
But IIRC even low end S/360s required a disk, at least to IPL(boot)
An application where one writes via mmap and others read
using stdio or read/write/pread/pwrite simulataneously
is poorly designed.
"An application"? I live in a world where all kinds of programs can
access the same files. How such a program works internally is often
not known to the designers of the others.
In practice your advice boils down to avoiding to write with mmap().
In my experience, mmap is most often used when record-granularity
is required, rather than treating the mapped region as a
stream-of-bytes.
I usually mmap() the whole file.
* You have to extend the file length with a separate system call, and
then mmap() the new area, so you might just as well use write().
False economy. ftruncate is a single system call.
Yes, that's the one that extends the file length. ftruncate()
followed by mmap() are two system calls. And at some point you also
want to msync() (although not for each ftruncate).
According to Anton Ertl <anton@mips.complang.tuwien.ac.at>:
An application where one writes via mmap and others read
using stdio or read/write/pread/pwrite simulataneously
is poorly designed.
"An application"? I live in a world where all kinds of programs can
access the same files. How such a program works internally is often
not known to the designers of the others.
In practice your advice boils down to avoiding to write with mmap().
It's more like don't try to write shared files unless you know all of
the writers are using consistent locking. Squinting at the source code
for FreeBSD's stdio, it only flushes writes when it fills the buffer
or when it writes a \n character with the '\n' hard coded in the
source code. It doesn't lock at all other than between threads in the
same task.
You need at least as many locks and flushes to keep things in sync as
you would with mapped files.
In my experience, mmap is most often used when record-granularity
is required, rather than treating the mapped region as a
stream-of-bytes.
I usually mmap() the whole file.
Same here, although I have used mmap() to map a whole file as well as
for database record stuff.
* You have to extend the file length with a separate system call, and
then mmap() the new area, so you might just as well use write().
False economy. ftruncate is a single system call.
Yes, that's the one that extends the file length. ftruncate()
followed by mmap() are two system calls. And at some point you also
want to msync() (although not for each ftruncate).
Seems to me the sensible thing to do is to use ftruncate and mmap to
extend the file in large chunks, say several megabytes at a time, not
one block at a time. If you have too many system calls your chunks are
not big enough. I believe the file systems do what they do with write()
and only allocate disk blocks the first time you write to them so there
is little penalty for extending in large chunks.
Scott Lurndal wrote:
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated when
a page is referenced for the first time.
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? ½ of the address space
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated when
a page is referenced for the first time.
ftruncate to the final size at close.
According to MitchAlsup1 <mitchalsup@aol.com>:
Scott Lurndal wrote:
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated when
a page is referenced for the first time.
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? ½ of the address space
Every filesystem has a maximum file size. Exceed that and you'll get
an EFBIG error.
Squinting at the source code for FreeBSD's stdio, it only flushes writes
when it fills the buffer or when it writes a \n character with the '\n'
hard coded in the source code.
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated when
a page is referenced for the first time.
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? ½ of the address space
Every filesystem has a maximum file size. Exceed that and you'll get
an EFBIG error.
Then it is not capable of ftruncate arbitrarily large in a hardware's
view of arbitrarily large which tends to be 1-bit smaller than the
largest container.
On Mon, 1 Jul 2024 02:10:43 -0000 (UTC), John Levine wrote:
The goal here is to map a file into the address space.
What if you don’t know how big it’s going to be?
On Sun, 30 Jun 2024 18:06:36 -0000 (UTC), John Levine wrote:
Squinting at the source code for FreeBSD's stdio, it only flushes writes
when it fills the buffer or when it writes a \n character with the '\n'
hard coded in the source code.
Both POSIX and C specs require this to be configurable ><https://manpages.debian.org/3/setbuf.3.en.html>.
The goal here is to map a file into the address space.
According to MitchAlsup1 <mitchalsup@aol.com>:
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated when
a page is referenced for the first time.
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? ½ of the address
space
Every filesystem has a maximum file size. Exceed that and you'll
get an EFBIG error.
Then it is not capable of ftruncate arbitrarily large in a hardware's
view of arbitrarily large which tends to be 1-bit smaller than the
largest container.
The goal here is to map a file into the address space. What's your use
case for mapping a file-like thing that is bigger than any real file
and can't be written out to the disk?
On Mon, 1 Jul 2024 02:10:43 -0000 (UTC)
John Levine <johnl@taugh.com> wrote:
According to MitchAlsup1 <mitchalsup@aol.com>:
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated when
a page is referenced for the first time.
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? ½ of the address
space
Every filesystem has a maximum file size. Exceed that and you'll
get an EFBIG error.
Then it is not capable of ftruncate arbitrarily large in a hardware's >>>view of arbitrarily large which tends to be 1-bit smaller than the >>>largest container.
The goal here is to map a file into the address space. What's your use
case for mapping a file-like thing that is bigger than any real file
and can't be written out to the disk?
Consider that configurations in which maximal file size is bigger than
half of address space are quite common. And not just on 32-bit HW.
Of course, what is considered "half of address space" is not a very
simple question by itself. Take x86-64. Is its address space 2**64 or
2*48? Take aarch64. Is its address space 2**64 or 2**49? Or, may be,
2**56?
Michael S wrote:
On Mon, 1 Jul 2024 02:10:43 -0000 (UTC)
John Levine <johnl@taugh.com> wrote:
According to MitchAlsup1 <mitchalsup@aol.com>:
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated when >>>>>>> a page is referenced for the first time.
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? ½ of the address >>>>>>space
Every filesystem has a maximum file size. Exceed that and you'll
get an EFBIG error.
Then it is not capable of ftruncate arbitrarily large in a hardware's >>>>view of arbitrarily large which tends to be 1-bit smaller than the >>>>largest container.
The goal here is to map a file into the address space. What's your use
case for mapping a file-like thing that is bigger than any real file
and can't be written out to the disk?
Consider that configurations in which maximal file size is bigger than
half of address space are quite common. And not just on 32-bit HW.
Of course, what is considered "half of address space" is not a very
simple question by itself. Take x86-64. Is its address space 2**64 or
2*48? Take aarch64. Is its address space 2**64 or 2**49? Or, may be,
2**56?
To answer this one has to use the proper verbology::
Half the virtual address space of x86-64 is 63-bits
Half the physical address space is as low as 38-bits and as high as
47-bits
Michael S wrote:
On Mon, 1 Jul 2024 02:10:43 -0000 (UTC)
John Levine <johnl@taugh.com> wrote:
According to MitchAlsup1 <mitchalsup@aol.com>:
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated
when a page is referenced for the first time.
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? ½ of the address >>>>>space
Every filesystem has a maximum file size. Exceed that and you'll
get an EFBIG error.
Then it is not capable of ftruncate arbitrarily large in a
hardware's view of arbitrarily large which tends to be 1-bit
smaller than the largest container.
The goal here is to map a file into the address space. What's your
use case for mapping a file-like thing that is bigger than any
real file and can't be written out to the disk?
Consider that configurations in which maximal file size is bigger
than half of address space are quite common. And not just on 32-bit
HW.
Of course, what is considered "half of address space" is not a very
simple question by itself. Take x86-64. Is its address space 2**64
or 2*48? Take aarch64. Is its address space 2**64 or 2**49? Or, may
be, 2**56?
To answer this one has to use the proper verbology::
Half the virtual address space of x86-64 is 63-bits
Half the physical address space is as low as 38-bits and as high as
47-bits
depending on the implementation (i.e., age)
This is one of those situations where the physical realm overrules the virtual realm.
mitchalsup@aol.com (MitchAlsup1) writes:
Michael S wrote:
On Mon, 1 Jul 2024 02:10:43 -0000 (UTC)
John Levine <johnl@taugh.com> wrote:
According to MitchAlsup1 <mitchalsup@aol.com>:
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated
when a page is referenced for the first time.
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? ½ of the address >>>>>>space
Every filesystem has a maximum file size. Exceed that and you'll
get an EFBIG error.
Then it is not capable of ftruncate arbitrarily large in a
hardware's view of arbitrarily large which tends to be 1-bit
smaller than the largest container.
The goal here is to map a file into the address space. What's
your use case for mapping a file-like thing that is bigger than
any real file and can't be written out to the disk?
Consider that configurations in which maximal file size is bigger
than half of address space are quite common. And not just on
32-bit HW.
Of course, what is considered "half of address space" is not a very
simple question by itself. Take x86-64. Is its address space 2**64
or 2*48? Take aarch64. Is its address space 2**64 or 2**49? Or,
may be, 2**56?
To answer this one has to use the proper verbology::
Half the virtual address space of x86-64 is 63-bits
Half the physical address space is as low as 38-bits and as high as
47-bits
And generally the address space usable by an application is
limited by the OS/user virtual address boundary (e.g. 2gb
or 3gb on 32-bit x86, and 2^55 for ARM64).
On Tue, 02 Jul 2024 00:28:45 GMT
scott@slp53.sl.home (Scott Lurndal) wrote:
mitchalsup@aol.com (MitchAlsup1) writes:
Michael S wrote:=20
=20
On Mon, 1 Jul 2024 02:10:43 -0000 (UTC)
John Levine <johnl@taugh.com> wrote:
=20
According to MitchAlsup1 <mitchalsup@aol.com>: =20
In fact, you can ftruncate arbitrarily large at the start -
backing sectors for the mapped pages will only be allocated
when a page is referenced for the first time. =20
Can you ftruncate( 0x7FFFFFFFFFFFFFFFF ); ?? =C2=BD of the address
space =20
Every filesystem has a maximum file size. Exceed that and you'll
get an EFBIG error. =20
Then it is not capable of ftruncate arbitrarily large in a
hardware's view of arbitrarily large which tends to be 1-bit
smaller than the largest container. =20
The goal here is to map a file into the address space. What's
your use case for mapping a file-like thing that is bigger than
any real file and can't be written out to the disk?
=20
Consider that configurations in which maximal file size is bigger
than half of address space are quite common. And not just on
32-bit HW.
Of course, what is considered "half of address space" is not a very
simple question by itself. Take x86-64. Is its address space 2**64
or 2*48? Take aarch64. Is its address space 2**64 or 2**49? Or,
may be, 2**56? =20
To answer this one has to use the proper verbology::
Half the virtual address space of x86-64 is 63-bits
Half the physical address space is as low as 38-bits and as high as
47-bits =20
And generally the address space usable by an application is
limited by the OS/user virtual address boundary (e.g. 2gb
or 3gb on 32-bit x86, and 2^55 for ARM64).
2**49 (IIRC) on ARMv8-A and 2**56 on ARMv9-A is a architectural hardware >limit rather than OS limit.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 01:19:21 |
Calls: | 10,387 |
Calls today: | 2 |
Files: | 14,061 |
Messages: | 6,416,728 |