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


Groups > comp.lang.c > #14767

Re: Small Variant Records in C

From "BartC" <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: Small Variant Records in C
Date 2011-12-19 21:44 +0000
Organization A noiseless patient Spider
Message-ID <jcob99$svt$1@dont-email.me> (permalink)
References (5 earlier) <b31838b4-399d-452e-9531-9fa92b5d09db@m10g2000vbc.googlegroups.com> <jcm7d3$e0s$1@dont-email.me> <fb727845-65e8-48a2-8cc9-a44d0c2d6f05@z12g2000yqm.googlegroups.com> <jcns0c$kl0$1@dont-email.me> <f74b6815-7230-41a7-9c7f-78b342138c64@l29g2000yqf.googlegroups.com>

Show all headers | View raw



"Marco Devillers" <marco.devillers@gmail.com> wrote in message 
news:f74b6815-7230-41a7-9c7f-78b342138c64@l29g2000yqf.googlegroups.com...
>> OK, I'll ask the obvious question: what's in the other 31 (or 28) bytes 
>> of
>> the memory used by a single char?
>
> By memory: A tag stating it's an opaque series of bits (a 0), the size
> of the series of bits, the record and the type info (it's a char), the
> value of the char. Each field aligned at 64 bits/8 bytes, four fields,
> so 32 bytes.
>
> It's a wasteful scheme, I knew that. But at a given point I was only
> interested in a bootstrap, didn't give it a lot of thought, and ended
> up at least two orders above of the imagined memory consumption. Guess
> I should have done the numbers before.

So you have an array of 15 million characters, but each one is stored inside 
a variant type.

That's always going to be wasteful: 32 bytes each here, 12 bytes if I did 
the same, unless you use a fiddly representation that uses spare bits. This 
is where a packed array should be considered, then each element can be 1, 2 
or 4 bytes depending on how much you need unicode.

But if this array represents a string, then definitely implement those 
first.

(I'm assuming your 15 million characters *are* together in a collection, but 
you also mention C code being generated that takes 15 minutes to compile. 
I'm not sure how that would come about, unless you represent your 
15-million-element data by initialising such an array of variants as 15 
million lines of C! That shouldn't be necessary, unless each element has a 
different initial value.)

-- 
Bartc 

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


Thread

Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 10:16 -0800
  Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-18 18:50 +0000
    Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 15:00 -0500
      Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 12:23 -0800
        Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-18 21:15 +0000
          Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 14:13 -0800
            Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-19 00:26 +0000
            Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 02:25 +0000
              Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 19:08 -0800
                Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 17:24 +0000
                Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 11:43 -0800
                Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 15:21 -0500
                Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 13:38 -0800
                Re: Small Variant Records in C James Kuyper <jameskuyper@verizon.net> - 2011-12-19 16:48 -0500
                Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 17:19 -0500
                Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 15:14 -0800
                Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 21:44 +0000
                Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 14:02 -0800
                Re: Small Variant Records in C Kaz Kylheku <kaz@kylheku.com> - 2011-12-19 18:38 +0000
              Re: Small Variant Records in C jgk@panix.com (Joe keane) - 2012-01-04 03:52 +0000
                Re: Small Variant Records in C Ian Collins <ian-news@hotmail.com> - 2012-01-04 20:25 +1300
          Re: Small Variant Records in C Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 15:53 -0800
        Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 18:35 -0500
          Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 16:01 -0800
            Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-19 00:26 +0000
              Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 17:02 -0800
            Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 19:53 -0500
              Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 01:36 +0000
                Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 18:21 -0800
                Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 02:52 +0000
                Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 19:17 -0800
                Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 09:24 -0500
                Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 17:18 +0000

csiph-web