From: Bruno Haible <bruno@clisp.org>
To: "Tim Rühsen" <tim.ruehsen@gmx.de>
Cc: bug-gnulib@gnu.org, Darshit Shah <darnir@gnu.org>
Subject: Re: immutable string type
Date: Mon, 18 Jan 2021 09:17:27 +0100 [thread overview]
Message-ID: <9423806.pBvWCk5liC@omega> (raw)
In-Reply-To: <238f4446-9fb6-363e-9277-6fb1bbad10cf@gmx.de>
Tim Rühsen wrote on 2019-12-29:
> >> As a more general approach, a function that switches already allocated
> >> memory into read-only memory would be handy. Like in
> >> - m = malloc()
> >> - initialize m with some data
> >> - if in debug mode: call memmap_readonly(m) - from this point on 'm' is
> >> read-only and a write leads to a segmentation fault.
> >> - ...
> >> - free(m)
> >
> > Hardware has write barriers only on the page level. You can't easily request
> > a write barrier for a requence of, say, 30 bytes. To accomodate this, the
> > API needs to have a certain shape. Paul wrote:
>
> True, and it means that immalloc() always allocate multiples of the page
> size (page is 4096 bytes on x86_64 ?). How do you plan to optimize
> memory usage here ?
I optimized the memory usage by allocated several small or medium sized objects
in a single memory page. Through the module 'ssfmalloc'.
Bruno
next prev parent reply other threads:[~2021-01-18 8:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-28 11:17 immutable string type Bruno Haible
2019-12-28 13:35 ` Tim Rühsen
2019-12-29 9:45 ` Bruno Haible
2019-12-29 12:07 ` Tim Rühsen
2019-12-29 18:49 ` Paul Eggert
2019-12-29 19:03 ` Tim Rühsen
2019-12-30 3:11 ` Paul Eggert
2021-01-18 8:17 ` Bruno Haible [this message]
2019-12-28 16:54 ` Ben Pfaff
2019-12-29 9:29 ` Bruno Haible
2019-12-28 18:15 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9423806.pBvWCk5liC@omega \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=darnir@gnu.org \
--cc=tim.ruehsen@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).