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.
Funkční role
Keše pevného disku hraje hlavně tři role:
Pre-reading
WhentheharddiskiscontrolledbytheCPUinstruction,itstartstoread.Whenfetchingdata,thecontrolchipontheharddiskwillcontroltheheadtoreadthedatainthenextorseveralclustersoftheclusterbeingreadintothecache(becausethedataontheharddiskisstoredcontinuously,thereadhitrateisrelativelyhighHigh),whenthedatainthenextorseveralclustersneedstoberead,theharddiskdoesnotneedtoreadthedataagain,justtransferthedatainthecachetothememorydirectly,becausethecacherateismuchhigherthanThereadandwritespeedofthemagneticheadcanachievethepurposeofsignificantlyimprovingperformance.
Zápis
Cache (16 fotografií)
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.
Princip práce
1.Pořadí čtení
WhentheCPUwantstoreadapieceofdata,itfirstlooksintheCache,ifIfitisfound,itwillbereadimmediatelyandsenttotheCPUforprocessing;ifitisnotfound,itwillbereadfromthememoryatarelativelyslowspeedandsenttotheCPUforprocessing.Atthesametime,thedatablockwherethedataislocatedcanbetransferredtotheCache,whichcanmakesubsequentadjustments.TheblockdataisreadfromtheCache,andthereisnoneedtocallthememory.
ItisthisreadmechanismthatmakesthehitrateofCPUreadCacheveryhigh(mostCPUscanreachabout90%),whichmeansthat90%ofthedatatobereadbytheCPUnexttimeareinIntheCache,onlyabout10%needtobereadfrommemory.ThisgreatlysavesthetimefortheCPUtodirectlyreadthememory,andalsomakestheCPUbasicallynoneedtowaitwhenreadingdata.Ingeneral,theorderinwhichtheCPUreadsdataisCachefirstandthenmemory.
2,Klasifikace mezipaměti
IntelhasseparatedCachefromPentium,whichisusuallydividedintofirst-levelcacheL1andsecond-levelcacheL2.Inthepastconcept,L1CacheisintegratedintheCPUandiscalledon-chipCache.InL1,therearealsodataCache(D-Cache)andinstructionCache(I-Cache).Theyarerespectivelyusedtostoredataandexecuteinstructionsforthesedata,andthetwoCachescanbeaccessedbytheCPUatthesametime,reducingconflictscausedbycompetingCachesandimprovingprocessorperformance.
3. Readhirate
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
Cache lze rozdělit na cache přímého mapování, skupinovou asociativní cache a plně asociativní cache.
Mezipaměť přímého mapování
V tomto typu mezipaměti má každá skupina pouze jednu řadu, E=1, a struktura je velmi jednoduchá. Celý soubor je ekvivalentní jednorozměrnému poli skupin. Nahrazení čáry v případě chyb je velmi jednoduché, pouze jedna čára, která není všechna.místo poté+1vrstvapamětimůže býtnamístěnapouzepodmnožinouumístěnívhornívrstvě(tedy,tétévrstvě)paměti.Za předpokladu přímo mapované mezipaměti,(S,E, B,m)=(4,1,2,4),to je řekněme,hlavová adresa je 4bity(16),jsou čtyřiskupiny,každáskupinavjednomřádku,dvabyte ample,0a4jsoumapoványdoskupiny1,1a5jsoumapoványdoskupiny2 a brzy. Zde nastává problém.Například,když je blok0 poprvé přečten,databloku0seuložídoskupiny0.Potom jsem znovu přečetl blok4,protožeblok4jetaképřimapovándoskupiny0askupina0jepouzevjednomřádku,takžedatapředchozíhobloku0budou přepsána. Skutečný program cyklu snadno způsobí tuto situaci, která se nazývá jitter. Existence této situace má přirozeně velký vliv na výkon. Proto je zapotřebí lepší schéma mapování.
Skupinová pasociativní mezipaměť
Ve skupině asociativní mezipaměti je E větší než 1, což znamená, že ve skupině je několik klecí.
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)Hlavní důvody pro snížení zpoždění přístupu k zákazníkovi jsou:
①Thecontentcachedintheproxyservercanbeobtaineddirectlyfromtheproxyinsteadoffromtheremoteserver.Reducedtransmissiondelay;
②Thecontentthatisnotcachedcanbequicklyobtainedbycustomersduetonetworkcongestionandthereductionofserverload.
(3)V rámci požadavku klienta lze obsah získat od agenta, zátěž na vzdáleném serveru je snížena.
(4)Iftheremoteserverfailstorespondtotheclient'srequestduetoaremoteserverfailureornetworkfailure,theclientcanobtainacopyofthecachedcontentfromtheproxy,whichenhancestherobustnessoftheWWWservice.
Webcachingsystemwillalsobringthefollowingproblems:
(1)Obsah získaný klientem prostřednictvím serveru proxy může být zastaralý.
(2)Ifacachefailureoccurs,theclient'saccessdelaywillincreaseduetotheadditionalproxyprocessingoverhead.Therefore,whendesigningaWebcachingsystem,weshouldstrivetomaximizethecachehitrateandminimizethecostoffailure.
(3)Theproxymaybecomeabottleneck.Therefore,anupperlimitofthenumberofservicecustomersandalowerlimitofserviceefficiencyshouldbesetforanagent,sothattheefficiencyofanagentsystemisatleastthesameastheefficiencyofaclientdirectlyconnectedtoaremoteserver.
AffecttheInternetaccessrate
TheprocessofaccessingthewebsiteiscompletedbytheHTTPprotocolbuiltontopoftheTCP/IPprotocol.SincetheclientsendsanHTTPrequest,thewaitingtimeexperiencedbytheuserismainlydeterminedbytheresponsetimeoftheDNSandthewebsite.ThedomainnameofthewebsitemustfirstberesolvedtoanIPaddressbytheDNSserver,andthedelayofHTTPisdeterminedbythenumberofround-triptimesbetweentheclientandtheserver.Theround-triptimereferstothetimetheclientwaitsfortheresponseofeachrequest.Theaverageround-triptimedependsonthreeaspects:
WebServerZpoždění
Thedelaycausedbythewebserveraccountsforthemainproportionoftheroundtriptime.WhenaserverreceivesmultipleconcurrentHTTPrequests,queuingdelaywilloccur.SincerespondingtoanHTTPrequestoftenrequiresmultipleaccesstothelocalharddisk,evenaserverwithasmallloadmayhaveadelayoftensorhundredsofmicroseconds.
Zpoždění zavedenésměrovače, brány, proxy servery a firewally
ThereareusuallymultiplenetworksinthepathbetweentheclientandtheserverEquipment,suchasrouters,gateways,proxies,firewalls,etc.Theyallneedtostore/forwardthepassingIPpackets,soqueuingdelayandprocessingdelaywillbeintroduced.Whenthenetworkiscongested,thesedevicesmayevenlosepackets.Atthistime,theyhopethattheclientandserverwillresumecommunicationthroughanend-to-endprotocol.
OndifferentcommunicationlinksRychlost přenosu dat
Inawideareanetwork,fromonenetworkdevicetoanothernetworkdeviceThedatatransferratebetweentimeisanimportantfactorindeterminingtheround-triptime.Buttheroleofbasicbandwidthisnotasimportantaspeoplethink.AtestshowsthatwhenawebsiteusesT3speedtoaccesstheInternet,only2%ofwebpagesorobjectscanbeprovidedtotheclientatarateof64kbps,whichisobviouslyShowsthatbandwidthisnotthemostcriticalfactorinnetworkperformance.
TheInternetisextendingtoeverycorneroftheworld.Auser'srequesttoaservermaytraveladistanceof8,000kilometersto16,000kilometers.ThedelaycausedbythespeedoflightandthedelayofnetworkequipmentisthenetworkThemostfundamentalreasonforsuchslowness.
Síťové ukládání do mezipaměti řeší základní problém
Sincethereasonthataffectsthenetworkspeediscausedbydistanceandthespeedoflight,theonlywaytospeedupWebaccessistoshortentheclientThedistancefromthewebsite.Bystoringthepagesandobjectsfrequentlyvisitedbyusersclosertotheuser,thedelayintroducedbythespeedoflightcanbereduced.Atthesametime,thedelayintroducedbyrouters,firewallsandproxiesisalsoreducedduetothereductionoflinksintherouting..
Thetraditionalsolutionistoestablishamirrorservertoachievethepurposeofshorteningthedistance.Butthismethodhasgreatshortcomings.Foracertainsite,itisimpossibletoestablishamirrorsiteclosetoeachusergroup.Itisevenmoreuneconomicaltousethismethodformostofthesites,anditwillbemanagedatthesametime.Andmaintainingmirrorsitesisaverydifficulttask.
NetworkcachingisanemergingnetworktechnologythatreducesInternettrafficandimprovesend-userresponsetime.Itsconceptcomesfromotherareasofcomputersandnetworks.Forexample,thereisacacheinthepopularIntel-basedCPUtoincreasetherateofmemoryaccess;variousoperatingsystemsalsousecachetoincreasetheratewhenaccessingdisks.;Distributedfilesystemsusuallyalsousecachingtoimprovethespeedbetweentheclientandtheserver.
Typ
Můžou existovat dvě formy ukládání statických stránek do mezipaměti: Ve skutečnosti je hlavní rozdíl v tom, zda za správu aktualizace mezipaměti souvisejícího obsahu odpovídá samotný CMS.
1.Staticcaching:Itisastaticpagethatgeneratescorrespondingcontentimmediatelywhennewcontentisreleased.Forexample,onMarch22,2003,aftertheadministratorenteredanarticlethroughthebackgroundcontentmanagementinterface,Andsynchronouslyupdatethelinksontherelevantindexpages.
2.Dynamiccaching:Afterthenewcontentisreleased,thecorrespondingstaticpageisnotgeneratedinadvanceuntilthecorrespondingcontentisrequested,ifthefront-endcacheservercannotfindthecorrespondingcache,itwillsendtheback-endcontentThemanagementserversendsarequest,andthebackgroundsystemgeneratesastaticpageofthecorrespondingcontent.Theusermaybeslowerwhenaccessingthepageforthefirsttime,butinthefuture,itwilldirectlyaccessthecache.
Nevýhody statického ukládání do mezipaměti:
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.
ProxycacheJak to funguje
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.
ProxycachingStrategie
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.
Přidat, odstranit a upravit data relace
Memcachedclient,whenadding,deleting,andmodifyingsessioninformationdata,youmustnotonlyadd,delete,ModifytheMemcachedserverdatainthisprovince,andatthesametimedothesameoperationonMemcahedserversinotherprovinces,sothatuserscanaccessthesamesessiondatawhenaccessingthefunctionalmodulesofserversinotherprovinces.TheMemcachedclientserverlistusestheintranetIPofthelocalareanetwork(suchas:192.168.1.179)tooperatetheMemcahedserverinthisprovince,andthepublicIP(suchas:202.183.62.210)tooperatetheMemcaheserverinotherprovinces.
Údaje o čtení
ThelistofMemcachedclientserversforallmodulesofthesystemtoreadsessiondataaresettotheintranetIPoftheMemcachedserveraddressinthisprovinceToreadthesessiondatafromtheMemcahedserver.
Potvrzení téhož zasedání
Usecookiestokeepthecustomerintouchwiththeserver.Atthebeginningofeachsession,aGUIDisgeneratedastheSessionIDandstoredinthecookieoftheclient.Thescopeisthetop-leveldomainname,sothatthesecond-levelandthird-leveldomainnamescansharethiscookie,andthesystemusesthisSessionIDtoconfirmwhetheritisthesameAconversation.
JedinečnéIDdat relace
TheuniquekeyofthesessiondatastoredontheMemcachedserver.TheKey,whichistheuniqueIDofthesessiondata,isdefinedas:SessionID_Name,SessionIDistheSessionIDstoredintheclientcookie,andNameisthenameofthesessiondata.TheNameofeachsessiondatainthesamesessionmustbeunique,otherwisethenewsessiondatawilloverwritetheoldsessiondata.
Doba vypršení relace
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.
Vyrovnávací paměť pevného disku
Klikněte na "Start"/"Spustit" na ploše počítače, zadejte "Msconfig" pro spuštění "SystemConfigurationUtility" a poté vyberte záložku "system.ini" pod položkou "Vcache", můžete upravit mezipaměť pevného disku podle skutečného stavu konfigurací systému. Velikost = 1024, MaxFileCache=10240andMinFileCache=10240;první řádek je hodnota jednotky čtení a zápisu vyrovnávací paměti, druhý a třetí řádek jsou maximální a minimální hodnoty vyrovnávací pamětipevného disku a rovnají se MB.18me. ,hodnota výše uvedených tří linií je samozřejmě rozumnější, můžete si ji také přizpůsobit. Pokud nevíte, jak nastavit příslušnou hodnotu vyrovnávací paměti, požádejte o pomoc "WindowsOptimizer".V tomto softwaru je položka "DiskCacheOptimizer" a můžete to snadno nastavit; nebo "WindowsOptimizer" vám automaticky pomůže optimalizovat nastavení. Když je hodnota mezipaměti pevného disku dostatečně velká, pevný disk nemusí často číst a zapisovat disk, což může prodloužit životnost pevného disku a zvýšit rychlost přenosu dat.
Navíc, nastavení "FileSystemCache" pevného disku"NetworkServer" může urychlit přístup systému k pevnému disku, protože mezipaměť systému souborů ukládá název souboru a cestu k pevnému disku, ke kterému se nedávno přistoupilo. Čím větší mezipaměť, tím více obsahu lze uložit. změnit "Hlavní použití tohoto počítače" z" Desktop"na"NetworkServer",můžete změnit původní 10KCache se zvětšila na přibližně 50K.
Ukládání disketové jednotky a jednotky CD-ROM do mezipaměti
Obecně řečeno, rychlost čtení a zápisu dat z disketové jednotky je poměrně nízká.To proto, že rychlost disku nemůže být příliš vysoká. Můžeme však zvýšit. Pole Start"/"Spustit" na ploše pro spuštění editoru registru zadejte HKEY-LOCAL-MACHINE\System\CurrentControlSet \Services\Class\FDC\0000 a vytvořte nový jako ForeFifo"DWORDvalue", nastavte jeho hodnotu na "0", takže disketová jednotka byla mírně zrychlena. Mnoho lidí ví, že klikněte pravým tlačítkem na ikonu "Můj počítač" na ploše, vyberte "Vlastnosti/Systém"/"Properties"/" a nastavte nejlepší přístupovou metodu na "Čtyřnásobná rychlostnebo Vyšší", Přetáhněte další velikosti mezipaměti posuvník na maximální pozici, což může výrazně zlepšit rychlost čtení mechaniky CD-ROM. Kromě této metody můžeme také nastavit hodnotu vyrovnávací paměti v registru a nastavit hodnotu CAL zadáním registru -MACHINE\System\CurrentControlSet\Control\FileSystem\CDFSAndPrefetch (velikost souboru před čtením) se upravují ručně, pokud na položku, kterou chcete vybrat, kliknete pravým tlačítkem, můžete ji upravit.