From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ffe4fb1477fe67e6 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!usenet-fr.net!gegeweb.org!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Memory mapped files and shared memory (Was: Newbie Needs Ada Advice) Date: Thu, 10 May 2007 23:20:19 +0200 Organization: Jacob's private Usenet server Message-ID: References: <1178212418.538270.283700@c35g2000hsg.googlegroups.com> <1178635220.859690.3310@y80g2000hsf.googlegroups.com> <5abtplF2n3855U1@mid.individual.net> <1178650313.462774.91850@e51g2000hsg.googlegroups.com> <1178659640.093325.10510@y5g2000hsa.googlegroups.com> <6lvef2aszy.fsf@hod.lan.m-e-leypold.de> NNTP-Posting-Host: taasingegade.news.jacob-sparre.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: jacob-sparre.dk 1178832022 10975 85.82.239.166 (10 May 2007 21:20:22 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 10 May 2007 21:20:22 +0000 (UTC) User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:xoITDq5+F8+cSDrCzNK05MrEivg= Xref: g2news1.google.com comp.lang.ada:15742 Date: 2007-05-10T23:20:19+02:00 List-Id: Markus E Leypold wrote: > Jacob Sparre Andersen writes: >> File names are slow. Wouldn't it be more appropriate to keep the >> currently relevant image(s) in a shared memory segment? > > Dependents on what you want to do. Probably not the whole 30 GB. My > rule of thumb always is to do the elementary thing first and > optimize later. In general that is also what I do, but isn't it simpler to store the whole sequence of images in an array of images? Mapping that array into a file/shared memory segment costs you around 20 lines of code (even with my rather extravagant use of linebreaks). There is one catch: I am not sure that the Ada interface to POSIX systems is required to support memory maps as large as 30 Gb. (Additionally I suspect that the original poster isn't using a POSIX system.) > In this case one could use the file storage (one use it anyway), > introduce (when required) the shared memory for explicit caching (or > perhaps play with memory mapping the file) and refine the > get-the-image protocol appropriately. My gut feeling though is, to > trust the file system cache of the machine to do the proper caching > implicitely and there should be a good reason to think you can do > better than that manually. Using memory maps goes even further in leaving the caching/swapping decisions to the operating systems, than copying individual images to and from files. Greetings, Jacob -- recursive, adj.; see recursive