Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #99426

Re: Why is this outputting alternate blank lines?

Message-ID <9a29id-9t5.ln1@wilbur.25thandClement.com> (permalink)
From <william@wilbur.25thandClement.com>
Subject Re: Why is this outputting alternate blank lines?
Newsgroups comp.lang.c
References (3 earlier) <o2s1i8$3qt$1@dont-email.me> <ln4m26nv0o.fsf@kst-u.example.com> <o2s8ir$uk5$1@dont-email.me> <lnmvfymf0a.fsf@kst-u.example.com> <87poku2n56.fsf@news.bourguet.org>
Date 2016-12-14 15:47 -0800

Show all headers | View raw


Jean-Marc Bourguet <jm@bourguet.org> wrote:
> Keith Thompson <kst-u@mib.org> writes:
> 
>> I suppose I should mention the background.  This can happen,
>> as I understand it, on Linux-based systems.  If the attempt to
>> access the "allocated" memory fails, it invokes something called
>> the "OOM killer" (OOM is Out Of Memory), which will kill *some*
>> chosen process(es), not necessarily the one that caused the error.
<snip>
>
> Excepted the "temporary need for fork", the other major use case (excepted
> lazy memory handling) seems to be applications which are playing tricks
> with the virtual memory such as using a large sparse array.
> 

That's the real reason, not the fork issue. The root of the problem,
supposedly, is applications that preallocate huge amounts of memory as a
performance optimization. For example, a database. A more recent example
would be some virtual machine memory managers that preallocate a large
amount of memory.

Often those applications will only ever touch a small amount of the memory.
And of course forked processes in particular are unlikely to touch any of
it. The issue with fork simply highlights the problem. Failing allocation or
fork would in most cases just be a needless inconvenience.

I don't find the argument very persuasive. Maybe the argument made more
sense 20 years ago, especially when Linux was trying to run big-iron
software on tiny desktops. But today preallocating memory like that is
frowned upon, and in any event there are much richer virtual memory
interfaces available to applications (e.g. mmap) that allow them to tell the
kernel if and how such memory should be inherited. Modern databases and
virtual machines know how to use these interfaces properly.

Virtual memory managers are much more sophisticated wrt sharing mappings for
regular files, including program code. In modern kernels the disk buffer
cache is shared with the virtual memory page cache, so memory-mapped files
can be serviced directly from disk, and kernels don't need to count those
pages against a process.

Applications can even effectively create their own swap space by creating,
deleting, and mapping large regular files. If the application truly never
touches the memory there's unlikely to be much if any disk activity. You get
all the benefits of overcommit, without the negatives.

And vfork is still a thing, not to mention posix_spawn.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Why is this outputting alternate blank lines? DFS <nospam@dfs.com> - 2016-12-13 23:18 -0500
  Re: Why is this outputting alternate blank lines? Melzzzzz <mel@zzzzz.com> - 2016-12-14 05:30 +0100
  Re: Why is this outputting alternate blank lines? mark.bluemel@gmail.com - 2016-12-14 00:59 -0800
  Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-14 10:38 +0000
    Re: Why is this outputting alternate blank lines? DFS <nospam@dfs.com> - 2016-12-14 12:53 -0500
      Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-14 18:05 +0000
        Re: Why is this outputting alternate blank lines? Keith Thompson <kst-u@mib.org> - 2016-12-14 11:57 -0800
          Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-14 20:05 +0000
            Re: Why is this outputting alternate blank lines? "James R. Kuyper" <jameskuyper@verizon.net> - 2016-12-14 15:21 -0500
            Re: Why is this outputting alternate blank lines? Keith Thompson <kst-u@mib.org> - 2016-12-14 12:28 -0800
              Re: Why is this outputting alternate blank lines? supercat@casperkitty.com - 2016-12-14 13:09 -0800
              Re: Why is this outputting alternate blank lines? Jean-Marc Bourguet <jm@bourguet.org> - 2016-12-14 22:53 +0100
                Re: Why is this outputting alternate blank lines? <william@wilbur.25thandClement.com> - 2016-12-14 15:47 -0800
            Re: Why is this outputting alternate blank lines? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-14 15:41 -0700
              Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-14 23:26 +0000
                Re: Why is this outputting alternate blank lines? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-14 17:33 -0700
                Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-15 00:42 +0000
                Re: Why is this outputting alternate blank lines? supercat@casperkitty.com - 2016-12-14 17:05 -0800
                Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-15 08:21 +0000
                Re: Why is this outputting alternate blank lines? supercat@casperkitty.com - 2016-12-15 09:15 -0800
                Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-15 17:50 +0000
                Re: Why is this outputting alternate blank lines? supercat@casperkitty.com - 2016-12-15 12:15 -0800
                Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-15 20:37 +0000
                Re: Why is this outputting alternate blank lines? raltbos@xs4all.nl (Richard Bos) - 2016-12-15 20:08 +0000
                Re: Why is this outputting alternate blank lines? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-14 20:40 -0700
                Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-15 08:36 +0000
                Re: Why is this outputting alternate blank lines? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-15 17:43 -0700
                Re: Why is this outputting alternate blank lines? Richard Heathfield <rjh@cpax.org.uk> - 2016-12-16 01:05 +0000
                Re: Why is this outputting alternate blank lines? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2016-12-15 18:34 -0700
                Re: Why is this outputting alternate blank lines? <william@wilbur.25thandClement.com> - 2016-12-15 10:14 -0800
                Re: Why is this outputting alternate blank lines? raltbos@xs4all.nl (Richard Bos) - 2016-12-15 20:15 +0000
            Re: Why is this outputting alternate blank lines? Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-15 01:51 -0800
              Re: Why is this outputting alternate blank lines? asetofsymbols@gmail.com - 2016-12-15 06:09 -0800
                Re: Why is this outputting alternate blank lines? Tim Rentsch <txr@alumni.caltech.edu> - 2016-12-15 17:47 -0800
          Re: Why is this outputting alternate blank lines? Keith Thompson <kst-u@mib.org> - 2016-12-14 12:15 -0800
            Re: Why is this outputting alternate blank lines? <william@wilbur.25thandClement.com> - 2016-12-15 10:24 -0800
          Re: overcommit is the plague Noob <root@127.0.0.1> - 2016-12-17 01:17 +0100
      Re: Why is this outputting alternate blank lines? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-14 20:19 +0000
        Re: Why is this outputting alternate blank lines? DFS <nospam@dfs.com> - 2016-12-14 17:44 -0500
          Re: Why is this outputting alternate blank lines? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-15 00:21 +0000
            Re: Why is this outputting alternate blank lines? mark.bluemel@gmail.com - 2016-12-15 00:56 -0800
              Re: Why is this outputting alternate blank lines? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-15 22:08 +0000
      Re: Why is this outputting alternate blank lines? Geoff <geoff@invalid.invalid> - 2016-12-14 13:39 -0800
      Re: Why is this outputting alternate blank lines? Ike Naar <ike@iceland.freeshell.org> - 2016-12-16 07:12 +0000

csiph-web