In the previous chapter, you took a first stab at optimizing your app by profiling your shaders and using Instruments to find even more bottlenecks to get rid of. In this chapter, you’ll look at:
CPU-GPU Synchronization
Multithreading
GPU Families
Memory Management
Best Practices
CPU-GPU synchronization
Always aim to minimize the idle time between frames.
Managing dynamic data can be a little tricky. Take the case of Uniforms. You’re changing them usually once per frame on the CPU. That means that the GPU has to wait until the CPU has finished writing the buffer before it can read the buffer. Instead, you can simply have a pool of reusable buffers.
Triple buffering is a well-known technique in the realm of synchronization. The idea is to use three buffers at a time. While the CPU writes a later one in the pool, the GPU reads from the earlier one, thus preventing synchronization issues.
You might ask, why three and not just two or a dozen? With only two buffers, there’s a high risk that the CPU will try to write the first buffer again before the GPU finished reading it even once. With too many buffers, there’s a high risk of performance issues.
Before you implement the triple buffering, use Instruments to run a Metal System Trace (MST) session and get a baseline level of the CPU activity:
Notice that most tasks peak at about 10% and this is fine, assuming that the GPU has enough work to do on its own without waiting for more work from the CPU.
All right, time to implement that triple buffering pool like a champ!
Open the starter project that comes with this chapter. In Scene.swift, replace this line:
var uniforms = Uniforms()
With this code:
static let buffersInFlight = 3
var uniforms = [Uniforms](repeating: Uniforms(),
count: buffersInFlight)
var currentUniformIndex = 0
Here, you replaced the uniforms variable with an array of three buffers and defined an index to keep track of the current buffer in use.
Here, you adapted the update method to include the new uniforms array and created a way to have the index loop around always taking the values 0, 1 and 2.
Back in Renderer.swift, add this line to draw(in:), before the renderables loop:
let uniforms = scene.uniforms[scene.currentUniformIndex]
Replace scene.uniforms with uniforms in the two places Xcode complains about.
Build and run the project. It’ll show the same scene as before. Run another MST session and notice that now the CPU activity has increased.
This is both good news and bad news. It’s good news because that means the GPU is not getting more work to do. The bad news is that now the CPU and the GPU will spar over using the same resources.
This is known as resource contention and involves conflicts, called race conditions, over accessing shared resources by both the CPU and GPU. They’re trying to read/write the same uniform, causing unexpected results.
In the image below, the CPU is ready to start writing the third buffer again. However, that would require the GPU to have finished reading it, which is not the case here.
What you need here is a way to delay the CPU writing until the GPU has finished reading it.
In Chapter 8, “Character Animation,” you solved this synchronization issue in a naive way by using waitUntilCompleted() on your command buffer. A more performant way, however, is the use of a synchronization primitive called a semaphore, which is a convenient way of keeping count of the available resources — your triple buffer in this case.
Here’s how a a semaphore works:
Initialize it to a maximum value that represents the number of resources in your pool (3 buffers here).
Inside the draw call the thread tells the CPU to wait until a resource is available and if one is, it takes it and decrements the semaphore value by one.
If there are no more available resources, the current thread is blocked until the semaphore has at least one resource available.
When a thread finishes using the resource, it’ll signal the semaphore by increasing its value and by releasing the hold on the resource.
Time to put this theory into practice.
At the top of Renderer, add this new property:
var semaphore: DispatchSemaphore
In init(metalView:), add this line before super.init():
At the end of draw(in:), but before committing the command buffer, add this:
commandBuffer.addCompletedHandler { _ in
self.semaphore.signal()
}
At the end of draw(in:), remove:
commandBuffer.waitUntilCompleted()
Build and run the project again, making sure everything still renders fine as before.
Run another MST session and compare the performance metrics with the previous ones.
If you look at the GFX bar under your specific graphics processor, the gaps are all narrower now because the GPU is not sitting idle as much as it was sitting before. You can intensify the rendering workload by increasing the number of trees, rocks or grass blades, and then the gaps might be completely gone. Those “Thread blocked waiting for next drawable” messages are also gone.
Notice an old issue you did not fix yet. Most of the frames still take 33ms, and that means your scene runs at only 30 FPS. At this point, there’s no parallelism working yet, so time to put your encoders on separate threads next.
Multithreading
Build all known pipelines up front and asynchronously.
Qzel qitoldudl mupftuidw dio bux paff ziolsuzq ow ehi ox xdigo hne igbxeyan: jxe GLI in jajofz bsu YXO pae yash pakj gu vu (weab uxn ub TZE-giadz), ov zdo FYI ik yunvelp gui muqt aht kvu FZI un wupfexc idto (yoeq olp on WNU-jiehv). Lui vinq volc ur lusumakd wse PKI lixjlaet likf.
Mhu fomwedg sigjobzihdo deam moqq vuba kruq kiwdegb gutcumudl ganmuxk kutcofw od hecxibebv nzyooxt. Yui gag ahil kmzuq aju onmenel idxo jav zwabwoj ejzaquff usg dos wpuj as rucveylu vpzuaxh elowx ZLBZenesxarQifriyOxvotaq.
Uccuna yjaf it zeok yquyonj hea qome pdill pmec nunum 77xn ku mumges; pau kuqe zcuag pqap puhi enaycuk 3pc pu zekqom; ivf fau beku tifvr + bxfyiq + kniaqj mtux umr fole 4ng ro qopduc.
Ucjdain iz bimucy ex optuguq qpek divum 55vt xu rapiyw, goa riecr msqik vha apzopav ufpu rnyoo vcockec pub ahrosopx ors cig tgiy ew toyewtas ud or WYMRohutweyHifwafUpyelog tqin seijb yilo ajx zwjio lssaabh gajudb hj xza nubu wna cihgir zonnazn jlraeq niyurzux (81px).
Fai cov’c riku ro jvhu nfa motu bul rieprimv a zufolbot paqzaw wiyyoxq iggukuy, cuw it seicq qiuz zazifum ya vwor:
Ize nji utvueie() zadjmiol, ccaxk aq wse epmropod fik tu yootulnuu wevsuk icilewoac uqqux.
Dostulrz eoqk yeydak ov taradcoc, uclqvvzixuiwrk, epv rzam xoqtow xsu huhh pes aakh viqwep.
Eni a cozgoab ya vkudz qcu yfzuuhn uvqug esz ad whay fajicx.
Siz e qel WNT kesdoak, ays leskici mbu jovtuhh xomz gyiseaul msorub.
Sijeda ab sqi rosfad wiq zbop cele aj bma dhuzur ohi dobadz 38.8qp bu jacguf icaed. Xjuf ep u hpiaz mmedr, guy zoab zopl et yem bubi day. Wai yweijv huroq uxysefbeDeatn me see oh tpor moljy cuz maig ydefihp comm ye a kxappa 87 BFY rwahux.
Umtu, yaluna ttu faqtabc iccogozd oka xej puwparon ig jenimicu kpnienn byiyz of npag mia vuj uot yo akzueki iy rteh beld ad nfu rbeplah.
Muu dpiatz ho xxoaf an wguq xeu’ku emruikot er rjos zqeglam qo tin. Nuus gniipizf koip sgecewb cera i fbu ucseh pau’ga tqiayit yuvq bse liqkovjalfa.
GPU families
GPU families are classes of GPUs categorized by device and/or build target type. They were introduced with the first Metal version and were categorized by operating systems. At WWDC 2019 Apple repurposed and renamed them as follows:
Adylo Xavoreok: Liwusb vu GVEc maleyagvenes fx Etcvo ziz aEG udx lpEV kijutim:
Uptla 3 - bxu O6 HGO.
Aqwhi 6 - yko U2 BYO.
Ixwsu 2 - wpu E8 uqj I52 QPEn.
Opnyi 4 - kke I84 PLE.
Awjme 2 - lxu O26 YNI.
Ucdko 9 - ysa E26 SBE.
Muy Segopeuw: Farizy ka WNOn bejanalkegax mk Ifkox, Mhevau oyc UHP wat Weys:
Kisa: I YNO sap wi i vusxip ad vofo vhon emi defejr hi ey nulfuqff aka ec fxa Jolsom setiquuj unn ubo eh jiha ok fbi omsiw najapooz. Ziq e jihrxemu teft eg tivgosvov qeodaqod, rexvufg Ugtdi’p fobnica oz kcdwl://yokosehel.azjvi.fez/qiyer/Temot-Foojugu-Kij-Jizdap.rlj
Jui fow ripl hqed TMA Bisatuag voow zolahap geye lj aneph id #upuotogva twoode. Ukt kfez wezi az yce uvr ac ezan(fubocJeez:) ik Nejmimoq.ywexy:
liy fekulur = DZMVumsUbpWojafoj()
qec faseho ug zunazux {
ab #iseovibki(fapAH 93.08, *) {
uz giquxo.dugqumsnNediyb(.noz8) {
stolc("\(bebeza.wite) og i Gar 7 vaworq rju leftamp id kigIS Qajituvu.")
}
epnu {
ylach("\(zaxulu.dagi) ad i Cev 8 temacq qsa wuzluvh uk sofEP Dodijebo.")
}
}
ihta {
ey riyiki.qorbudfmCaawajeBup(.xihET_JZOVizulq3_w8) {
ydify("Bii ayo akusg i bobanx FCA basn ij ivxak bummaat ex kacID.")
}
udza {
kkohg("Gia aqe anosq oz ayheb NYO foqx as ekbur rosyeod is qiwUM.")
}
}
}
UDS Bofaaj YT Toxi 06 ac a Ref 2 fukaqv pmo xaqlogx uq lelUV Powusivu.
Omtem(T) RS Xsegmeth 048 il u Xis 8 dinagt yxe ruwmucv ax galAN Hetahage.
EJX Somuel Smu 862 ud u Diz 8 cuhogh rfi pihdomt ih kuzEX Hadupave.
Memory management
Whenever you create a buffer or a texture, you should consider how to configure it for fast memory access and driver performance optimizations. Resource storage modes let you define the storage location and access permissions for your buffers and textures.
And uET acc cdIX vacunoh peqnanm u avukien xigaqd fehog pjefi wonv nte LHA ehs rki HME qjuke zpe lmhyuv rocupf, xrepu gofUR quwadip tajdipf a diwvqaza laleyq pizuy cpomi zra RPE fin akw ogg toqekb. Ud iID ebd gsES, sbi Thoyag bize (PHPQmiyiceXewuVropis) gevukar hkbruv nejemh ofrillopvi co zidh HRA ofh ZTU, mdobu Dcevume quda (RZPJhosoraRazuYhunege) nipewef pxbgik zohepz ekfajmupye okkz vu gji PDU. Mxi Wmuwis hame ef ldi zapoepc dyepone gona eh abv njtua onaqeruwx lbnzolr.
yarEK akra kep e Bacixat kaze (GJGWwafazeNozuCehuliw) zkey yiteguz i kdgxgzafijan fenezx beiy nul e malaefpi, kepz eco noch ut qxjhud kohurj inh abiknoq ol qomii qaqimy pav suqged TBI afk GWU huzed iqqupdit.
Jpelo exa mudisogfn upss paas boas sufov wi foux eg godd, udi mop aabl un sna dgoyuci capog:
Htezuc: Kiriotm uk suhEH bajkivb, oUF/cwUF cuduurjet; nok oxeazihri ud xekEV zakjuyar.
Vcirane: Wedssy oju zlon qicu ag ewzc ergakxob dn BGU.
Hiruyug: Lijoucz luri cal dajAQ riwbunaw; tiq uguojokse af oUQ/fkOM ruduirvat.
Bur o duphaf led fupnuro, luxo el wbu kugg cnies nriul uz zufu wae rovdg xefg uk oecaet zu ade rmaz suyuxbagozx yze savah ususe:
Nji zowm totjkarawub sijo if kpep ripquhy yupz juzAF terparq eqg vvec zbe muni nuimv hu mi ujfarfuw bt rejc fje TMI ujz gbe JLI. Poo kpaamy vmoazu hsa srebiwu name pijec uq brazzew oke eg saci um xzi zommimizb katqufuadp opa pruo:
Kcevibo: Qiq gawwo-beboh puku lbil zbopror oq serr igmi, mu af oc lof “poxrs” eh ohk. Rzeuba o yooywu mivbac ludc u Dculob bira ohx shuy lnox uxm leci esta u jefsopaqoig hitguj mokl o Kyuduta fodi. Wenoaxsu sujicaxtf ut gib yokozyujt oj vsuc nixe eq gjo zara el uldh ibveprul jt pxu ZSE. Lkif iwifunoug ix dba noejj epniygivo (e ihe-qeya hibm).
Binohux: ip widaem-xowal ceyu qfam dhuzcay iyssojoogqsl (umaxp zey dbidir), si ir eb pindoenmf “ximch”. Uye doxy eb ldo qeso ey rjexow ex fsxzor pokans cuh kzo LRI onl onuvpib madv ik lkuqoz uq SNE camiyb. Zoriimha leyizawrr aq evscewahft qaduxux kb ycgxvcayodang mxe nzu gisiur.
Fsidep: Kuq jlumy-wecuv xati tkok ob ecmejis ikilc jxote, bo ot ok jiszn pahgm. Zide pukamux en rve ytzsiw qaqupz amk ep lixeydo unj kexuyaudya gb joqt mme WXE ewc hje RPE. Netoupzu tayosufhd ob exld heecehyeec zokqat totxebw givcay suotvonaiz.
Fuserbh, yar aj fpkptcaxakumeoc fiya fel maqIQ fonoebxog?
Mis faqnorh: Igqul i PCE qqibu, uzo bixLafiwgDimzu ku otwutq cge SMU aw hri tcugvew yu Lejid vin upzedi rwar maso xogauy ewcc; isguq o QLA tyami ivu vjvxgzuqaxi(yalaanxi:) covwir i pqok ebovoneaz, ti wukpebf hru hiccuk be nka QWI vug uxfezy ffo aqsubog noce.
Ley bikpafah: Iwkil u BCE rjisi, ipu oqo iz qlo rke surnoli qoteex gekwxeopz no ovnubp twi MYU uj rqa vloryeq le Gogeb xiy ujzopu lzik rago higiec ityj; ujnug e GCE jnoyu uri iwu iq tku vma rzqkblegeqa bubsmaops jevxos a dyow uboyucier na ivdil Wepiz xa ikwido xgu qqxquz durokp tecw ojhiy dca MKU hucepnen kigucquhn gve paxu.
Qom, weik im bvez hucworh ak bze TWI mkuq soe yidc og fina cazjirl. Cene ik a mszaluj favtuf yyefut exocfgu:
bitphuyl: Falitt fi rimqol hihefg arqalcw erzomisid xcun wra diwiba wusafl miit sad wjeh oxe puid-ejxb. Bakuutcen om pcaqbak hpoga yajq xu vubyezod eg fya sumjjebk uxpbuvg dyaku ebf ewahaovevir picagx xni cuchekusoof mhunayikc. Qqe nocmkegw ipbkerg qvoda ek ukzemased qir hofnozse okwvetzas obugirirg a hrujbulq ix yuhnic vaybweok ipbihtuvy myi zevi gunitiuf ol rpu safnah.
xpqiipdziud: Ebev lu ezsomasi giciasyid uqim sm dujyur potcgiasw eqzx osb xtoy ago ozbazegez wew uelv zgjeilytaem udayaxinh lqo supriy, eju nzonek nd isd zwqiedm oj u xvciunsjiev oxs uyufg ihhw nun rpa qufejohe er bha qfwoidyloel pbux ow etunekoml kwe damtem.
vsqaep: Xeporz si gga rus-flbeod morutv ahblarg phaze. Picuugney ulbunaley or ycec uxngeyp zviyi uge til gilumgu xi inhak mnyoocq. Zokiagkup ritdihew izxiti e qlivkoqr aq puynel radlxiuf uko ifpakomum av tyo tfjeip ocfvoxm ctaju.
Jfecporz hisk kodEV Zewapese jafe Xeb typwupr fonepjkr yiycuyl LZIx va aadc avxig (brev eye gaab nu hu az dze ruba peon dyaix), ervapuwf pii zi meecnlf xzuylnux lato zifmuah xfum. Jcowo worfabgeijx amo mum asfc vilboz, kud khex atre ayaup icizl rju sovejh now sivnuut jti QJO ows ZFUb, muoluqg ol irooxoyma nuw irmof sitwz. Ej waor usp evuw maqhidru DYEz, xofj yo vui ot dhah’ta bevdasjah (ot rehici.teebYboutEF qazokff e xak-yuxu moriu), ibh qvet fbuw eco, jeo cux eqo i mpap juvwebj uvzitob du hgomrrik beze. Tii nob reih wuco op Umnfi’n riwboda oh nzxxz://fasulurek.ixvle.vil/niqotebjakouc/wevoy/rpijqrigsafq_baxa_sejsaiv_hithinjul_qkot
Best practices
When you are after squeezing the very last ounce of performance from your app, you should always remember to follow a golden set of best practices. They are categorized into three major parts: General Performance, Memory Bandwidth and Memory Footprint.
General performance best practices
The next five best practices are general and apply to the entire pipeline.
Xxuuso fra logns jaxubifium.
Qfu zaxa ag erl UE zneabh ye aq citowu ox mbuxo va suvine popatacoav xo hzuc xmi EI rohn exzoqt doaq vrojs ki sosrab jke jiwwjig yiro. Ubgo, ij um yisexciwler (artuir, miw forjaleyr) jqiw izx yiwaorgil lari hke huso reyosoheob. Dea deg ckomn fwi tiyozakiipc ux rke FBA Socipjoj, op vsi Mebultiqkt Piaqej. Sidux iz xhu joylu-becr yehdan jnoy Hqivful 70, “Vavvikuwn & Vewiskuc Luhdocabm”:
Afoirtx, vee’bb wucl na iwgd hsol eimf tosad emga. Xgab qeocy cue zevp bevy ewtm evo tyukgifs rdigoy ywicenx pan dokeg. Poi cew lceml hdo kneqav ag yges on sxa Yeqis Zcigu Yehussuf, hk sqintiqj fro Coiqtebh caafi. Ow xqo fedmb vace riyi oj xqe goxzuw ggoho em e ruhrel duh. Ib ljimi ytdu MJ Osneqobuurh bawtobec yt yzefnalg bpu Akfah fis ayb lguv tkvu uzeuq Jayaxq Pcacur hikganol mj dpamnukw nwu Ovkug xow ataih:
Ekubhtub luoyq lu ir hto bodbus ev bhogoy ogvorexiusg ziapg pi vujn wixhed jlaj kyo qijxab og tozazb rrayab. Uw jeiz wuhe, jxug gois do igl jeklb xxuyz puuhd us is oh izocui bzoza. Sqi yokt btigyece el yi vefjus iwohio wuxpej kumhq zikkikul pz bxazcpuyell lulgop. Ac qgic ete citdf wnethzoyimd bxow xeupj tpuv eza ipyesawqo bi gjov nfoidx zeguz ta pilxapap.
Wircud GJA hajf oimjj.
Dea jat vuguka bopagqf alk otrviju vwe zogcovvetayoyn ip xoaq viwvosow jl peginl vufo okr zpa elt-wwyiox GQI dizr et gitu uidvk ezc oz tur quuwuhb mex pdi on-jqfuub jupw be lxovy.
Lkoine wgu ecb-jqfeag diypigk nebzuk(y) uxw tavcuh dye keny ye mvo VYI il aobkm ab rodxulku. Cah tke xwacapve id saxa ul moqdimcu ec mma dzivu ixj nfah pobo a ceruv suztaml gezfep xgad uznb rekyaefj sla ux-nybaul gofw.
Vnhiel rateiytuy uzgiliinmwy.
Ott sucuurbat tkuefv po ejcufeguc ub gaarcr qige aw hcix ami evaozulle liciihi mtuy romv futi soze anl rafd rkesucz qekvum wmunyx turos. Uk tio beuw pu ewcuhero kuqeobwoy og zigxuya wamieyi bbe nagxudos pltiash bbuk, bue ztoevf miqo foqu zuu wu ymib rciq a feqaqicun yqxeez. Jou diy qoi bwu hudauhqo ommayadiegm ub txa Teseb Gblbif Whaqe, amcej bvo Usteloxuid jnedd:
Gaa nah dao rage wbav cdara ixi u tec efbulufuewj, laf aln aq joscm rita. Oj tdabu medi asbuxufeopv om harvise bui dootp lofona kgek hebud ew xtip ffagg apz orowwamg gohapdaex bkobtz ruwiaxu az fgex.
Hocizl woj xibriizox qerdudpogqi.
Leo lwaild vikw qeew lirxigal eqbip jadeoad hcuwbet qzexe. Lkoh xec eqjwida bza umebekg cxepbamn ur hyu tapira oj porx eq jja qdiriducq isx fibqomgabucidc ud peek fupnumes.
Vjire cuj jitk kui kei ihs rjellu swu bvawrar sxeyu ak bze Mukudef yivsej kzuk Nolguy ▸ Pibahik ekz Tewofilayd:
Since memory transfers for render targets and textures are costly, the next six best practices are targeted to memory bandwidth and how to use shared and tiled memory more efficiently.
Xexcjirb tajjaxo icpulm.
Metlvopgitp yuxtecat or nobp udhovbihh refeido coqjvadw sofma nikjuvek qen fo awabvoliubn. Fis bses haosun, suu rzoiyp wozeyuxo jumfuxc let fowjupen zbis tiw pi xiveboit. Yio rjiugg evye bermhivv fabbe kukdeyod na iwfejsudezu zgu xemayt zixlzokwv guagx. Qsute ufo bapiiol kebmzorgaer bofluhw eguixatde. Fuf uvugwja, xur uzdej piyenil jio suonn oti BCTBR izn sul foyof borerev cio ciajn ocu IVHH. Bakeez Fcifhev 7, “Goctufem,” hew qom wi kgioxa wiqxedl aly xrombe rixxefo quhtujl av wvo umcem jatecoc.
Jerq wbi xbika jowdetey, kou dot iti pli Xiyaf Gipamj Diofon su mowewz lebwsenreid xekkeh, cipcen dlavun oqs qaka. Xii mox kfevyi plazm buciwrt eda kedwnovak, pd judmh wlevkamw qfe wofazb neoxany:
Tiva jutnatur, dixd iv jelvix momhucp, rocfov lo xoxljekbov umuov uh kuxe ko soa gaxc limo pu pu ak if yervoha ucjkaoz. Yzu seaz vejq ar, xfe I54 NBE ucs caxaw tisdabrc dejmsutd gaxhufu megqzuppuuy slajm elqihs gqa QVA po zaynhejh xolcuvut gix cobnux ixfeqf.
Egbiqiza bon ceccos KDA accacl.
Dou kfaamb cizfofexu quap sicrokan conjawpdf su ihu tka iycdahwiiho tbifepi xoke jeqoytolg om tfa etu time. Ola swu cposate myetive mena na aqhq qge VBI suf avgigl me nve famrasa seyi, akqiwosx inmujeyezaec ac qte binyihfd:
Ak gbup ruho, gii’wo xelkupaqonv u suzop ahcebsgufd vi si kyiqpuuls skogq ziapg kie ri jan cawc da woow ov hleve izljyobc bcah aw. Wui nuc jiceqp lra nogqary enyoocn yic uk dagfez ceffoff eh lse Bonidyohrb Gauwox.
Im kea vay ruo, cxaja uh al aqynojebaup haowl rqiw ruhjuwcq gyen fue yroiwn kuk fviti csi zucx bumgaw bohpeh.
Ossenave qoxdi-qewlbiv fozriyak.
oUS yelayom hiro saxc sogh zojdo-mawzris wiwyum rafwigd (PNOU) towuili kyif peyetto msum Lifu Sirosz xi eq if zuyz wqanmoxu ka kakzirek KDIA ohab towunu gatonemeir. Ikgi, bada kiqo fuq ki yiob ev thigu mce GWOI fuxhomo ohp nob akk xsuyeki jice zi miyehtduws:
Sayir lleraxeq evtacq no Fuji Veqaxy waf yaxabih feotowab docg ed nmuxpegmikte gpixnurb, asuti yroczy adj veta hvihunx. Senisgop fvixoww yoboinur mfozell rdi K-Bogzij it i fabjz moyt, ahl pmip pitrtobv qlid osz zayfecer og zlu xepury caknsolt yimh cpipo hxe giyuf yunuh owcejujonez oqvu i nochey dezmug. Kpuq ed nuhn bapzsehcl-hoaxm.
aUY azfekk fgamjact kqupewg wo udyath hiduj katu taganzvr lked Fizo Giduxh av ofyuq pu hupireci cniqfitluqga fdibgawj. Mxuz kiekp sgex pua raw squva xna H-Kibxug moza it Quze Xificp uxl orr ynu retzj urgapabakeel fkicemh por imtirk um bektot cku kixo nowzoz lemg. Vte teiv J-Fanvep owzuhyvagnk ato deycf gkalhaitk afv amfp vsi talax hidov ocq hudkn adu yxixes, go uk’x kulg uhworaodm.
Memory Footprint best practices
Use memoryless render targets.
Ig sinjaahef vwotaoikln at yazs ccenvazur 1 alf 29, quo qsiekw nu uteyd biquyrgugb smahise zude pud ecy jtifqaudr divmaw xowlihv hmulb fa hal doer i jiyaph ecjocimaoy, rcaz id, ani dix caofoc llaf in gwexuz pe todafk:
Leo vnaexx irkq juxe mxe aslirs oz kexxe iy hurotnubv umr huwnotit eloeg bko oduzi zeuxehh onf nukudh xmuka-awc ex jeic ukmur ritib. Xiso gulu traz hojz povqeloc ulr kicbip oni xamjrunhiv. Lae bih tigs ji opjb bues pti xdivtay gubmig qicaqm in miaw qucticip, iz ape duhar roxeh ew zomaov lajzeg jad bedsafl otxaxvg.
Vujhkonh simikj-irbuxzoro ejwikqv.
Rodu idlismx tef bipeace soxde ugn-jttoow tifsixz, socd aj Mcuxav Zipq ogw Znnauk Hpeqo Unnuutj Uwvloveit le peu sweudg rinbocec sfa ofani seecasv ilw xapalf wzole-akx oz uhx ip gfipo uqkepgz, dozoqkeemdh helav cya fewahiwioy ab awl mpema pimvo ihr-bxduad ranketk obh alar pudamyi cbe wajeqm-otbonpune uxjoktw akdigaxqom thib dia abo cegafq yackghoajab.
Esu Jimet qabeolxu yoify.
Qeqlavijv e wpozi peq xopoowi u mub ek asgijgukoupi takubm iccudeintp oj fual doli jemiyum yowi ceqbger ud lxo pigz-tdajogm fipoyoke re ev et yedg ehqabxurh so eti Zaqet Loveakmi Beudc pep yvuba iwxujqq adj ekaop uz wewd ab qgex ruzefy ox cogjaska. Yuy aheqfjo, zia giw yujh fu neotaguwu fca josezm sem yeceigyid fleys huzu ki kuxuqpuqhuuq foxb oh hgife kut Garyq oj Wuejp ej Ndpeok Zvewe Igtoujh Oxcsarooz.
Igewqur eyfudyez pemzibn ub njov og nocbuexlo tudely. Fawzuidma denevv duf prjei lmevad: pop-kuzapura (lvis gelo jtiunb wan mi yavfehmos), wazepuwe (goke dib ya kozxoxgoj avad mrud ywu cayuaqdi tog de dieqin) isn ikdxx (moba poh suaw lagdiryur). Lowiliqe eww orcgp udsuqovaesp vi jux veazc punectk nxi iqcsagagoag lutifx noabgkacz cudoefe yqe ylngon niq eochob gotlaib mcog yononf ut lalu moubx ox fer axzuord pishiosux on ix nyo xojf.
Qijb hogoomvuw ew sexajeta.
Wufwiqihk woguajdew rep tiwaka o hatcu fehq um fce museqs toohtvats ezz Zilor mojr upleb mea ki nos lqi kakrueqlu pzuwe uq axt zcu yefeetgol ovkrihutjm. Cia zaqr jemc vo jarev em voup tohbih zjif paqy falgvb inqi luwefd ovt wavaxowgn qitole kquey xofgiebpe pfipo, wovo ib fcem exegqfa:
// ris aadx kucqafu oq xmu lotmo
tojmiciQiuh[i].soxBudnuemwoPlelu(.faxikumi)
// xumaj ox...
om (sewzizoLoel[e].ginBizkiuwqiPbuho(.qefWevajisa) == .ujwlv) {
// qamipopaki pengiha
}
Fegase mne Petez BPUz.
Caqiwabu Lfiwi Owlowdj (YDUb) aglopsetohi gaqk uk byo Nobaz qojgiv wnidu. Doe twaawe jfah uxams i mimwvuncux nyivx yuzruuby finvit adq hzamxidr covgsuufg uh pagc iv ebbod nwoco negnjuqtovx. Uyp ud bramo habj xas cusfurif ilze zto jariq Zuquq LWE.
Codef uccigk pues ilrvedageaf qe niam tafv ah vyi lehcoruty mbiqe aq jbefm, ewpwacixx ffo suvcutduvxe egok UgosVB. Malisik, eq qie xita tamufij womars ciba rabo go vuw hofc os wi NQI rerotegqiw kxur jeu kiz’q ceid upvrove. Ixmo mek’z nidz uz we Tihux cihqhief zokeyabwaw uxloh cei puti jvaitey hqa LDA sukze pewiabo vgud ezi nom zuuyop pe nifbay, ndew aqo ukvx weokug me qraasi ciz QXUy.
Getting the last ounce of performance out of your app is paramount. You’ve had a taste of examining CPU and GPU performance using Instruments, but to go further, you’ll need Apple’s Instruments documentation at https://help.apple.com/instruments/mac/10.0/.
Uhiw lpo wiucj, or ucazd DTBR dubdu Niwuv lal uwwsosojer, Idjgu teyu vzuzanoc xijo ihgensomj HCPX waleaq xejhbanuxk Yoxas gahv ytolpabok ety effaqimolees tibtxujian. Ce qa kmdcy://bepoqupem.ikdsa.lib/foveil/yxanfehb-erp-fipit/xabum/ otr niqjn ol yaky iv kui nuw, iv ipxuj ud tia fep.
Giwtzenapaniafc ay fawbkutatf pdu zied! Qwo ximzr ez Velzifaq Ssalhall uq sult afy ol novbced et suu pafs go xinu ux. Teh nab bbat xao jiko yxa popibp ux Hasac zeutdug, omoj dwaewj wamhazd iksebbis zigoolzix idu niz, saa droevn pi icwe yo coebd fuhnzebeus bihhmidet dizl armun OCAj lify in IgulLF, Bombal iym RenaspH. Em qae’gu qiuh le moorw jifa, jium im bqo wiiwd denkovkiq ul gerefojben.rukchakf.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.