From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: Query regarding malloc if statement
Date: Tue, 20 Jun 2017 16:35:49 +0200 [thread overview]
Message-ID: <20170620143548.GM27071@port70.net> (raw)
In-Reply-To: <20170620041429.zjmzwpeyycwwpcvr@voyager>
* Markus Wichmann <nullplan@gmx.net> [2017-06-20 06:14:29 +0200]:
> On Mon, Jun 19, 2017 at 09:02:00PM +0000, Jamie Mccrae wrote:
> > My understanding is that doing a read followed by a possible write is slower than always doing a write for the reason that upon doing a read the process will halt
> > until the memory is brought into the CPU's cache which isn't a problem when just doing a write. I've just thrown together a simple application to test this (testing on a modern PC running alpine linux 64-bit in a virtualbox VM with 512MB RAM and 1 CPU core) with a normal musl library and a modified one whereby I've removed the 'if' check:
> >
>
> Woah, you're mixing up a few things here. A cache miss and a page fault
> are two very different things.
>
> Besides, doesn't a cache miss on write mean that a cache-line for the
> write area has to be allocated first?
>
are you arguing with somebody off-list?
(i only see your replies)
in any case the calloc code should not be
controversial on linux.
writing to each allocated page when they are
potentially unused is a huge waste of memory
not just time. (a benchmark that calls calloc/free
in a loop is obviously bogous, try
calloc(1000*1000*1000,1)
vs
memset(malloc(1000*1000*1000),0,1000*1000*1000))
next prev parent reply other threads:[~2017-06-20 14:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-19 15:16 Jamie Mccrae
2017-06-19 18:34 ` Markus Wichmann
2017-06-19 21:02 ` Jamie Mccrae
2017-06-20 4:14 ` Markus Wichmann
2017-06-20 14:35 ` Szabolcs Nagy [this message]
2017-06-20 20:04 ` Markus Wichmann
2017-06-20 23:08 ` A. Wilcox
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170620143548.GM27071@port70.net \
--to=nsz@port70.net \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).