Introduction
Cachereferstothememorythatcanexchangehigh-speeddata.ItexchangesdatabeforethememoryandCPU,sothespeedisveryfast.L1Cache(firstlevelcache)isthefirstlevelofCPUcache.Thecapacityandstructureofthebuilt-inL1cachehaveagreaterimpactontheperformanceoftheCPU,butthecachememoryiscomposedofstaticRAM,andthestructureismorecomplex.WhentheCPUdieareacannotbetoolarge,thecapacityoftheL1cacheisnotItmaybetoobig.Generally,thecapacityofL1cacheisusually32-256KB.L2Cache(second-levelcache)isthesecond-levelcacheoftheCPU,dividedintointernalandexternalchips.Theinternalchip'sL2cacherunsatthesamespeedasthemainfrequency,whiletheexternalL2cacheisonlyhalfofthemainfrequency.TheL2cachecapacitywillalsoaffecttheperformanceoftheCPU.Theprincipleisthatthelargerthebetter,theL2cacheofordinarydesktopCPUsisgenerally128KBto2MBorhigher,andtheL2cacheofCPUsusedonnotebooks,serversandworkstationscanreachupto1MB-3MB.Sincethehigherthespeedofthecache,themoreexpensiveitis,sosomecomputersystemshavetwoormorelevelsofcache.Thefirst-levelcacheclosetotheCPUhasthehighestspeedandthesmallestcapacity.Thesecond-levelcachehasaslightlylargercapacityandaslightlylowerspeed.
Thecacheisjustacopyofasmallpartofthedatainthememory,sowhentheCPUlooksfordatainthecache,itwillnotbefound(becausethedataisnotcopiedfromthememorytothecache).Atthattime,theCPUwillstilllookfordatainthememory,sothesystemspeedwillslowdown,buttheCPUwillcopythedatatothecachesothatitwillnotberetrievedfromthememorynexttime.Astimechanges,themostfrequentlyaccesseddataisnotstatic.Thatistosay,thedatathatwasnotfrequentlyaccessedjustnowneedstobeaccessedfrequently.Themostfrequentdatajustnowisnotfrequent,soItissaidthatthedatainthecacheshouldbereplacedfrequentlyaccordingtoacertainalgorithm,soastoensurethatthedatainthecacheisaccessedmostfrequently.
Workingprinciple
TheworkingprincipleofthecacheisthatwhentheCPUwantstoreadapieceofdata,itfirstsearchesitfromtheCPUcache,andthenreadsitimmediatelyandsendsittotheCPUforprocessing;,ItreadsfromtherelativelyslowmemoryandsendsittotheCPUforprocessing,andatthesametimetransfersthedatablockwherethedataislocatedintothecache,sothattheentireblockofdatacanbereadfromthecacheinthefuture,noneedtocallRAM.ItisthisreadmechanismthatmakestheCPUreadcachehitrateveryhigh(mostCPUscanreachabout90%),whichmeansthat90%ofthedatathattheCPUwillreadnexttimeareintheCPUcache,onlyabout10%Needstobereadfrommemory.ThisgreatlysavesthetimefortheCPUtodirectlyreadthememory,andalsomakestheCPUbasicallynoneedtowaitwhenreadingdata.Ingeneral,theorderinwhichtheCPUreadsdataiscachedfirstandthenmemory.
RAM(Random-AccessMemory)isoppositetoROM(Read-OnlyMemory).RAMistheonethatdisappearsafterpowerfailure,andtheinformationwillnotdisappearafterROMpowerfailure.whichtype.RAMisdividedintotwotypes,oneisstaticRAM,SRAM(StaticRAM);theotherisdynamicRAM,DRAM(DynamicRAM).Thestoragerateoftheformerismuchfasterthanthelatter,andthememoryusedisgenerallydynamicRAM.Inordertoincreasethespeedofthesystem,itisenoughtoexpandthecache.Thelargertheexpansion,themoredatacachedandthefasterthesystem.ThecacheisusuallystaticRAM,andthespeedisveryfast,buttheintegrationofstaticRAMislow(storageForthesamedata,thevolumeofstaticRAMis6timesthatofdynamicRAM),andthepriceishigh(staticRAMofthesamecapacityisfourtimesthatofdynamicRAM).ItcanbeseenthatexpandingstaticRAMasacacheisaverystupidbehavior,butforToimprovetheperformanceandspeedofthesystem,itisnecessarytoexpandthecache.Inthisway,thereisacompromisemethod.InsteadofexpandingtheoriginalstaticRAMcache,somehigh-speeddynamicRAMisaddedasacache.Thespeedofthesehigh-speeddynamicRAMishigherthanthatoftheconventionaldynamicRAMisfast,butslowerthantheoriginalstaticRAMcache.TheoriginalstaticRAMcacheiscalledthefirstlevelcache,andthedynamicRAMthatwasaddedlateriscalledthesecondlevelcache.
Toimintarooli
Kiintolevyvälimuisti pelaa pääasiassa kolmea roolia:
Pre-reading
WhentheharddiskiscontrolledbytheCPUinstruction,itstartstoread.Whenfetchingdata,thecontrolchipontheharddiskwillcontroltheheadtoreadthedatainthenextorseveralclustersoftheclusterbeingreadintothecache(becausethedataontheharddiskisstoredcontinuously,thereadhitrateisrelativelyhighHigh),whenthedatainthenextorseveralclustersneedstoberead,theharddiskdoesnotneedtoreadthedataagain,justtransferthedatainthecachetothememorydirectly,becausethecacherateismuchhigherthanThereadandwritespeedofthemagneticheadcanachievethepurposeofsignificantlyimprovingperformance.
Kirjoita
Välimuisti (16 kuvaa)
Whentheharddiskreceivesaninstructiontowritedata,itwillnotwritethedataimmediatelyIsstoredonthedisc,buttemporarilystoredinthecache,andthensendsa"datawritten"signaltothesystem,thenthesystemwillthinkthatthedatahasbeenwritten,andcontinuetoperformthefollowingwork,andtheharddiskisinWhenitisidle(whennotreadingorwriting),thedatainthecacheiswrittentothedisk.Althoughtheperformanceofwritingdatahasbeenimprovedtoacertainextent,italsoinevitablybringssecurityrisks-whenthedataisstillinthecache,thepowerissuddenlylost,thenthedatawillbelost.Forthisproblem,theharddiskmanufacturersnaturallyhaveasolution:whenthepowerisoff,theheadwilluseinertiatowritethedatainthecacheintoatemporarystorageareaotherthantrackzero,andthenwritethedatatothedestinationafterthenextstartup.Temporarystorage
Sometimes,somedatawillbeaccessedfrequently.Forexample,theinternalcacheoftheharddisk(akindoftemporarystorage)willstoresomefrequentlyreaddatainthecache.Itcanbetransferreddirectlyfromthecachewhenitisreadagain.Thecacheislikethememoryofacomputer.Whentheharddiskreadsandwritesdata,itisresponsiblefordatastorageandstorage.Inthisway,notonlycanthetimefordatareadandwritebegreatlyreducedtoimprovetheuseefficiencyoftheharddisk.Atthesametime,theuseofcachecanalsoreducefrequentreadsandwritesoftheharddisk,makingtheharddiskquieterandmorepower-saving.Withalargerharddiskcache,youwillbefasterwhenreadinggames,fasterwhencopyingfiles,andmoreadvancedinsystemstartup.
Thesizeofthecachecapacityisdifferentfordifferentbrandsandmodels.Theearlyharddiskcacheisbasicallyverysmall,onlyafewhundredKB,whichcannolongermeettheneedsofusers.16MBand32MBcachesarecurrentlyusedbymainstreamharddrives,andthereareproductswithlargercachecapacitiesinserversorspecialapplications,evenreaching64MB,128MB,andsoon.Althoughthelarge-capacitycachecanstoremoredatainthecachewhiletheharddiskisreadingandwriting,toincreasetheaccessrateoftheharddisk,itdoesnotmeanthatthelargerthecache,themoreoutstandingitis.Thereisanalgorithmicproblemwithcachedapplications.Evenifthecachecapacityislargewithoutanefficientalgorithm,thehitrateofcacheddataintheapplicationwillbelow,andtheadvantagesoflarge-capacitycachecannotbeeffectivelyused.Algorithmsarecomplementarytocachecapacity.Large-capacitycachesrequiremoreefficientalgorithms,otherwiseperformancewillbegreatlyreduced.Fromatechnicalpointofview,high-capacitycachealgorithmsareanimportantfactorthatdirectlyaffectstheperformanceofharddrives.Largercapacitycacheisaninevitabletrendinthedevelopmentofharddisksinthefuture.
Technologydevelopment
TheearliestCPUcachewasawhole,andthecapacitywasverylow.IntelbegantoclassifycachesfromthePentiumera.Atthattime,thecacheintegratedintheCPUcorewasnotenoughtomeettheneedsoftheCPU,andthelimitationsonthemanufacturingprocesscouldnotgreatlyincreasethecapacityofthecache.Therefore,thereisacacheintegratedonthesamecircuitboardastheCPUoronthemotherboard.Atthistime,thecacheintegratedwiththeCPUcoreiscalledthefirst-levelcache,andtheexternaloneiscalledthesecond-levelcache.Thefirstlevelcacheisalsodividedintodatacache(DataCache,D-Cache)andinstructioncache(InstructionCache,I-Cache).Thetwoarerespectivelyusedtostoredataandexecuteinstructionsforthesedata,andbothcanbeaccessedbytheCPUatthesametime,reducingconflictscausedbycontentionforCache,andimprovingprocessorperformance.WhenIntelintroducedthePentium4processor,itreplacedtheinstructioncachewithanewly-addedfirst-leveltrackingcachewithacapacityof12KμOps,whichmeansitcanstore12Kmicroinstructions.
WiththedevelopmentoftheCPUmanufacturingprocess,thesecond-levelcachecanalsobeeasilyintegratedintotheCPUcore,andthecapacityisalsoincreasingyearbyyear.WhetheritisintegratedintheCPUornottodefinethefirstandsecondlevelcachesisnolongeraccurate.Andasthesecond-levelcacheisintegratedintotheCPUcore,thepreviousdivisionofthesecond-levelcacheandtheCPUhasbeenchanged.Atthistime,itworksatthesamerateasthemainfrequency,whichcanprovideahighertransmissionratefortheCPU..Thesecond-levelcacheisoneofthekeystotheperformanceoftheCPU.WhentheCPUcoredoesnotchange,increasingthesecond-levelcachecapacitycangreatlyimprovetheperformance.AndthedifferencebetweenthehighandlowendofthesamecoreCPUisoftendifferentinthesecondlevelcache,whichshowstheimportanceofthesecondlevelcachetotheCPU.
TheCPUfindsusefuldatainthecacheiscalledahit.WhenthereisnodataneededbytheCPUinthecache(calledamissatthistime),theCPUaccessesthememory.Intheory,inaCPUwithasecond-levelcache,thehitrateforreadingthefirst-levelcacheis80%.Thatistosay,theusefuldatafoundintheCPU'sfirst-levelcacheaccountsfor80%ofthetotaldata,andtheremaining20%isreadfromthesecond-levelcache.Duetotheinabilitytoaccuratelypredictthedatatobeexecuted,thehitrateofreadingthesecond-levelcacheisalsoabout80%(readingusefuldatafromthesecond-levelcacheaccountsfor16%ofthetotaldata).Thentheremainingdatahastobecalledfrommemory,butthisisalreadyafairlysmallpercentage.Higher-endCPUswillalsohaveathird-levelcache,whichisdesignedfordatathatmissesafterreadingthesecond-levelcache—atypeofcache.InaCPUwithathird-levelcache,onlyabout3%ofthedataneedstoberetrievedfromthecache.Calledinmemory,whichfurtherimprovestheefficiencyoftheCPU.InordertoensureahighhitrateduringCPUaccess,thecontentinthecacheshouldbereplacedaccordingtoacertainalgorithm.Amorecommonlyusedalgorithmisthe"leastrecentlyusedalgorithm"(LRUalgorithm),whicheliminatesthelinesthathavebeenleastvisitedinthemostrecentperiodoftime.Therefore,itisnecessarytosetacounterforeachrow.TheLRUalgorithmclearsthecounterofthehitrowandadds1tothecountersoftheotherrows.Whenreplacementisneeded,thedatarowwiththelargestrowcountercountiseliminated.Thisisanefficientandscientificalgorithm.Itscounterclearingprocesscaneliminatesomedatathatisnolongerneededafterfrequentcallsfromthecacheandimprovetheutilizationofthecache.InCPUproducts,thecapacityofthefirstlevelcacheisbasicallybetween4KBand64KB,andthecapacityofthesecondlevelcacheisdividedinto128KB,256KB,512KB,1MB,2MB,4MB,etc.Thereisnotmuchdifferencebetweenthefirst-levelcachecapacityofeachproduct,andthesecond-levelcachecapacityisthekeytoimprovingCPUperformance.TheincreaseinthecapacityofthesecondarycacheisdeterminedbythemanufacturingprocessoftheCPU.TheincreaseincapacitywillinevitablyleadtoanincreaseinthenumberoftransistorsinsidetheCPU.TointegratealargercacheonalimitedCPUarea,therequirementsforthemanufacturingprocesswillbehigher.MainstreamCPUsecondarycachesarearound2MB,amongwhichIntelhassuccessivelyintroducedhigh-performanceCPUswith4MBand6MBsecondarycachesfordesktopcomputersin2007,butthepriceisrelativelyhigh,andtheconfigurationrequirementsarenottoohigh.Myfriend,ageneraldual-coreCPUwith2MBL2cachecanbasicallymeetdailyInternetneeds.
Mainsignificance
Theprincipleofcachingworkis"localityofreference",whichcanbedividedintotemporallocalityandspatiallocality.SpatiallocalitymeansthattheCPUneedsacertaindataatacertainmoment,soitislikelythatthenextstepwillneedthedatanearby;timelocalitymeansthatwhenacertaindataisaccessedonce,itwillbere-examinedafterashortperiodoftime.Onevisit.Forapplications,nomatteritistheinstructionfloworthedataflow,thelocalityphenomenonofreferencewillappear.
Togiveasimpleexample,forexample,whenplayingaDVDmovie,theDVDdataconsistsofaseriesofbytes.Atthistime,theCPUwillprocesstheDVDdatafromthebeginningtotheendinturn.IftheCPUreadsthistimeTheDVDdatais1minuteand30seconds,sothenexttimeitisread,itwillstartfrom1minuteand31seconds.Therefore,inthiscase,theordereddataaresequentiallyreadintotheCPUforprocessing.Fromthedatapointofview,applicationssuchasWordusuallyhavegoodspatiallocality.Inuse,userswillnotopen7or8documentsatatime,andwillnotchangeoneofthedocumentswithafewwords.Mostusersopenoneortwodocumentsandthenprocessthemforalongtimewithoutdoingotherthings.Inthisway,thedatainthememorywillbeconcentratedinonearea,anditcanbecentrallyprocessedbytheCPU.
Consideringfromtheprogramcode,designersusuallytrytoavoidprogramjumpsandbranches,sothattheCPUcanprocesslargepiecesofcontinuousdatawithoutinterruption.Games,simulations,andmultimediaprocessingprogramsareusuallyrepresentativesofthisaspect,whichcontinuouslyprocesslargeblocksofdatawithsmallpiecesofcode.Butinofficeapplications,thesituationisdifferent.Changingfonts,formatting,andsavingdocumentsallrequiredifferentpartsoftheprogramcodetowork,andtheinstructionsusedareusuallynotinacontinuousarea.SotheCPUhastojumparoundinmemorytofindthecodeitneeds.Thismeansthatforofficeprograms,alargercacheisneededtoreadinmostfrequentlyusedcodesandputtheminacontiguousarea.Ifthecacheisnotenough,youneedthedatainthememory,andifthecacheislargeenough,allthecodecanbeputin,andyoucangetthehighestefficiency.Inthesameway,high-enddataapplicationsandgameapplicationsrequireahighercapacitycache.
CPUCache
CPUCache(CacheMemory)isatemporarymemorylocatedbetweentheCPUandthememory.Itscapacityismuchsmallerthanthememorybuttheexchangerateisfasterthanthememory.many.TheappearanceofthecacheismainlytosolvethecontradictionbetweentheCPUoperationrateandthememoryreadandwriterate,becausetheCPUoperationrateismuchfasterthanthememoryreadandwriterate,whichwillmaketheCPUspendalongtimewaitingforthedatatoarriveorwritethedataintothememory.Thedatainthecacheisasmallpartofthememory,butthissmallpartisabouttobeaccessedbytheCPUinashorttime.WhentheCPUcallsalargeamountofdata,itcanavoidthememoryandcallitdirectlyfromthecache,therebyspeedingupthereadingrate..ItcanbeseenthataddingcachetotheCPUisanefficientsolution,sothattheentireinternalmemory(cache+memory)becomesahigh-speedstoragesystemwithbothcacheandmemory.ThecachehasagreatimpactontheperformanceoftheCPU,mainlyduetotheCPU'sdataexchangesequenceandthebandwidthbetweentheCPUandthecache.
ThecachebasicallyusesSRAMmemory.SRAMistheabbreviationofEnglishStaticRAM.Itisamemorywithstaticaccessfunction.Itcansavethedatastoredinitwithoutrefreshingthecircuit.UnlikeDRAMmemory,whichrequiresarefreshcircuit,theDRAMmustberefreshedandchargedeveryonceinawhile,otherwisetheinternaldatawilldisappear,soSRAMhashigherperformance,butSRAMalsohasitsshortcomings,thatis,itsintegration.Lower,DRAMmemoryofthesamecapacitycanbedesignedintoasmallervolume,butSRAMrequiresalargevolume,whichisalsoanimportantreasonwhythecachecapacitycannotbemadetoolarge.Itscharacteristicsaresummarizedasfollows:Theadvantagesareenergysaving,fastspeed,noneedtocooperatewiththememoryrefreshcircuit,andcanimprovetheoverallworkefficiency.Thedisadvantagesarelowintegration,largevolumeofthesamecapacity,andhighprice,whichcanonlybeusedinasmallamountforthekey.Sexualsystemtoimproveefficiency.
Toimintaperiaate
1.Lukujärjestys
WhentheCPUwantstoreadapieceofdata,itfirstlooksintheCache,ifIfitisfound,itwillbereadimmediatelyandsenttotheCPUforprocessing;ifitisnotfound,itwillbereadfromthememoryatarelativelyslowspeedandsenttotheCPUforprocessing.Atthesametime,thedatablockwherethedataislocatedcanbetransferredtotheCache,whichcanmakesubsequentadjustments.TheblockdataisreadfromtheCache,andthereisnoneedtocallthememory.
ItisthisreadmechanismthatmakesthehitrateofCPUreadCacheveryhigh(mostCPUscanreachabout90%),whichmeansthat90%ofthedatatobereadbytheCPUnexttimeareinIntheCache,onlyabout10%needtobereadfrommemory.ThisgreatlysavesthetimefortheCPUtodirectlyreadthememory,andalsomakestheCPUbasicallynoneedtowaitwhenreadingdata.Ingeneral,theorderinwhichtheCPUreadsdataisCachefirstandthenmemory.
2,CacheClassification
IntelhasseparatedCachefromPentium,whichisusuallydividedintofirst-levelcacheL1andsecond-levelcacheL2.Inthepastconcept,L1CacheisintegratedintheCPUandiscalledon-chipCache.InL1,therearealsodataCache(D-Cache)andinstructionCache(I-Cache).Theyarerespectivelyusedtostoredataandexecuteinstructionsforthesedata,andthetwoCachescanbeaccessedbytheCPUatthesametime,reducingconflictscausedbycompetingCachesandimprovingprocessorperformance.
3.Readhitraatti
TheCPUfindsusefuldataintheCacheiscalledahit.WhenthereisnodataneededbytheCPUintheCache(Atthistime,itiscalledamiss),theCPUonlyaccessesthememory.Theoretically,inaCPUwithLevel2Cache,thehitrateforreadingL1Cacheis80%.Thatistosay,theusefuldatafoundbytheCPUfromtheL1Cacheaccountsfor80%ofthetotaldata,andtheremaining20%isreadfromtheL2Cache.Duetotheinabilitytoaccuratelypredictthedatatobeexecuted,thehitrateofreadingL2isalsoabout80%(readingusefuldatafromL2accountsfor16%ofthetotaldata).Thentheremainingdatahastobecalledfrommemory,butthisisalreadyafairlysmallpercentage.Insomehigh-endCPUs(likeIntel’sItanium),weoftenhearL3Cache,whichisdesignedfordatathatmissesafterreadingL2Cache—akindofCache.AmongCPUswithL3Cache,thereareonlyabout5%Ofthedataneedstobecalledfrommemory,whichfurtherimprovestheefficiencyoftheCPU.
Level1Cache
Level1Cache(Level1Cache)isreferredtoasL1Cache.ItislocatednexttotheCPUcore.ItistheCPUcachethatismostcloselyintegratedwiththeCPU,anditisalsotheearliestinhistory.CPUcache.Becausethetechnicaldifficultyandmanufacturingcostofthefirst-levelcachearethehighest,theincreasedtechnicaldifficultyandcostincreasebroughtaboutbyincreasingthecapacityareverylarge,buttheperformanceimprovementbroughtbyitisnotobvious,thecostperformanceisverylow,andtheexistingfirst-levelcachehitsTherateisalreadyveryhigh,sothefirstlevelcacheisthesmallestofallcaches,muchsmallerthanthesecondlevelcache.
Thefirstlevelcachecanbedividedintothefirstleveldatacache(DataCache,D-Cache)andthefirstlevelinstructioncache(InstructionCache,I-Cache).Thetwoareusedtostoredataanddecodetheinstructionsthatexecutethesedatainrealtime,andbothcanbeaccessedbytheCPUatthesametime,reducingconflictscausedbycontentionforCache,andimprovingprocessorperformance.ThefirstleveldatacacheandthefirstlevelinstructioncacheofmostCPUshavethesamecapacity.Forexample,AMD’sAthlonXPhasa64KBlevelonedatacacheanda64KBleveloneinstructioncache.Thefirstlevelcacheisrepresentedby64KB+64KB,AndtherestoftheCPU'sL1cacherepresentationmethodcanbededucedbyanalogy.
Intel'sCPUwithNetBurstarchitecture(themosttypicalisPentium4)hasaspeciallevelofcache,usinganewlyaddedleveloftracecache(ExecutionTraceCache,T-CacheorETC))Toreplacethefirst-levelinstructioncache,withacapacityof12KμOps,whichmeansthatitcanstore12Kor12000decodedmicro-instructions.Theoperatingmechanismofthefirst-leveltrackingcacheandthefirst-levelinstructioncacheisdifferent.Thefirst-levelinstructioncacheonlydecodesinstructionsinrealtimeanddoesnotstoretheseinstructions,whilethefirst-leveltrackingcachealsodecodessomeinstructions.Instructionsarecalledmicro-ops,andthesemicro-instructionscanbestoredinthefirst-leveltracecache,andthereisnoneedtodecodetheprogrameverytime.Therefore,thefirst-leveltracecachecaneffectivelyincreasethenumberofinstructionsunderhighoperatingfrequency.Thedecodingcapabilityofthemicro-ops,andμOpsismicro-ops,whichmeansmicro-operation.Itprovidesμopstotheprocessorcoreataveryhighrate.TheIntelNetBurstmicro-architectureusesanexecutiontrackingcachetoseparatethedecoderfromtheexecutionloop.Thistracecacheprovidesuopstothecorewithahighbandwidth,whichisessentiallysuitableformakingfulluseoftheinstruction-levelparallelmechanisminthesoftware.Intelhasnotannouncedtheactualcapacityofthefirst-leveltrackingcache,butonlyknowsthatthefirst-leveltrackingcachecanstore12,000micro-ops(micro-ops).Therefore,youcannotsimplyusethenumberofmicroinstructionstocomparethesizeoftheinstructioncache.Infact,thesingle-coreNetBurstarchitectureCPUusing8Kμopscacheisbasicallyenough,andtheextra4kμopscangreatlyimprovethecachehitrate.Ifyouwanttousehyper-threadingtechnology,12KμOpswillbesomewhatinsufficient,whichiswhysometimesIntelprocessorswillcauseperformancedegradationwhenusinghyper-threadingtechnology.Forexample,theNorthwoodcore'sfirst-levelcacheis8KB+12KμOps,whichmeansitsfirst-leveldatacacheis8KB,andthefirst-leveltrackingcacheis12KμOps;andthePrescottcore'sfirst-levelcacheis16KB+12KμOps,whichmeansitsfirst-leveldatacacheis16KB,Thefirst-leveltrackingcacheis12KμOps.Here,12KμOpsisdefinitelynotequalto12KB,andtheunitsarealldifferent,oneisμOpsandtheotherisByte(byte),andtheiroperatingmechanismsarecompletelydifferent.SothosewhosimplyaddthefirstlevelcacheofIntel'sCPU,forexample,saythattheNorthwoodcoreisa20KBfirst-levelcache,andthePrescottcoreissaidtobea28KBfirst-levelcache,andbasedonthis,itisconsideredthatthefirst-levelcachecapacityofIntelprocessorsisfarTheviewthattheprimarycachecapacityofAMDprocessorsislowerthan128KBiscompletelywrong,andthetwoarenotcomparable.InthecomparisonofCPUswithdifferentarchitectures,itisdifficultformanycachestofindthecorrespondingthings.Evencacheswithsimilarnameshavedifferentdesignideasandfunctiondefinitions.Atthistime,simplearithmeticadditioncannotbeusedforcomparison;andinthearchitectureInaverysimilarCPUcomparison,itmakessensetocomparethecachesizesofvariousfunctionsseparately.
Level2cache
Level2cache,itissomebuffermemoryinsidetheprocessor,itsfunctionisthesameasmemory.Datingbacktothe1980s,astheprocessorwasrunningfasterandfaster,slowly,thespeedatwhichtheprocessorneededtoreaddatafromthememorybecamehigherandhigher.However,therateofincreaseofthememoryspeedisveryslow,andthepriceofthememorythatcanreadandwritedataathighspeedisveryhighandcannotbewidelyadopted.Fromtheperspectiveofperformance-priceratio,Intelandotherprocessordesignandproductioncompanieshavecomeupwithasolution,whichistouseasmallamountofhigh-speedmemoryincombinationwithalargeamountoflow-speedmemorytoprovidedatafortheprocessortogether.Inthisway,theoptimalperformanceandcostofusearebothconsidered.Thosehigh-speedmemoryarecalledbuffermemory,or"cache"forshort,becausetheyarelocatedbetweenthecpuandthememoryandarealsotheplacewheredataistemporarilystored.Itsfunctionislikeaplacewheregoodsaretemporarilystackedinawarehouse.Whenthegoodsareplacedfromthetransportvehicle,theyaretemporarilystackedinthebufferarea,andthenmovedtotheinternalstorageareaforlong-termstorage.Thegoodsarestoredinthisareaforashorttime,whichisatemporarycargoyard.Initially,thecachewasonlylevelone,buttheprocessorspeedincreasedandthelevelonecachewasnotenough,sothesecondlevelcachewasadded.Thesecond-levelcacheisamemorywithaslowerspeedandalargercapacitythanthefirst-levelcache.Itismainlyusedfortemporaryexchangeofdatabetweenthefirst-levelcacheandthememory.Inordertoadapttothefasterprocessorp4ee,thethird-levelcachehasappeared.Itscapacityislargerandthespeedisslowerthanthesecond-levelcache,butitismuchfasterthanthememory.Theappearanceofthecachehasgreatlyimprovedtheoperatingefficiencyofthecpuprocessor.Thisareastoresdatathatisfrequentlyusedbythecpu.Therefore,thelargerthecache,thehighertheefficiencyoftheprocessor.Atthesametime,thephysicalstructureofthecacheislargerthanthatofthememory.Alotofcomplexity,soitscostisalsoveryhigh.
Theresultofextensiveuseofsecondarycacheistheimprovementofprocessoroperatingefficiencyandthesubstantialincreaseincostandprice.Forexample,thecoresoftheXeonprocessorusedontheserverandtheordinaryp4processorarebasicallythesame,thatis,thesecond-levelcacheisdifferent.Xeon'ssecond-levelcacheis2mb-16mb,p4'ssecond-levelcacheis512kb,sothecheapestXeonisalsomoreexpensivethanthemostexpensivep4,thereasonisthatthesecond-levelcacheisdifferent.Thatisl2cache.DuetothelimitationoftheL1levelcachecapacity,inordertoincreasethecomputingspeedofthecpuagain,ahigh-speedmemory,namelytheleveltwocache,isplacedoutsidethecpu.Theworkingfrequencyismoreflexible,anditcanbethesamefrequencyasthecpuordifferent.Whenthecpureadsdata,itfirstlooksinl1,thenfroml2,thenthememory,andthentheexternalmemory.Therefore,theimpactofl2onthesystemcannotbeignored.
Theearliestcpucacheisawhole,andthecapacityisverylow,Intelhasclassifiedthecachesincethepentiumera.Atthattime,thecacheintegratedinthecpucorewasnolongersufficienttomeettheneedsofthecpu,andthelimitationsonthemanufacturingprocesscouldnotgreatlyincreasethecapacityofthecache.Therefore,thereisacacheintegratedonthesamecircuitboardasthecpuoronthemotherboard.Atthistime,thecacheintegratedwiththecpucoreiscalledthefirst-levelcache,andtheexternaloneiscalledthesecond-levelcache.Withthedevelopmentofthecpumanufacturingprocess,thesecond-levelcachecanalsobeeasilyintegratedintothecpucore,andthecapacityisalsoincreasingyearbyyear.Itisnolongeraccuratetodefinethefirstandsecondlevelcacheswhethertheyareintegratedinthecpuornot.Andasthesecond-levelcacheisintegratedintothecpucore,thepreviousdivisionofthesecond-levelcacheandthecpuhasbeenchanged.Atthistime,itworksatthesamerateasthemainfrequency,whichcanprovideahighertransmissionrateforthecpu..
Three-levelcache
L3Cache(three-levelcache)isdividedintotwotypes,theearlyonewasexternal,andgraduallybecamebuilt-in.AnditsactualeffectisthattheapplicationofL3cachecanfurtherreducememorylatency,andatthesametimeimprovetheperformanceoftheprocessorwhencomputinglargeamountsofdata.Reducingmemorylatencyandimprovingthecomputingpoweroflargeamountsofdataareveryhelpfulforgames.TheadditionofL3cacheintheserverfieldstillhasasignificantimprovementinperformance.Forexample,aconfigurationwithalargerL3cachewillusephysicalmemorymoreefficiently,soitsslowerdiskI/Osubsystemcanhandlemoredatarequests.ProcessorswithlargerL3cachesprovidemoreefficientfilesystemcachingbehaviorandshortermessageandprocessorqueuelengths.
Infact,theearliestL3cachewasappliedtotheK6-IIIprocessorreleasedbyAMD.Atthattime,theL3cachewaslimitedbythemanufacturingprocessandwasnotintegratedintothechip,butintegratedonthemotherboard.Infact,theL3cache,whichcanonlybesynchronizedwiththesystembusfrequency,isnotmuchdifferentfromthemainmemory.Later,theL3cachewasusedbyIntel'sItaniumprocessorfortheservermarket.ThenthereareP4EEandXeonMP.IntelalsoplanstointroduceanItanium2processorwith9MBL3cacheandadual-coreItanium2processorwith24MBL3cacheinthefuture.
ButbasicallytheL3cacheisnotveryimportanttotheperformanceimprovementoftheprocessor.Forexample,theXeonMPprocessorwith1MBL3cacheisstillnotOpteron'sopponent.Itcanbeseenthattheincreaseinfront-sidebusisbetterthanIncreasedcachebringsmoreeffectiveperformanceimprovement.
SuperCache
SuperCache,alsoknownasSuperCache,thespeedbottleneckofthecomputerismainlythereadandwritespeedofthemechanicalharddisk.SuperCacheuseshigh-speedmemoryfortheharddiskreadandwriteasacache.Itisthefirstchoiceforspeedinguplargememorymachinesandanindispensabletoolforservers.
Workingprinciple:ForSuperCache,thereisnoconceptoffilesontheharddisk.Itisjustasmallgridofauser-specifiedsize,suchas32k.Thecontentofasmallgridontheharddiskisread,thenItiscachedinthememory,andthenexttimethissmallgridisread,itisreaddirectlyfromthememorywithoutanyactionontheharddisk,thusachievingthepurposeofacceleration.Therearetwocachemodes,1.MFUmode,wheneachsmallgridisread,asimplecountismade.Whenthecacheisfull,thesmallercountvaluewillbeclearedoutofthecachefirst;2.MRUmode,simpleQueue,firstinfirstout.
Systemcache
ComparingtheCPUtoafurniturefactoryinthecity,andcomparingthestoragesystemtoawoodfactoryinthesuburbs,theactualsituationisthatthewoodfactoryisgettingawayfromthefurniturefactory.Evenifalargertruckisusedtotransportthewood,thefurniturefactoryhastostopworkandwaitforthewoodtoarrive.Insuchasituation,onesolutionistobuildasmallwarehouseintheurbanareaandplacesomewoodmaterialsmostcommonlyusedbyfurniturefactories.Thiswarehouseisactuallythe"Cache"ofthefurniturefactory,andthefurniturefactorycancontinuouslydeliverthewoodneededintimefromthewarehouse.Ofcourse,thelargerthewarehouseandthemorewoodstored,thebettertheeffect,becauseeventhelesscommonlyusedthingscanbefoundinthewarehouse.Ifthereisnowoodinthewarehouse,wewillcontinuetolookforitfromthewoodfactoryoutsidethecity,andthefurniturefactorywillhavetowait.ComparedwiththeL1cache,thewarehousecanbereadandwrittenintimeandquicklybytheCPU,soitstoresthemostcommonlyusedcodesanddataoftheCPU(howtoselectthe"mostcommonlyused"willbeintroducedlater).TheL1cacherateismuchfasterthansystemmemorybecauseitusesSRAM,whichusesfourtosixtransistorsonasinglechipofmemory.ThisalsomakesthecostofSRAMquitehigh,soitcannotbeusedintheentirestoragesystem.OnmostCPUs,theL1cacheandthecoreareonthesamechip.Inthecaseofafurniturefactory,itislikeafactoryandawarehouseonthesamestreet.ThisdesignallowstheCPUtogetdatafromthenearestandfastestplace,butitalsomakesthedistancebetweenthe"woodfactoryoutsidethecity"andthe"warehouse"andthe"furniturefactory"almostfaraway.Inthisway,thedatarequiredbytheCPUisnotintheL1cache,thatis,"CacheMiss",andittakesalongtimetofetchdatafromthestoragedevice.Thefastertheprocessorspeed,thegreaterthegapbetweenthetwo.Usingahigh-frequencyprocessorlikePentium4,gettingdatafromthememoryisequivalenttothe"timberfactory"locatedinanothercountry.
Infact,thecacheisapartoftheCPU.ItexistsintheCPUatwhichtheCPUaccessesdataataveryfastrate.Itcanaccessandprocessonebillioninstructionsanddatainonesecond(term:CPUfrequency1G),andthememoryismuchslower.Fastmemorycanreachtensofmegabytes.Itcanbeseenhowthespeeddifferencebetweenthetwois.ThebigcacheistosolvetheproblemofthedifferencebetweentheCPUspeedandthememoryspeed.ThememoryisthemostaccessedbytheCPU.FrequentdataandinstructionsarecopiedintothecacheintheCPU,sothattheCPUcannotoftenfetchdatafromtheslowmemorylikea"snail".TheCPUonlyneedstofetchitfromthecache,andthecacherateisfasterthanMemoryismuchfaster.Specialpointstobepointedouthereare:1.Becausethecacheisonlyacopyofasmallpartofthedatainthememory,whentheCPUlooksfordatainthecache,itwillnotbefound(becausethedataisnotcopiedfromthememorytotheCache).Atthistime,theCPUwillstillfinddatainthememory,sothesystemspeedwillslowdown,buttheCPUwillcopythedatatothecachesothatitwillnotberetrievedfromthememorynexttime.2.Astimechanges,themostfrequentlyaccesseddataisnotstatic,thatistosay,thedatathatisnotfrequentlyaccessedjustnowneedstobeaccessedfrequently.Justnowitwasthemostfrequentlyaccesseddata,andthenitwasnot.Frequent,sothedatainthecacheshouldalwaysbereplacedaccordingtoacertainalgorithm,soastoensurethatthedatainthecacheisthemostfrequentlyaccessed3.Regardingthefirstlevelcacheandthesecondlevelcache,inordertodistinguishthesetwoconcepts,wefirstUnderstandtherelativerelationshipbetweenRAMandROM.RAMistheonewhoseinformationdisappearsafterpowerfailure,andROMistheonewhoseinformationwillnotdisappearevenafterpowerfailure.RAMisdividedintotwotypes:oneisstaticRAMandSRAM;theotherisdynamicRAMandDRAM.
Diskcache
Diskcacheisdividedintoreadcacheandwritecache.Readcachemeansthattheoperatingsystemkeepsthefiledatathathasbeenreadinthememoryspacewhenthememoryisrelativelyfree(thismemoryspaceiscalledthe"memorypool"),andthenexttimethesoftwareortheuserreadsthesameThefiledoesnothavetobereadfromthediskagain,therebyincreasingthespeed.Thewritecacheactuallysavesthedatatobewrittentothediskinthememoryspaceallocatedbythesystemforthewritecache.Whenthedatasavedinthememorypoolreachesacertainlevel,thedataissavedtotheharddisk.Thiscanreduceactualdiskoperations,effectivelyprotectthediskfromdamagecausedbyrepeatedreadandwriteoperations,andreducethetimerequiredforwriting.
Accordingtothedifferentwritingmethods,therearetwotypes:write-throughandwrite-back.Whenreadingtheharddiskdatainthewritegeneralmode,thesystemfirstcheckstherequestcommandtoseeiftherequireddataisinthecache.Ifso,thecachesendstheresponsedata.Thisprocessiscalledahit.Inthisway,thesystemdoesnothavetoaccessthedataintheharddisk.SincethespeedofSDRAMismuchfasterthanthatofmagneticmedia,thespeedofdatatransmissionisaccelerated.Thewrite-backtypeistofindthedatainthecachewhentheharddiskdataiswritten,andwhenthedataisfound,thecachewillwritethedatatothedisk.Mostharddisksusethewrite-backcache,whichgreatlyimprovestheperformance.TheEnglishnameofthecacheisCache.CPUcacheisalsoakindofmemory,withfastdataexchangerateandhighfrequencyofoperation.Diskcacheisamemoryareaallocatedinordinaryphysicalmemorybytheoperatingsystemfordiskinputandoutput.
Theharddiskbuffer,theharddiskbufferistheplacewheretheharddiskexchangesdatawiththeexternalbus.Theprocessofharddiskreadingdataistoconvertmagneticsignalsintoelectricalsignals,fillandemptythebufferagainandagain,fillagain,andthenempty,stepbystepaccordingtothecycleofthePCIbus.Itcanbeseenthattheroleofthebufferisveryimportant.of.Itsroleisalsotoimproveperformance,butitisdifferentfromthecachein:1.Itisafixed-capacityhardware,unlikethecachethatcanbedynamicallyallocatedinthememorybytheoperatingsystem.Second,itsimpactonperformancegreatlyexceedstheimpactofdiskcachingonperformance.Becausethereisnobuffer,itwillberequiredtoreadorwritetothediskeverytimeaword(usually4bytes)istransferred.
Cachemapping
Välimuisti voidaan jakaa suoraan kartoitusvälimuistiin, ryhmäassosiatiiviseen välimuistiin ja täysin assosiatiiviseen välimuistiin.
Suorakartoitusvälimuisti
Tämän tyyppisessä välimuistissajokainen ryhmä vainyksi rivi,E=1jarakenne onhyvin yksinkertainen.Koko välimuisti vastaa yksiulotteista ryhmien joukkoa.Rivinvaihtotapauksessa ei ole liian helppoa,joka ei ole juurikivessä. nopeus,tietyt tietolohkot+1 muistikerroksessa voidaan vainkorvata tietyllä sijainnilla muistin ylemmän kerroksen (eli kerroksen) kohdalla. Olettaen, että välimuisti on suoraan kartoitettu, (S,E, B,m)=(4,1,2,4),joka tarkoittaa,etheaddressis4bits(16),onneljä ryhmää,jokainen ryhmäyksirivi,kaksitavuinen lohko.Koska osoitteita on 16, edustavat 16 tavua, on 8 lohkoayhteensä,mutta useaa lohkoa voidaan vain neljänkertaisena, sama välimuistiryhmä.Esimerkiksi 0 ja 4 yhdistetään ryhmään 1, 1 ja 5 yhdistetään ryhmään 2 ja pian. Tässä tulee ongelma.Esimerkiksi kun lohko0luetaan ensin,lohkon0tiedot tallennetaan välimuistiin ryhmään0.SittenIreadblock4uudelleen,koska lohko4onliimattu ryhmään0,ja ryhmässä0 on vain yksi rivi, joten edellisen lohkon0datakirjoitetaan alaskirjoitettuun. er-levelmemorytodet.Todellisessa sykliohjelmassa on helppo aiheuttaa tämä tilanne, jota kutsutaan värinäksi. Tämän tilanteen olemassaolo vaikuttaa luonnollisesti suuresti suorituskykyyn. Siksi tarvitaan parempi kartoitus.
Ryhmässosiaatiovälimuisti
Ryhmän assosiatiivisessa välimuistissa, ei suurempi kuin 1, mikä tarkoittaa, että ryhmässä on useita kätkölinjoja.
Thematchingofgroup-associatedrowsisabitmorecomplicated,becausethemarkbitandvalidbitofmultiplerowsneedtobechecked.Ifyoufinditintheend,it'sokay.Ofcourse,therowcontainingtherequireddatawillberemovedfromthenextlevelofstorageforreplacementifitcannotbefound,butwithsomanyrowsinagroup,whichrowtoreplace.Ifthereisablankline,itisnaturaltoreplacetheblankline.Ifthereisnoblankline,thensomeotherreplacementstrategiesaretriggered.Inadditiontotherandomstrategyintroducedjustnow,therearealsotheleastfrequentlyusedstrategies,andtheleastrecentlyusedstrategies.Thesestrategiesthemselvesrequireacertainamountofoverhead,butyoumustknowthattheoverheadofmissesisverylarge,soinordertoensurethehitrate,itisworthwhiletoadoptsomerelativelycomplicatedstrategies.
Fullyassociativecache
Theso-calledfullyassociativecacheisacachecomposedofagroupcontainingallcachelines(blockscanbeplacedanywhereinthecache).Sincethereisonlyonegroup,thegroupselectionisparticularlysimple.Atthistime,theaddressdoesnothaveagroupindex,onlythemarkandoffset,thatis,thetpartandthebpart.Theothersteps,rowmatchinganddataselection,andtheprincipleofgroupassociationarethesame,butthescaleismuchlarger.Iftheabovedescriptionofthesethreemappingmethodsisveryabstract,inordertobeabletounderstandmorethoroughly,comparethememorytoalargesupermarket,thethingsinthesupermarketarebytesordata.Inordertomakeiteasytoseedelicious,funandpopularthings,thesupermarketcanputthesethingstogetherinaspecialrecommendationcounter,whichisthecache.Ifyoujustputthesegoodsonthecounterandyouaredone,thenthisisacompletelyrelatedway.
Butifyouwanttofindwhatyouwant,youhavetolookfortheserecommendedgoods,andbecauseoftheuncertainlocation,youmayevensearchtheentirerecommendationcounter.Thisefficiencyisundoubtedlynothigh.Sothemanagerofthesupermarketdecidedtoadoptanothermethod,whichistodivideallrecommendedgoodsintomanycategories,suchas"jambiscuits","chocolatebiscuits","walnutmilk",etc.,andstoreonekindofgoodsoneachfloorofthecounter.Thisistheprincipleofdirectassociationaccess.Theadvantageofthisisthatitiseasyforcustomerstohaveatargeted,quickerandmoreeffectivesearch.
Butthismethodstillhasitsdisadvantages,thatis,iftherearemanycustomerswhoneedjambiscuits,andtherearerelativelyfewcustomerswhoneedchocolatebiscuits,obviouslythedemandforjambiscuitswillbefarmorethanthatofchocolatebiscuits.Thedemand,butthespaceforplacingthetwotypesofbiscuitsisthesame,sothissituationmayoccur:thestoragespaceforjambiscuitsisfarfrommeetingthemarketdemand,andthestoragespaceforchocolatebiscuitsisleftunused.Inordertoovercomethisshortcoming,thebossdecidedtoimprovetheinventorymethod:orclassifythegoods,buttheclassificationmethodhaschanged,accordingto"biscuits","milk","juice"andothercategoriesofinventory,thatis,nomatterwhatkindofbiscuitscanbeStoredinthespaceusedby"biscuits",thismethodobviouslyimprovesthesufficiencyofspaceutilizationandmakesstorageandsearchmethodsmoreflexible.
Technicalindicators
InCPUproducts,thecapacityofthefirstlevelcacheisbasicallybetween4kband64kb,andthecapacityofthesecondlevelcacheisdividedinto128kb,256kb,512kb,1mb,2mbWait.Thereisnotmuchdifferencebetweenthefirst-levelcachecapacityofeachproduct,andthesecond-levelcachecapacityisthekeytoimprovingcpuperformance.Theincreaseinthecapacityofthesecond-levelcacheisdeterminedbythecpumanufacturingprocess.Theincreaseincapacitywillinevitablyleadtoanincreaseinthenumberofinternaltransistorsinthecpu.Tointegratealargercacheonalimitedcpuarea,therequirementsforthemanufacturingprocesswillbehigher./p>
CachesizeisoneoftheimportantindicatorsofCPU,anditsstructureandsizehaveagreatinfluenceonCPUspeed.Simplyput,thecacheisusedtostoresomecommonlyusedorabouttobeuseddataorinstructions.Whenthesedataorinstructionsareneeded,theyaredirectlyreadfromthecache.Thisismuchfasterthanreadingfromthememoryoreventheharddisk.Significantlyincreasetheprocessingrateofthecpu.Theso-calledprocessorcacheusuallyreferstothesecondarycache,orexternalcache.Thatis,thehigh-speedbuffermemoryisasmall-scalebuthigh-speedmemorylocatedbetweentheCPUandthemainmemorydram(dynamicram),usuallycomposedofsram(staticrandomaccessmemory).Usedtostoredatathatisfrequentlyusedbythecpu,sothatthecpudoesnothavetorelyontheslowerdram(dynamicrandomaccessmemory).L2cachehasalwaysbeenatypeofmemorywithextremelyfastspeedandveryexpensiveprice,calledsram(staticram),sram(staticram)istheEnglishabbreviationofstaticmemory.Becausesramusesthesamesemiconductorprocessasmakingcpu,comparedwithdynamicmemorydram,sramhasafasteraccessrate,butithasalargervolumeandahighprice.
Thebasicideaoftheprocessorcacheistouseasmallamountofsramasthebufferbetweenthecpuandthedramstoragesystem,thatis,thecachesystem.Anotablefeatureof80486andhigher-endmicroprocessorsisthattheprocessorchipintegratessramasacache.Becausethesecachesareinstalledinthechip,theyarecalledon-chipcaches.Thecachecapacityofthe486chipisusually8k.High-endchipssuchaspentiumare16kb,andpowerpcscanreach32kb.Thepentiummicroprocessorfurtherimprovestheon-chipcache,usingdataanddual-channelcachetechnology.Relativelyspeaking,theon-chipcachehasasmallcapacity,butitisveryflexibleandconvenient,whichgreatlyimprovestheperformanceofthemicroprocessor.On-chipcacheisalsocalledlevelonecache.Duetothehighclockfrequencyofhigh-endprocessorssuchas486and586,oncethefirstlevelcachemisses,theperformancewillbesignificantlydeteriorated.Inthiscase,themethodusedistoaddacacheinadditiontotheprocessorchip,whichiscalledasecondarycache.Thesecondarycacheisactuallytherealbufferbetweenthecpuandthemainmemory.Sincetheresponsetimeonthesystemboardismuchlowerthantherateofthecpu,itisimpossibletoachievetheidealrateofhigh-endprocessorssuchas486and586withoutthesecondarycache.Thecapacityofthesecond-levelcacheshouldgenerallybemorethananorderofmagnitudelargerthanthatofthefirst-levelcache.Inthesystemsettings,usersareoftenrequiredtodeterminewhetherthesecondarycacheisinstalledandthesize.Thesizeofthesecondarycacheisgenerally128kb,256kbor512kb.Inmicrocomputersabove486,256kbor512kbsynchronouscacheiscommonlyused.Theso-calledsynchronizationmeansthatthecacheandcpuusethesameclockcycleandworksynchronouslyatthesamerate.Comparedwithasynchronouscache,theperformancecanbeimprovedbymorethan30%.OneofthedevelopmenttrendsofthepcanditsserversystemisthattheCPUfrequencyisgettinghigherandhigher,thesystemarchitectureisgettingmoreandmoreadvanced,andtheimprovementofthestructureandaccesstimeofthemainmemorydramisslower.Therefore,thecachetechnologyisbecomingmoreandmoreimportant,andthecacheisgettingbiggerandbiggerinthepcsystem.ThemajorityofusershaveregardedcacheasanimportantindicatorforevaluatingandpurchasingPCsystems.
Opticaldrivecache
Opticalstoragedriveshaveinternalbuffersorcachememory.Thesebuffersareactualmemorychips,mountedonthecircuitboardofthedrive,whichmayprepareorstorelargerdatasegmentsbeforesendingdatatothePC.ThetypicalbuffersizeforCD/DVDis128KB,butthespecificdrivecanbelargeorsmall(usuallythemorethebetter).ArecordableCDorDVDdrivegenerallyhasalarge-capacitybufferof2MB-4MBormoretopreventbufferunderrunerrorsandatthesametimemaketherecordingworksmoothandconstantwriting.Generallyspeaking,thefasterthedrive,themorebuffermemorytohandlethehighertransferrate.
CD/DVDdriveswithbufferingorcachinghavemanyadvantages.BufferingcanensurethatthePCreceivesdataatafixedrate.Whenanapplicationrequestsdatafromthedrive,thedatamaybelocatedindifferentplacesscatteredonthedisc.Becausetheaccessrateofthedriveisrelativelyslow,thedrivehastosenddatatothePCatintervalswhenreadingdata.Thebufferofthedrivecanreadandpreparethecontentdirectoryoftheopticaldiscinadvanceunderthecontrolofthesoftware,thusspeedingupthefirstdatarequest.
ThelawforCD-ROMdrivetoreaddataistosearchinthecachefirst.Ifitisnotfoundinthecache,itwillsearchonthedisc.Thelarge-capacitycachecanreadmoredatainadvance,butinpracticalapplicationsInCD-ROM,DVD-ROMandotherreadoperations,thechanceofreadingrepeatedinformationisrelativelysmall.Mostoftheopticaldiscsaremoreoftenreadmorefilesatatime.,TheimportanceofcacheonDVD-ROMdrivesisnotreflected,somostoftheseproductsusesmallercachecapacity.CD-ROMgenerallyhasseveralkindsof128KB,256KB,512KB;andDVDgenerallyhas128KB,256KB,512KB,onlyindividualexternalDVDdriveadoptslargercapacitycache.
OnrecordersorCOMMBOproducts,cachingbecomesveryimportant.Whenburningadisc,thesystemwillpre-readthedatathatneedstobeburnedintothecache,andthenreadthedatafromthecacheforburning.Thecacheisthebridgebetweenthedataandtheburningdisc.Whenthesystemtransfersdatatothecache,itisinevitablethattherewillbeatransmissionpause.Forexample,whenburningalargenumberofsmall-capacityfiles,theharddiskreadingratemaynotkeepupwiththeburningrate,whichwillresultinthedatainthecache.Theinputandoutputarenotproportional.Ifthisstatecontinuesforaperiodoftime,itwillcauseallthedatainthecachetobeoutput,andnoinputwillbeobtained.Atthistime,itwillcauseacacheunderloaderror,whichwillleadtoafailuretoburnthedisc.Therefore,therecorderandCOMMBOproductswillusealargercachecapacity,coupledwiththeanti-engravingtechnology,canminimizetheprobabilityofburningabaddisk.Atthesametime,thecachecanalsocoordinatethedatatransmissionratetoensurethestabilityandreliabilityofdatatransmission.
Burnerproductsgenerallyhave2MB,4MB,8MB,andCOMBOproductsgenerallyhave2MB,4MB,8MBcachecapacity.Duetothelimitationofmanufacturingcost,thecachecannotbemadelargeenough.Buttherightamountofcachecapacityisstilloneofthekeystoconsiderwhenchoosingopticalstorage
NetworkCache
Concept
WWWisoneofthemostpopularapplicationsontheInternet,Itsrapidgrowthhascausednetworkcongestionandserveroverload,resultinginincreasedcustomeraccessdelays,andWWWservicequalityhasbecomeincreasinglyapparent.Cachetechnologyisconsideredtobeoneoftheeffectivewaystoreduceserverload,reducenetworkcongestion,andenhancethescalabilityofWWW.Itsbasicideaistousetheprincipleoftemporallocalityofcustomeraccess(TemproralLocality)tostorethecontentaccessedbycustomersintheCacheStoreacopy.Whenthecontentisaccessednexttime,itdoesnotneedtobeconnectedtotheresidentwebsite,butisprovidedbythecopykeptintheCache.
Webcontentcanbecachedontheclientside,proxyserver,andserverside.StudieshaveshownthatcachingtechnologycansignificantlyimproveWWWperformance,anditcanbringthefollowingbenefits:(1)Reducenetworktraffic,therebyreducingcongestion.
(2)Tärkeimmät syyt asiakkaiden pääsyviiveen vähentämiseen ovat:
①Thecontentcachedintheproxyservercanbeobtaineddirectlyfromtheproxyinsteadoffromtheremoteserver.Reducedtransmissiondelay;
②Thecontentthatisnotcachedcanbequicklyobtainedbycustomersduetonetworkcongestionandthereductionofserverload.
(3)Agentilta voidaan saada sisältöä asiakkaan pyynnöstä, etäpalvelimen kuormitusta vähennetään.
(4)Iftheremoteserverfailstorespondtotheclient'srequestduetoaremoteserverfailureornetworkfailure,theclientcanobtainacopyofthecachedcontentfromtheproxy,whichenhancestherobustnessoftheWWWservice.
Webcachingsystemwillalsobringthefollowingproblems:
(1)Asiakkaan välityspalvelimen kautta saatava sisältö saattaa olla vanhentunut.
(2)Ifacachefailureoccurs,theclient'saccessdelaywillincreaseduetotheadditionalproxyprocessingoverhead.Therefore,whendesigningaWebcachingsystem,weshouldstrivetomaximizethecachehitrateandminimizethecostoffailure.
(3)Theproxymaybecomeabottleneck.Therefore,anupperlimitofthenumberofservicecustomersandalowerlimitofserviceefficiencyshouldbesetforanagent,sothattheefficiencyofanagentsystemisatleastthesameastheefficiencyofaclientdirectlyconnectedtoaremoteserver.
AffecttheInternetaccessrate
TheprocessofaccessingthewebsiteiscompletedbytheHTTPprotocolbuiltontopoftheTCP/IPprotocol.SincetheclientsendsanHTTPrequest,thewaitingtimeexperiencedbytheuserismainlydeterminedbytheresponsetimeoftheDNSandthewebsite.ThedomainnameofthewebsitemustfirstberesolvedtoanIPaddressbytheDNSserver,andthedelayofHTTPisdeterminedbythenumberofround-triptimesbetweentheclientandtheserver.Theround-triptimereferstothetimetheclientwaitsfortheresponseofeachrequest.Theaverageround-triptimedependsonthreeaspects:
VerkkosivustoPalvelinViive
Thedelaycausedbythewebserveraccountsforthemainproportionoftheroundtriptime.WhenaserverreceivesmultipleconcurrentHTTPrequests,queuingdelaywilloccur.SincerespondingtoanHTTPrequestoftenrequiresmultipleaccesstothelocalharddisk,evenaserverwithasmallloadmayhaveadelayoftensorhundredsofmicroseconds.
Reitittimien, yhdyskäytävien, välityspalvelinten ja palomuurien aiheuttama viive
ThereareusuallymultiplenetworksinthepathbetweentheclientandtheserverEquipment,suchasrouters,gateways,proxies,firewalls,etc.Theyallneedtostore/forwardthepassingIPpackets,soqueuingdelayandprocessingdelaywillbeintroduced.Whenthenetworkiscongested,thesedevicesmayevenlosepackets.Atthistime,theyhopethattheclientandserverwillresumecommunicationthroughanend-to-endprotocol.
Erilaiset viestintälinkitTiedonsiirtonopeus
Inawideareanetwork,fromonenetworkdevicetoanothernetworkdeviceThedatatransferratebetweentimeisanimportantfactorindeterminingtheround-triptime.Buttheroleofbasicbandwidthisnotasimportantaspeoplethink.AtestshowsthatwhenawebsiteusesT3speedtoaccesstheInternet,only2%ofwebpagesorobjectscanbeprovidedtotheclientatarateof64kbps,whichisobviouslyShowsthatbandwidthisnotthemostcriticalfactorinnetworkperformance.
TheInternetisextendingtoeverycorneroftheworld.Auser'srequesttoaservermaytraveladistanceof8,000kilometersto16,000kilometers.ThedelaycausedbythespeedoflightandthedelayofnetworkequipmentisthenetworkThemostfundamentalreasonforsuchslowness.
Verkon välimuisti ratkaisee perustavanlaatuisen ongelman
Sincethereasonthataffectsthenetworkspeediscausedbydistanceandthespeedoflight,theonlywaytospeedupWebaccessistoshortentheclientThedistancefromthewebsite.Bystoringthepagesandobjectsfrequentlyvisitedbyusersclosertotheuser,thedelayintroducedbythespeedoflightcanbereduced.Atthesametime,thedelayintroducedbyrouters,firewallsandproxiesisalsoreducedduetothereductionoflinksintherouting..
Thetraditionalsolutionistoestablishamirrorservertoachievethepurposeofshorteningthedistance.Butthismethodhasgreatshortcomings.Foracertainsite,itisimpossibletoestablishamirrorsiteclosetoeachusergroup.Itisevenmoreuneconomicaltousethismethodformostofthesites,anditwillbemanagedatthesametime.Andmaintainingmirrorsitesisaverydifficulttask.
NetworkcachingisanemergingnetworktechnologythatreducesInternettrafficandimprovesend-userresponsetime.Itsconceptcomesfromotherareasofcomputersandnetworks.Forexample,thereisacacheinthepopularIntel-basedCPUtoincreasetherateofmemoryaccess;variousoperatingsystemsalsousecachetoincreasetheratewhenaccessingdisks.;Distributedfilesystemsusuallyalsousecachingtoimprovethespeedbetweentheclientandtheserver.
Tyyppi
Staattisten sivujen välimuistiin tallentamiseen voi olla kaksi muotoa: Itse asiassa suurin ero on siinä, onko CMS itse vastuussa liittyvän sisällön välimuistipäivityksen hallinnasta.
1.Staticcaching:Itisastaticpagethatgeneratescorrespondingcontentimmediatelywhennewcontentisreleased.Forexample,onMarch22,2003,aftertheadministratorenteredanarticlethroughthebackgroundcontentmanagementinterface,Andsynchronouslyupdatethelinksontherelevantindexpages.
2.Dynamiccaching:Afterthenewcontentisreleased,thecorrespondingstaticpageisnotgeneratedinadvanceuntilthecorrespondingcontentisrequested,ifthefront-endcacheservercannotfindthecorrespondingcache,itwillsendtheback-endcontentThemanagementserversendsarequest,andthebackgroundsystemgeneratesastaticpageofthecorrespondingcontent.Theusermaybeslowerwhenaccessingthepageforthefirsttime,butinthefuture,itwilldirectlyaccessthecache.
Staattisen välimuistin haitat:
Complextriggerupdatemechanism:Thesetwomechanismsareverysuitablewhenthecontentmanagementsystemisrelativelysimple.Butforawebsitewithacomplicatedstructurediagramofanetworkcachesystem,thelogicalreferencerelationshipbetweenpagesbecomesavery,verycomplicatedproblem.Themosttypicalexampleisthatanewsitemshouldappearonthenewshomepageand3relatednewstopicsatthesametime.Inthestaticcachemode,eachnewarticleisposted,inadditiontothepageofthenewscontentitself,thesystemneedstobetriggered.Thebrowsergeneratesmultiplenewrelatedstaticpages,andthetriggeringoftheserelatedlogicoftenbecomesoneofthemostcomplexpartsofthecontentmanagementsystem.
Batchupdateofoldcontent:Thecontentpublishedbystaticcacheisdifficulttomodifythecontentofthepreviouslygeneratedstaticpage,sothatwhenusersvisittheoldpage,thenewtemplatewillnottakeeffectatall.
Inthedynamiccachemode,eachdynamicpageonlyneedstobeconcerned,andotherrelatedpagescanbeautomaticallyupdated,whichgreatlyreducestheneedtodesignrelatedpageupdatetriggers.
Thenetworkcachecanbeontheclientsideoronthenetwork,sowedividethecacheintotwocategories:browsercacheandproxycache.
Almostallbrowsershaveabuilt-incache,theyusuallyusetheclient'slocalmemoryandharddisktocompletethecachework,whileallowinguserstocontrolthesizeofthecachedcontent.Browsercachingisanextremecaseofnetworkcaching,becausethecachingislocatedlocallyontheclient.Usuallyaclienthasonlyoneuserorafewsharedcomputerusers,andtheharddiskspacerequiredbythebrowsercacheisusuallyintherangeof5MBto50MB.However,thebrowsercacheisdifficulttosharebetweenusers,andthecachesofdifferentclientscannotcommunicate,sothecontentandeffectsofthecachearequitelimited.
Proxycachingisanindependentapplicationlayernetworkservice,whichismorelikeE-mail,Web,DNSandotherservices.Manyuserscannotonlysharethecache,butalsoaccessthecontentinthecacheatthesametime.Enterprise-levelproxycachesgenerallyneedtobeconfiguredwithhigh-endprocessorsandstoragesystems,usingdedicatedsoftware,therequiredharddiskspaceisabout5MBto50GB,andthememoryis64MBto512MB.
Theproxyisbetweentheclientandthewebsiteserver.Insomecases,thisconnectionisnotallowed.Forexample,ifthewebsiteisinafirewall,theclientmustestablishaTCPconnectionwiththeproxy,andthenTheproxyestablishesaTCPconnectionwiththewebsiteserver.Theproxyactsasadatarelaybetweentheserverandtheclient.TheHTTPrequestsentbytheproxyisslightlydifferentfromthegeneralHTTPrequest,mainlyinthatitcontainsthecompleteURL,notjustthepathoftheURL.
VälivälimuistiHowitworks
Whentheproxycachereceivesarequestfromtheclient,itfirstcheckstherequestedcontentWhetherithasbeencached.Ifitisnotfound,thecachemustforwardtherequestonbehalfoftheclient,andwhenreceivingthefilefromtheserver,saveitinacertainformonthelocalharddiskandsendittotheclient.
Ifthecontentrequestedbytheclienthasbeencached,therearetwopossibilities:First,thecachedcontentisoutofdate,thatis,thecontentstoredinthecacheexceedsthepresettimelimit,orthewebsiteserverThewebpagehasbeenupdated.Atthistime,thecachewillasktheoriginalservertoverifythecontentinthecache.Eitherupdatethecontentorreturnan"unmodified"message;second,thecachedcontentisnew,thatis,itissynchronizedwiththecontentoftheoriginalwebsite.Thisiscalledacachehit.Atthistime,thecachewillimmediatelysendthesavedcontenttotheclient.
Whentheclient'srequestdoesnothit,itincreasestheprocessingtimeofcachestorageandforwarding.Inthiscase,doesproxycachingstillmakesense?Infact,theproxycachecanestablishmultipleconcurrentTCP/IPconnectionswiththewebsiteserveratthesametimetoobtainthecontentonthewebsiteinparallel.Theexistenceofthecachereducesthenumberofvisitstothewebsiteasawhole,andalsoreducesthenumberofqueuesontheserversideperunittime,sothequeuingdelayofconcurrentconnectionsismuchsmalleratthistime.Excellentcachingcanevenrealizetheprefetchingofrelatedlinksinwebpagestospeeduptheconnectionrate.
Välivälityspalvelinstrategia
Whentheoriginalserver’sfilesaremodifiedordeleted,howdoesthecacheknowhowit’ssaved?Isthecopyobsolete?TheHTTPprotocolprovidesbasicsupportforthecacheservice.Itenablesthecachetoquerytheoriginalserverwhetherafileischanged,andifthecachedcopyisoutofdate,itwillbeconditionallydownloaded.Onlywhentheoriginalserverfileexceedsthespecifieddate,anewfilewillbeissued.
However,theloadcausedbythesequeryoperationsonthewebserverisalmostthesameasthatofobtainingthefile,soitisimpossibletoperformsuchoperationswhentheclientinitiatesarequesttothecache.TheHTTPprotocolallowstheservertoselectivelyspecifythelifetimeofeachdocument,thatis,clearlyindicatetheeffectivelifecycleofafile,andtheshortlifetimemeans"don'tcacheit".Theretentiontimeofthecopycanbefixed,oritcanbecalculatedfromthesize,source,timetolive,orcontentofthefile.
Distributedcache
Thedistributedcachesystemistosolvethebottleneckbetweenthedatabaseserverandthewebserver.Ifawebsitehasalotoftraffic,thisbottleneckwillbeveryobvious,andeachdatabasequerywillconsumeaconsiderableamountoftime.Forwebsitesthatarenotupdatedveryquickly,wecanusestaticizationtoavoidexcessivedatabasequeries.Forwebsiteswhoseupdatespeedismeasuredinseconds,staticizationisnottooideal,andacachingsystemcanbeusedtobuildit.Ifonlyasingleserverisusedasacache,theproblemwillnotbetoocomplicated.Iftherearemultipleserversusedasacache,theloadbalancingofthecacheservermustbeconsidered.
UseMemcacheddistributedcachingservicetosavetheuser'ssessiondata,andachievethepurposeofeachfunctionalmodulebeingabletosharetheprivatedatainthissessionacrossprovincesandservers.EachprovinceusesoneserverastheMemcachedservertostorethedatainthesession.Ofcourse,multipleserverscanbeused,butthenumberofMemcachedserversineachprovincemustbethesame,soastoensuretheMemcachedclientTheoperationisthesamepieceofdatatoensuredataconsistency.
Lisää, poista ja muokkaa istuntotietoja
Memcachedclient,whenadding,deleting,andmodifyingsessioninformationdata,youmustnotonlyadd,delete,ModifytheMemcachedserverdatainthisprovince,andatthesametimedothesameoperationonMemcahedserversinotherprovinces,sothatuserscanaccessthesamesessiondatawhenaccessingthefunctionalmodulesofserversinotherprovinces.TheMemcachedclientserverlistusestheintranetIPofthelocalareanetwork(suchas:192.168.1.179)tooperatetheMemcahedserverinthisprovince,andthepublicIP(suchas:202.183.62.210)tooperatetheMemcaheserverinotherprovinces.
Lukuistunnon tiedot
ThelistofMemcachedclientserversforallmodulesofthesystemtoreadsessiondataaresettotheintranetIPoftheMemcachedserveraddressinthisprovinceToreadthesessiondatafromtheMemcahedserver.
Saman istunnon vahvistus
Usecookiestokeepthecustomerintouchwiththeserver.Atthebeginningofeachsession,aGUIDisgeneratedastheSessionIDandstoredinthecookieoftheclient.Thescopeisthetop-leveldomainname,sothatthesecond-levelandthird-leveldomainnamescansharethiscookie,andthesystemusesthisSessionIDtoconfirmwhetheritisthesameAconversation.
AinutlaatuinenIDofthessiondata
TheuniquekeyofthesessiondatastoredontheMemcachedserver.TheKey,whichistheuniqueIDofthesessiondata,isdefinedas:SessionID_Name,SessionIDistheSessionIDstoredintheclientcookie,andNameisthenameofthesessiondata.TheNameofeachsessiondatainthesamesessionmustbeunique,otherwisethenewsessiondatawilloverwritetheoldsessiondata.
Istunnon vanhenemisaika
Theexpirationofthesessionisachievedbycontrollingtheeffectivetimeofthecookie.ThesessiontimeissettotheSessionIDortheeffectivetimeinthecookie.AndeachtimetheSessionIDisaccessed,theeffectivetimeofthecookiemustbereset,sothattheeffectivetimeofthesessionreachedisthelongesttimefortheSessionIDvalueinthecookiebetweentwovisits.Iftheintervalbetweenthetwovisitsexceedstheeffectivetime,TheCookiesavedintheSessionIDwillbeinvalid,andanewSessionIDwillbegeneratedandstoredintheCookie,theSessionIDchanges,andthesessionends.InvalidationofsessiondataintheMemcachedserver,everytimesessiondataisaddedtotheMemcacheserver,theeffectivetimeissettooneday,whichis24hours,sothattheMemcachedserviceusesitsinternalmechanismtoclearit,andthereisnoneedtospecializethesessiondataintheprogram.Deleteoperation.ThevalidtimeofthedataintheMemcacheserverisonlylogical.Evenafter24hours,ifthememoryallocatedtotheMemcachedserviceissufficient,thedataisstillstoredinthememory,buttheMemcacheclientcannotreadit.OnlywhenthememoryallocatedtotheMemcachedserviceisnotenough,itwillcleanupuselessorrelativelyolddata,thatis,lazycleaning.
Howtoincreasethecache
CPUcache
CPUcacheisdividedintotwolevels:L1(firstlevelcache)andL2(secondlevelcache),whenWhentheprocessorwantstoreaddata,itmustfirstlookintheL1cache,thentheL2cache,andfinallythesystemmemory.Ifonedayyoufindthatyourcomputerisalotslower,andittakesafewminutestoentertheWindowsdesktop,youshouldcheckwhetherthefirstandsecondcachesoftheCPUareturnedon.IntheStandardCMOSSetup(standardCMOSsetting)intheBIOSsettings,twoitemsareusedtoturnonorturnoffthecache:whenCPUInternalCacheissettoEnable,turnonthefirstlevelbufferwithintheCPU,andifitissettoDisabl,itwillturnoff.Atthistime,thesystemperformanceWillbegreatlyreduced;ExternalCacheoptionistocontrolthesecond-levelbufferonthemotherboard,ifthereisasecond-levelcacheonthemotherboard,itshouldbesettoEnable.
Kiintolevyvälimuisti
Napsauta "Käynnistä"/"Suorita"tietokoneen työpöydällä, kirjoita "Msconfig" käynnistääksesi"SystemConfigurationUtility" ja valitse sitten"system.ini"-välilehti "Vcache"-kohdassa.Voit säätää kiintolevyvälimuistia järjestelmäntodellisen yleisen säännön mukaan. option: ChunkSize=1024, MaxFileCache=10240andMinFileCache=10240;ensimmäinen rivi onpuskurinreadandwrite-yksikönarvo,toinen jakolmas riviovat kiintolevyn maksimi- ja vähimmäispuskuriarvot,ja yhtäsuuruusmerkki. oryon 128 Mt,edellä olevankolmen rivin arvo on tietysti järkevämpää, voit myös mukauttaa sitä. Jos et tiedä kuinka asettaa sopiva puskuriarvo, ole hyvä ja "WindowsOptimizer"apua.On"DiskCacheOptimizer" tai anna "WindowsOptimizer"auttaa automaattisesti optimoimaan asetukset. Kun kiintolevyn välimuistin arvo on tarpeeksi suuri, kiintolevyä ei tarvitse lukea ja kirjoittaa levyä usein, mikä voi pidentää kiintolevyn käyttöikää ja lisätä tiedonsiirtonopeutta.
Lisäksi kiintolevyn "FileSystemCachen" asettaminen"verkkopalvelimeen" voi nopeuttaa järjestelmän pääsyä kiintolevylle, koska tiedostojärjestelmävälimuisti tallentaa tiedostonimen ja äskettäin käytetyn kiintolevyn polun. Mitä suurempi välimuisti, sitä enemmän"sisältöä"/lomake" "FileSystem"/"HardDisk",muuta"MainUseofThisComputer"arvosta" Työpöytä"verkkopalvelimeksi",voit muuttaaalkuperäisen10KVälimuisti on kasvanut noin 50k.
Cachingoffloppy drive and CD-ROM drive
Yleensä tietojen luku- ja kirjoitusnopeus on suhteellisen hidas. Tämä johtuu siitä, ettälevyn nopeus ei voi olla liian korkea.Voimme kuitenkin lisätä levykeasemaa :Kirjoita "Regedit""Käynnistä"/"Suorita"-ruutuun työpöydällä rekisterieditoriin, kirjoita HKEY-LOCAL-MACHINE\System\CurrentControlSet \Services\Class\FDC\0000,andcreateanewoneasForeFifo"DWORDvalue",asetivaluetoksi"0",jotta levykeasema on ollut pehmeästi nopeutunut. Monet ihmiset tietävät, että napsauta hiiren kakkospainikkeella"MyComputer"-kuvaketta työpöydällä"/"PerectS" ", ja asetaparhaanpääsymenetelmäksi"QuadrupleSpeedorHigher",Dragtheadditionalcachesizeslider-liukusäädintämaksimiasentoon,mikä voi parantaa merkittävästi CD-ROM-aseman lukunopeutta. Tämän menetelmän lisäksi voimme rekisteröidä e)kohdassa HKEY-LOCAL-MACHINE\System\CurrentControlSet\Control\FileSystem\CDFSAndPrefetch(pre-reading filesize) säädetään manuaalisesti, niin kauan kuin napsautat hiiren oikeaa painiketta, voit muokata sitä.