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


Groups > comp.lang.forth > #45226

Re: Forth dictionary implementation and performance

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Forth dictionary implementation and performance
Date 2016-02-01 06:47 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2016Feb1.074719@mips.complang.tuwien.ac.at> (permalink)
References <2016Jan29.184253@mips.complang.tuwien.ac.at> <87k2mrrk95.fsf@jester.gateway.pace.com> <2016Jan30.145442@mips.complang.tuwien.ac.at> <8737tdr075.fsf@jester.gateway.pace.com>

Show all headers | View raw


Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> Note MAP_PRIVATE; from the documentation: "Updates to the mapping are
>> not visible to other processes mapping the same file, and are not
>> carried through to the underlying file." 
>
>Hmm, I remember noticing that, but it didn't seem to displace the part
>saying opening the file for read/write was required for PROT_WRITE.  I
>asked on #linux IRC and someone there said it was undefined behaviour
>under POSIX, so I'd be scared to deploy it in anything serious, but
>anyway it seems to work for the example.

Better check yourself when people make such claims.  Like all lawyers,
standards lawyers prefer to give you the advice that something is not
allowed rather than erring on the other side, especially when they
give their advice for free.

Anyway, here's from the latest POSIX
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html>:

|If PROT_WRITE is specified, the application shall ensure that it has
|opened the file descriptor fildes with write permission unless
|MAP_PRIVATE is specified in the flags parameter as described below.

>> in other words, mmap() is used here as (a hopefully more efficient
>> variant of) read().
>
>Yes, that part made sense.  Though reading the file in a single read()
>call might conceivably be faster than mmap'ing the file and taking
>multiple page faults while traversing it.

My expectation is that read first causes the disk contents to be
loaded into kernel buffers, and then copies the data to user space,
while mmap() maps the OS buffers into user space without copying
(except the copy-on-write when I write to it).

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2015: http://www.rigwit.co.uk/EuroForth2015/

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


Thread

Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-29 17:42 +0000
  Re: Forth dictionary implementation and performance Paul Rubin <no.email@nospam.invalid> - 2016-01-29 16:20 -0800
    Re: Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-30 13:54 +0000
      Re: Forth dictionary implementation and performance Paul Rubin <no.email@nospam.invalid> - 2016-01-31 11:57 -0800
        Re: Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-01 06:47 +0000
          Re: Forth dictionary implementation and performance Paul Rubin <no.email@nospam.invalid> - 2016-02-01 00:47 -0800
            Re: Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-01 11:13 +0000
  Re: Forth dictionary implementation and performance Bernd Paysan <bernd.paysan@gmx.de> - 2016-01-30 01:57 +0100
    Re: Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-30 17:18 +0000
      Re: Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-30 17:51 +0000
  Re: Forth dictionary implementation and performance Paul Rubin <no.email@nospam.invalid> - 2016-01-29 18:01 -0800
    Re: Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-30 13:59 +0000
      Re: Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-01-30 17:38 +0000
        Re: Forth dictionary implementation and performance Paul Rubin <no.email@nospam.invalid> - 2016-01-31 12:05 -0800
          Re: Forth dictionary implementation and performance Albert van der Horst <albert@spenarnc.xs4all.nl> - 2016-02-01 03:01 +0000
          Re: Forth dictionary implementation and performance anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-01 06:17 +0000
            Re: Forth dictionary implementation and performance "Elizabeth D. Rather" <erather@forth.com> - 2016-01-31 21:27 -1000
  Re: Forth dictionary implementation and performance hughaguilar96@gmail.com - 2016-01-30 15:42 -0800

csiph-web