[Yaffs] Performance of overwrite vs new file

Charles Manning Charles.Manning at trimble.co.nz
Wed Oct 12 22:46:12 BST 2005


Hi Robert

This is a well-known (by some :-)) issue, but the x7 difference is
surprising, I would have expected more like x2.

I could go into the explanation in depth if you need, but for now I will
give a 50,000 ft description:

What happens is this:
1) If you overwrite a file, then yaffs cannot use soft deletion, but
must instead mark the old file sectors as being deleted. This costs
extra programming cycles. If (likely) blocks become fully discarded,
then they will be erased.

The above will happen whether or not you overwrite the file directly or
whether you first truncate it to zero first ie open with O_TRUNC.

If instead you delete a file and rewrite it from scratch, then YAFFS
uses "soft deletion" to delete the file instead. This does not program
deletion markers and therefore takes far less time.

I believe some/most other log structured fs have a similar issue.


One way around this is to delete files rather than truncate them. Of
course this only works if you can modify the source. Ie:

Instead of 
   
     h = open(fname, O_CREAT | O_RDWR| O_TRUNC);

Use 

     unlink(fname);
     h = open(fname, O_CREAT | O_RDWR);

The above does not apply to yaffs2 on 2k pages since yaffs2/2k does not
write deletion markers.



> -----Original Message-----
> From: yaffs-bounces at stoneboat.aleph1.co.uk 
> [mailto:yaffs-bounces at stoneboat.aleph1.co.uk] On Behalf Of 
> Roberts Nathan-mcg31137
> Sent: Thursday, 13 October 2005 4:24 a.m.
> To: yaffs at stoneboat.aleph1.co.uk
> Subject: [Yaffs] Performance of overwrite vs new file
> 
> 
> I've run into an interesting performance issue that I was 
> hoping someone with more knowledge of YAFFS's inner workings 
> could explain rather quickly.
> 
> Essentially, I am observing that overwriting a file (1MB or 
> so) takes about 7 times longer than writing exactly the same 
> file under a new name.
> 
> This is using YAFFS1 on NAND with 512B pages.
> 
> Thanks for any insight.
> 
> _______________________________________________
> yaffs mailing list
> yaffs at stoneboat.aleph1.co.uk
> http://stoneboat.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs
> 



More information about the yaffs mailing list