资源描述:
《What_Every_Programmer_Should_Know_About_Memory.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、WhatEveryProgrammerShouldKnowAboutMemoryUlrichDrepperRedHat,Inc.drepper@redhat.comNovember21,2007AbstractAsCPUcoresbecomebothfasterandmorenumerous,thelimitingfactorformostprogramsisnow,andwillbeforsometime,memoryaccess.Hardwaredesignershavecomeupwithevermoresophisticatedmemoryhandli
2、ngandaccelerationtechniques–suchasCPUcaches–butthesecannotworkoptimallywithoutsomehelpfromtheprogrammer.Unfortunately,neitherthestructurenorthecostofusingthememorysubsystemofacomputerorthecachesonCPUsiswellunderstoodbymostprogrammers.Thispaperexplainsthestructureofmemorysubsys-temsi
3、nuseonmoderncommodityhardware,illustratingwhyCPUcachesweredeveloped,howtheywork,andwhatprogramsshoulddotoachieveoptimalperformancebyutilizingthem.1Introductiondaythesechangesmainlycomeinthefollowingforms:Intheearlydayscomputersweremuchsimpler.Thevar-•RAMhardwaredesign(speedandparall
4、elism).iouscomponentsofasystem,suchastheCPU,memory,massstorage,andnetworkinterfaces,weredevelopedto-•Memorycontrollerdesigns.getherand,asaresult,werequitebalancedintheirper-•CPUcaches.formance.Forexample,thememoryandnetworkinter-faceswerenot(much)fasterthantheCPUatproviding•Directme
5、moryaccess(DMA)fordevices.data.Thissituationchangedoncethebasicstructureofcom-Forthemostpart,thisdocumentwilldealwithCPUputersstabilizedandhardwaredevelopersconcentratedcachesandsomeeffectsofmemorycontrollerdesign.onoptimizingindividualsubsystems.Suddenlytheper-Intheprocessofexplori
6、ngthesetopics,wewillexploreformanceofsomecomponentsofthecomputerfellsig-DMAandbringitintothelargerpicture.However,wenificantlybehindandbottlenecksdeveloped.Thiswaswillstartwithanoverviewofthedesignfortoday’scom-especiallytrueformassstorageandmemorysubsystemsmodityhardware.Thisisaprer
7、equisitetounderstand-which,forcostreasons,improvedmoreslowlyrelativeingtheproblemsandthelimitationsofefficientlyus-toothercomponents.ingmemorysubsystems.Wewillalsolearnabout,insomedetail,thedifferenttypesofRAMandillustrateTheslownessofmassstoragehasmostlybeendealtwithwhythesedifferen
8、cesstillexist.using