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,55a8252137b5ef97 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!proxad.net!62.253.162.218.MISMATCH!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!newspeer1-win.ntli.net!newsfe3-win.ntli.net.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: Efficiently setting up large quantities of constant data User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.ada References: <4LGruwf2lqzz@eisner.encompasserve.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Thu, 16 Dec 2004 23:47:50 GMT NNTP-Posting-Host: 81.100.88.147 X-Complaints-To: http://www.ntlworld.com/netreport X-Trace: newsfe3-win.ntli.net 1103240870 81.100.88.147 (Thu, 16 Dec 2004 23:47:50 GMT) NNTP-Posting-Date: Thu, 16 Dec 2004 23:47:50 GMT Organization: ntl Cablemodem News Service Xref: g2news1.google.com comp.lang.ada:7008 Date: 2004-12-16T23:47:50+00:00 List-Id: On Thu, 16 Dec 2004 15:52:28 -0600, Larry Kilgallen wrote: > In article , Andre writes: >> Dr. Adrian Wrigley wrote: > >>> For example, suppose I have a binary file "distances.dat" containing >>> the (road) distances between 1000 different cities. This could be a 2MB >>> file computed by another application. How can I build a single executable >>> file containing the data and access it from the Ada code? > >> 2. Use a memory mapped file. This way you also get a pointer to the data >> and Windows is taking care of loading it into the memory. Data reading >> using a memory mapped file is just as fast as putting it in the executable. > > But since he did not say the purpose of putting it in the application > was for speed, I think we have to presume it was for religious reasons. It seems like a good idea in some circumstances: Atomic upgrade - replace the binary in one step may be useful, particularly in a real-time system (think cron job running single executable avoids possible inconsistency of old data files during upgrade) obscures internal structures a bit - makes it a bit harder for users to mess around with/view internal structure (eg substituting their own data files) simpler distribution - can put executable in /usr/bin without messy directory of data files to go somewhere. No need for .tar.gz archive. Also simpler to remove and to verify. I like the objcopy route over generating and compiling Ada source (particularly for large data), since it avoids potential compiler limits, and doesn't risk unexpected efficiency problems (stack space/elaboration time/code space, compilation time etc.). but mostly it was religious, yes... -- Adrian