Re: [Yaffs] Re: How to calculate the exact ram usage of YAFF…

Startseite
Anhänge:
Nachricht
+ (text/plain)
Nachricht löschen
Nachricht beantworten
Autor: Charles Manning
Datum:  
To: yaffs
CC: Wookey
Betreff: Re: [Yaffs] Re: How to calculate the exact ram usage of YAFFS(2)?
Pretty much all GoodStuff so far.

On Tuesday 27 September 2005 05:07, Wookey wrote:
> +++ Sven Höhne [05-09-26 16:12 +0200]:
> > Hi!
> >
> > I am curerntly doing some research on YAFFS(2) and would like to
> > calculate the exact RAM usage.
>
> That is excllent - people would very much like to be easily able to
> calculate this, and as you have discovered, it is currently not an easy
> thing to determine.
>
> > For my paper I do need some more information and better values to
> > calculate the RAM usage.
> > I would like to set up a kind of formula which would allow to calculate
> > the RAM usage based on three parameters: NAND size, chunk size and the
> > number of files. The calculation shall presuppose, that all space in
> > NAND ist used by the given number of files, all of the same size.
> >
> > I basically came up with this kind of calculation:
> >
> > RAM usage = number of files * (Space for yaffs_Object + Space for tnode
> > structure) + Space always needed (yaffs_Device, program in RAM, etc.)
>
> That looks about right to me. There is some variability in the 'space
> always needed' part - e.g. depending on how many yaffs_ShortOp_Caches you
> define, for example - each one of those is another page's worth of bytes
> IIRC.


The other "space always needed" are the bufers allocated for yaffs2 (yaffs1
uses the stack for this instead).

>
> > For this, I would like to calculate the number of tnodes used for a
> > given file size and would need some more info on the size of the
> > strucures.


Calculating the tnodes is pretty straight forward, except for files with holes
in them (sparse files):

First calculate the level0 tnodes. These are the ones that actually point to
the nand chunks. Note that chunk zero is not used.

Each tnode points to 16 nand chunks. If we ignore sparse files then:

nlevel0tnodes = round_up(round_up((filesize/chunksize)+1)/16) // the +1 is
for the chunk zero that is not used.

or in C, for chunksize=512

nlevel0tnodes = ((((filesize + 511)/512)+1)+15)/16;

The tnodes are also used to hold together the internal tree, however in this
case the space is treated as 8*32-bit pointers instead of 16 * 16-bit
chunkIds. So essentially each level n+1 can support 8 level n tnodes.

So the algorithm goes:

if level n <= 1 tnode, then we don't need any level n+1
else level n+1 = round_up((level n)/8);

Worked example:

file size of 123456 bytes.
(123456 + 511)/512 = 242 chunks
((242 + 1) + 15)/16 = 16 level 0 tnodes
(16 + 7)/8 = 2 level 1 tnodes
(2 + 1)/8 = 1 level 2 tnode.

Total tnodes for the file = 19.

Since tnodes are only added where chunks exist, a sparse file can have far
fewer tnodes. However, the depth is determined by file size, not by the
number of tnodes below.

For example, a sparse file with 1 byte at 1MB will have one level 0 tnode, one
level 1, one level 2... up to whatever n is.


-- Charles