Approximat Coutrs for Flash Mmory Jack Cichoń ad Wojcich Macya Istitut of Mathmatics ad Computr Scic Wrocław Uivrsity of Tchology, Polad Abstract Flash mmory bcoms th a vry popular storag dvic Du to its shock - rsistac ad powr coomy is adoptd i ssor tworks ad mbddd systms Rctly mor atttio is paid to th data storag i flash mmory This is ot a simpl issu du to th limitatios of flash mmory Data i flash mmory should b distributd vly amog data blocks If th umbr of writs i a data block is too high, it may caus damag of th block Rquirmts for highly rliabl storag systms iclud fficit algorithms to maximiz its liftim ad tools to prdict it or moitor systm status O way to achiv this goal is to mbd a systm of coutrs which could cotrol block usag (spcially rasig opratios) Som solutios of this kid icludig cssary algorithms ar pattd I this papr w propos a iovativ solutio ivolvig th us of probabilistic coutig of th umbr of block modificatios Our solutio drastically rducs th umbr of bits dd to mmoriz coutrs W prcisly stimat th spac rquirmts for th coutr, discuss a sris of xprimts coformig th corrctss of our approach ad ivstigat th volutio systm of coutrs Idx Trms flash mmory, approximat coutr I INTRODUCTION Flash mmory is a vry popular storag dvic This is bcaus of its shock - rsistac, powr coomy ad ovolatil atur I rct yars flash mmory tchology taks th lad as a mai mmory compot i ssor tworks ad mbddd systms Thr ar sigificat brakthroughs i th capacity ad rliability of that tchology Th capacity of flash mmory icrass dramatically with th dcrasig cost of such dvics Thr ar flash storag dvics of GB o th markt ad thir siz will icras It sms that storag mmory will b a good altrativ for hard disks i may applicatios Nowadays flash mmory is usd i mobil applicatios such as PDA dvics, cll phos, music playrs ad so o Thr ar may promisig filds, whr flash mmory may b applid O of th rsarch dirctios cosidrs applicatio of flash mmory i databass [] A lot of paprs cosidr implmtatio of th B-tr or R-tr idxs ovr flash mmory [], [3] Thr ar two typs of flash dvics: NOR ad NAND Th NOR dvics hav lowr storag capacity, but fastr ad simplr accss to stord data, so thy ca b usd for program storag O th cotrary, th NAND dvics ar abl to accumulat mor data, bcaus of thir storag capacity Thy sm to b mor suitabl for data storag ad ssor tworks Flash mmory has a compltly diffrt architctur from hard disks Th proprtis o NAND flash ar dscribd i [] I summary, th rad ad writ opratios ar prformd at th pag graularity O flash mmory pag has typically 5-048 byts Pags ar orgaizd ito blocks; o block cosists of 3 or 64 pags Th first ky fatur of such mmory typ is th way of data rasur Th pag ca b ovrwritt oly aftr th rasig of th tir data block, i which th pag rsids As a cosquc, to prform a dlt opratio all othr pags i th block must b movd to aothr o I diffrt scario, istad of rmovig th pag, it may b chckd as dltd Aothr importat issu is th rgy cosumptio To writ a pag th flash mmory ds mor rgy th to prform th rad opratio This is importat for th systm with limitd rgy supply I such a cas usig th rgy must b plad optimally Th scod fatur with th grat impact o th data storag ad data maipulatio i flash mmory is th durac issu A block may b rasd about 00000 to 000000 tims Thraftr it may b wor out ad o mor usabl So th writ load should b sprad ovr th mmory vly To do that, ach block should b associatd with a coutr, which ca rcord th umbr of ras vts for this block Du to ths fudamtal costraits fficit storag maagmt is a challgig task Th coutr of th block ras opratio umbr must b maitaid spacfficitly Th aiv approach is to stor th xact umbr of th ras vts for ach block It s ot fficit, bcaus it rquirs about bits mmory pr block Thr ar svral solutios to this problm i th litratur Most of thm appard as US patts Som approachs ar basd o th maitaiig of th xact coutrs associatd with th ras blocks [4], [5], [6], [7] Ha pattd th solutio, which rlis o war stimatio usig ras latcis It is basd o th obsrvatio that th ras tim icrass with war [8] I this papr w propos approximat coutrs for th masurmt of th umbr of th ras opratios prformd o th particular block i flash mmory Approximat coutrs may b usd i situatios wh kowldg of a prcis umbr of occurrcs of obsrvd phomo is ot cssary Th mai advatag of this solutio for our purposs is a sigificat rductio of th umbr of bits rquird for storig th systm of coutrs This papr is orgaizd as follows: i th xt sctio w dscrib th problm ad propos our solutio I th third sctio w show, how to stor th data coctd with th approximat coutrs I th xt sctio w discuss th
volutio of th systm of coutrs ad xt w dscrib th xprimts, which wr do to cofirm our mthod mpirically I th last sctio w summarizd th papr ad dscribd coclusios ad possibl xtsios of our work A Motivatio II PROBLEM FORMULATION As w dscribd i th prvious sctio, ach block i flash mmory should b writt with th similar frqucy So vry sigl block must b associatd with th coutr, which masurs th umbr of ras vts Suppos that th block wars out aftr millio rpatd writs I that cas th umbr of bits usd for th maitac of th sigl coutr is about bits So if th capacity of th flash is 4 GB, o block cosists of 3 pags ad vry pag has 5 byts, th umbr of blocks is about 50000 I that cas 660000 byts of th flash mmory is dd for th coutrs It maks 006 prct of th whol mmory Additioally, th frqut icrmt of th coutr is also ot dsirabl, bcaus it ds th modificatio of th mmory block I this articl w propos th probabilistic coutr istad of th ral coutr dscribd abov Our coutr ds oly 5 bits pr block i flash mmory Cosidrig th umbr of blocks mtiod abov, istad of 000000 byts (8000000 bits) w d about 50000 bits Th othr advatag of our approach is th updat frqucy I th cas of th ral coutr, vry sigl ras of th block causs th icrmt of th coutr Usig our probabilistic coutr w do t d to do that so oft B Dscriptio of th approximat coutr I our work w us th approximat coutig proposd by Morris [9] Th algorithm maks it possibl to kp approximat couts of larg umbrs i small coutrs As w xplaid bfor for th ral coutr, which rag from to M w d log M + bits So for th coutr with th valu up to millio w d bits O th cotrary th approximat coutr ds oly approximatly log log M bits I that cas w d oly 5 bits of flash mmory for th storag for th sam rag So it sms to b much mor spac fficit tha usig th ral coutr Now w shall dscrib th procdur show i dtail i [0]: Th approximat coutr, calld also somtims calld as a probabilistic coutr, starts with th coutr valu C iitializd to 0 Th procss of icrmtatio of th coutr C is dscribd by th followig psudo-cod: d:= Radom([0,]); if d < C th C:= C+ d if Lt C dot th valu of th coutr C aftr coscutiv icrmts Th C is a radom variabl ad i [9] it was show that E[ C ] = + ad var[ C ] = ( + ) (whr E[X] dots th xpctd valu of a radom variabl X ad var[x] dots its variac) Thrfor th umbr C Fig Storag architctur is a ubiasd stimator of th umbr of icrmts I a dtaild aalysis of th approximat coutr do i [0] it was show that ( ) E[C ] = lg + c + ω() + O 098, () whr c 073954 ad ω is a priodic fuctio with priod, of ma valu 0 ad amplitud lss tha 0 5 Morovr th variac of th variabl C is small, amly w hav var[c ] 08736 (s also [0]) Hc w s that: ) th radom variabl C is strogly coctratd, ) w d approximatly lg log bits to stor th valu of th coutr C aftr icrmts, 3) th valu C is a quit prcis stimator of th umbr of icrmts III STORAGE ISSUES Lts assum, that o block cotais 3 pags ad ach pag 5 byts So th umbr of blocks of th 4GB flash mmory is about 50000 As w stimatd abov, w d 5 bits to stor o probabilistic coutr For th flash mmory of 4GB it maks about 50000 bits Th problm appars, how to maitai th coutrs i th flash mmory fficitly W propos to rsrv th adquat umbr of blocks to th siz of flash mmory, whr th coutrs will b stord Du to our prvious calculatio 50000 bits (5660 byts) d about 0 blocks to stor W call ths blocks th coutr rsrvatio storag (CRS) Of cours th CRS must also b cotrolld for th umbr of ras vts For that purpos about 50 bits (7 byts) ar dd So for th cotrol of th CRS block of mmory is ough Figur shows th cocpt of th storag It s ot difficult to imagi that frqut usig of CRS may lad to warig out of th mmory whr CRS rsid Th umbr of writ ad ras vts of CRS is vry high, bcaus vry chag i flash mmory will caus th chag of th associatd CRS block Usig our probabilistic coutr w scal dow th frqucy of such opratios o CRS Our coutrs do t icrmt as oft as it may tak plac i ral coutrs, so its valu dos ot d to b updatd so oft (w will com back to this proprty of CRS i sctio IV) Of cours to protct from warig out, th CRS may b tak to th mai mmory ad th swap priodically I o of our xprimts blow w simulat this procss
IV EVOLUTION OF SYSTEM OF COUNTERS I this sctio w discuss th procss of volutio of a systm of approximat coutrs Lt us fix a umbr m of blocks ad a systm C = (C i ) m of approximat coutrs dscribig th umbr of chags of corrspodig blocks Lt us rcall that iitially w hav C i = 0 for ach i A Radom modl Suppos that w radomly, with th uiform distributio, choos a block to b chagd Th w us th probabilistic icrmt procdur to th corrspodig approximat coutr Lmma 4: Lt Chag dots th vt that aftr a modificatio of a radom block th systm C is chagd Th Proof: Lt B i chagd Th Pr[Chag] = m Pr[Chag] = m dots th vt,,th ith block is Pr[Chag B i ] Pr[B i ] = Pr[Chag B i ] m = Pr[Chag B i ] = m Suppos for a whil that w obsrv a vctor C aftr a larg umbr m of icrmts Th ach block has b chagd approximatly m tims, so for ach i w hav C i log m, so Ci m, hc Pr[Chag] So, w s that if is larg th th probability of a chag of C aftr a icrmt opratio applid to o coutr is vry small Notic that i th cas of a vctor of ral coutrs icrmt of ach coutr chags th coutr, so th probability of chag is prcisly Thus th volutio of a systm of approximat coutrs radically diffrs from th volutio of ral coutrs: th itsity of chags i th first o dcrass quit rapidly, whil it is costat i th ral cas I ordr to trasform ths ituitios ito a prcis rsult w d to prov o auxiliary rsults Lt us rcall that a radom variabl Y has a Poisso distributio with a paramtr λ if Pr[Y = k] = λ λ k /k! Lmma 4: Suppos that balls ar draw uiformly ad idpdtly ito m urs Lt X, X m dot th umbrs of balls i corrspodig urs Th Pr[X m X m m ] m ( ) m Proof: Lt us cosidr a squc Y, Y m of idpdt radom variabls with Poisso distributio with paramtr λ = m Usig th classical Chroff boud for Poisso distributio (s g []) w dduc that Pr[Y λ ] ( ) λ, hc Pr[Y λ Y m λ m ] Pr[Y i λ ( ] m ) λ W us ow a stadard tchology (s [], sc 54 ad corollary 5) of comparig ur ad balls modl with th Poisso modl w gt th rquird rsult Usig last lmma w dduc that wh a larg umbr of balls ar draw uiformly ad idpdtly ito a fixd umbr m of urs th with high probability all urs ar occupid by at last m balls Thrfor if w icras tims radomly chos probabilistic coutr th w may xpct that with a high probability ach coutr will hav a valu at last log ( m ) Idd, w hav th followig rsult: Thorm 43: Lt Chag dot th vt that aftr modificatios of blocks th xt modificatio will chag a coutr If th Pr[Chag ] = o() Proof: Lt A dots th vt X > m X m > m From Lmma 4 w gt Pr[Ac ] m ( ) m Nxt w hav Pr[Chag ] = Pr[Chag A] Pr[A] + Pr[Chag A c ] Pr[A c ] ( ) m Pr[Chag A] + m Hc, w may assum that th vt A holds Lt us fix a idx i of a coutr Th, accordig to Eq () for sufficitly larg w hav E[C i ] > log (X i ) = log (X i /) Morovr, for sufficitly larg w hav var[c i ] < From th Chbyshv iquality w dduc that Pr[C i > E[C i]] 4 E[C i ] so udr th assumptio that th vt A holds w gt Pr[C i > log m ] 4 log m Th icrmts of approximat coutrs ar idpdt, hc m ( Pr[ C i > ) ( ) m log 4 ] m log m (o th vt A) Obsrv ow that m ( C i > ) log m < m m
Puttig all th abov pics togthr ad usig Lmma 4 w fially gt ( m + so th thorm is provd Pr[Chag ] ) m 4 + m log m ( ) m, B Cotrolld Us of Blocks Lts suppos ow that ach tim w d to modify a block w shall us th block with miimal valu of th corrspodig probabilistic coutr W call this scario of block usig a cotrolld us of blocks Notic that if a valu of a approximat coutr is C th th probability of chagig its valu aftr a sigl call of th icrmt procdur is C, hc a xpctd umbr of calls of th icrmt procdur dd to chag its valu is C Th xpctd umbr of stps to chag th iitial stat (0, 0,, 0) of th coutr C to (,,, ) is m Nxt, to chag (,,, ) ito (,,, ) w d (i avrag) stps I gral, i ordr to chag C from (a, a,, a) to (a +, a +,, a + ) w d a m stps Usig this obsrvatios ad makig som additioal calculus w gt th followig rsult: Thorm 44: Lt L dot th umbr of chags of th systm C aftr updats i th cotrolld us of blocks Th E[L ] m log ( m + ) Thrfor if w us th systm of approximat coutrs i a optimal way tims th thr will b oly O(l ) chags to th systm, so oly so may tims w should flash its cotts ito flash mmory V EXPERIMENTS I this sctio w shall discuss som umrical xprimts which hav b mad with th probabilistic coutrs i cotxt of flash mmory A Compariso of th ral ad probabilistic coutr I this xprimt w rcordd radomly k writ vts amog m blocks of flash mmory (Fig ) For ach block w maitai th probabilistic coutr (p i ) ad th ral coutr (r i ) Not, that th ral coutr is rcordd oly for th d of th xprimt ad will ot b maitaid i th ral viromt W rpatd th xprimt tims For ach block w stimat th prcisio dfid by P rc i = p i /r i Th avrag prcisio for o xprimt is: P rc j = m (P rci ) W also calculat th stadard dviatio for th xprimt dfid as Std = (pi P rc) /m W stimatd th avrag prcisio ad stadard dviatio for 0 xprimts ad w gt P rc 00 ad Std 0068 This xprimtal rsult cofirms th high prcisio of th approximat coutrs Fig Typical coutr cotts aftr o xprimt for m=00 ad k=00000 Fig 3 Th chart shows ral coutr valus wh th block with miimum approximat coutr valu is rasd Th xprimt was mad for m=00 ad k=00000 B Data distributio mthod I th scod xprimt w simulatd th data distributio i th flash mmory blocks As w mtiod bfor, th data i th mmory blocks should b distributd I our approach, w us th approximat coutr to dcid ito which mmory block to writ th data I our xprimt w ras that block, which has th smallst valu of th approximat coutr If w ras th block j, w icrmt th ral coutr valu(r j ) ad w us th probabilistic mthod for th stimatio of th approximat coutr (p j ) I figur 3 w compard th valus of both coutrs C Swap simulatio I this xprimt w simulat th situatio whr th CRS is loadd ito th mai mmory ad th aftr svral opratios o coutr valus swappd back to th blocks of flash mmory W compar th cass wh th probabilistic coutrs ad th ral coutrs ar stord i th CRS I our xprimt w assum that our CRS cosists of 0 blocks ad 00 ras opratios ar prformd o th coutrs of CRS loadd ito th mai mmory Aftr that th CRS blocks ar swappd back to th flash mmory W rpat that procdur 00 tims Figur 4 illustrats our xprimt
viromt I th futur ivstigatios w wat to combi our approximat coutrs with th ras rclamatio policis Fig 4 Typical umbr of CRS chags whr 00 swap opratios wr prformd o 0 CRS blocks ad i vry swap opratio 00 ras vts occurs REFERENCES [] S Nath ad A Kasal, Flashdb: dyamic slf-tuig databas for ad flash, i IPSN, T F Abdlzahr, L J Guibas, ad M Wlsh, Eds ACM, 007, pp 40 49 [] C-H Wu, L-P Chag, ad T-W Kuo, A fficit r-tr implmtatio ovr flash-mmory storag systms, i GIS ACM, 003, pp 7 4 [3] C-H Wu, T-W Kuo, ad L-P Chag, A fficit b-tr layr implmtatio for flash-mmory storag systms, ACM Tras Embddd Comput Syst, vol 6, o 3, 007 [4] K M Lofgr, R D Norma, G B Thli, ad Gupta, War lvlig tchiqus for flash prom systms, US Patt 6,594,83, 998 [5], War lvlig tchiqus for flash prom systms, US Patt 6,08,447, 999 [6] J M Marshall ad C D H Maig, Flash fil maagmt systm, US Patt 5,83,493, 998 [7] E Jou ad J I J H, Flash mmory war lvlig systm providig immdiat dirct accss to microprocssor, US Patt 5,568,43, 996 [8] S W Ha, Flash mmory war lvlig systm ad mthod, US Patt 6,06,75, 998 [9] R Morris, Coutig larg umbrs of vts i small rgistrs, Commu ACM, vol, o 0, pp 840 84, 978 [0] P Flajolt, Approximat coutig: A dtaild aalysis, BIT, vol 5, o, pp 3 34, 985 [] M Mitzmachr ad E Upfal, Probability ad Computig : Radomizd Algorithms ad Probabilistic Aalysis Cambridg Uivrsity Prss, Jauary 005 Fig 5 Global approximat coutrs chags aftr ras opratios for m=00 ad k=00000 D Coutrs chagig I this xprimt w show th corrlatio btw th umbr of flash mmory chags ad th umbr of coutrs chags W chagd 00000 tims th flash mmory cosistd of 00 blocks W s that i th first phas th valu of approximat coutrs icrass rapidly ad aftr th crtai umbr of modificatios gos up vry slowly Figur 5 illustrats this xprimt A thortical backgroud of this bhavior is xplaid i sc IV VI CONCLUSIONS AND FUTURE WORK I this papr w proposd a systm of approximat coutrs for flash mmory dvics I our approach ach block of th mmory is associatd with o coutr Th coutrs ar stord i th spcial ara of flash mmory calld CRS W showd that th CRS ds oly 0004 prct of th mmory Of cours it strogly dpds o flash mmory architctur I this papr w discussd statistical proprtis of th proposd mthod ad w dscribd svral xprimts which cofirm th corrctss of our mthod Th vry low mmory rquirmts is ot th oly advatag of our approach Th othr o is that th approximat coutr valus do t d to b chagd so oft as it is i th cas of th ral coutr It s a vry importat issu i flash mmory