1 research outputs found

    Embedded dynamic memory allocator optimisation

    Get PDF
    The objective of this thesis was to improve upon the dynamic memory allocator used in U-Blox GNSS receivers. After initial analysis, the main weakness of the currently used Buddy allocator was determined to be high fragmentation, so lowering this was the focus. To understand the problem better and find possible alternatives to Buddy, a literature survey was conducted. The survey examined the fundamental building blocks of dynamic memory allocation and how they could be combined for desired results. Using knowledge gained from the survey, a number of allocators were chosen for further examination. Among them, the most promising were two real-time allocators TLSF and a Half Fit variant called O1Heap due to their focus on integrity and more constrained heaps. After preliminary testing, two more allocators were considered as a response to the observed shortcomings of previously mentioned allocators. First was Half Fit CSTM, which makes slight modifications to the Half Fit algorithm trading constant execution time for lower fragmentation. The second allocator is Half Tree, which is a new allocator created in the scope of this research. It aims to address the weaknesses of the other considered allocators and achieve good results in all required aspects. A testing framework was designed and implemented to assist in evaluating each allocator’s suitability as an alternative for the Buddy allocator. Performance tests measured each allocator’s average and worst execution times while fragmentation tests measured the required heap size and other metrics for fragmentation. The tests were run on a real device to provide more accurate results. Testing focused on real allocation sequences (memory traces) gathered from a production device, but synthetic traces were also included. All allocators went through the same tests, and their results were compared to those of the Buddy allocator. Out of the 4 allocators considered, TLSF and Half Tree were determined to be the most suitable. Half Tree was deemed superior to TLSF because of much better performance while still having low fragmentation. Finally, Half Tree reduces fragmentation to approximately 15% to that of Buddy while only being 0–15% slower in real trace test scenarios. It requires 25% less heap for the same memory traces. Overall, the thesis objectives have been met. Half Tree allocator provides a significant improvement in memory efficiency over Buddy while maintaining comparable performance.Työn tavoitteena oli parantaa U-Bloxin GNSS laitteissa käytettyä muistiallokaattoria. Alustavan analyysin perusteella, nykyisen Buddy-allokaattorin heikkoutena oli korkea fragmentaatio, joten tutkimuksen pääpainona oli tämän alentaminen. Ongelman ja sen taustojen ymmärtämiseksi, sekä parempien allokaattorien löytämiseksi, tehtiin työn alussa kirjallisuusselvitys. Selvityksen avulla määriteltiin dynaamisen muistinhallinan perusteet ja kuinka niiden avulla voidaan rakentaa halutunlaisia allokaattoreita. Selvityksen osana tarkasteltiin useita erilaisia allokaattoreita ja päädyttiin lopulta valitsemaan 2 allokaattoria tarkempaa tutkimusta varten. Nämä olivat reaaliaika käyttöön suunnitellut ja laajalti tunnetut TLSF ja Half Fit variantti O1Heap. Alustavien kokeiden perusteella, toteutettiin kaksi uutta allokaattoria vastaamaan kokeissa havaittuihin TLSF:n ja O1Heapin heikkouksiin. Ensimmäisenä Half Fit CSTM, joka tekee pieniä muutoksia Half Fittiin vaihtaen vakioaikaisen suorituksen matalampaan fragmentaatioon. Half Tree puolestaan on uusi allokaattori suunniteltu tätä tutkimusta varten. Sen tavoitteena oli vastata muiden allokaattereiden heikkouksiin ja suoriutua hyvin kaikilla osa-alueilla. Allokaattoreiden soveltuvuutta Buddyn korvaajaksi arvioitiin kokeellisesti. Kokeiden avulla mitattiin allokaatoreidenn keskimääräistä suorituaikaa, huonointa suoritusaikaa sekä fragmentaatiota ja muistintarvetta. Koejärjestelyt suunniteltiin ja toteutettiin kohdelaitteella tulosten todenmukaisuutta ajatellen. Kokeet keskittyivät laitteelta kerättyihin oikeisiin muistijälkiin, mutta myös synteettisiä muistijälkiä hyödynnettiin. Kaikille 4 allokaattorille suoritettiin samat kokeet ja niiden tuloksia verratiin Buddy -allokaattoriin ja toisiinsa. Valituista allokaattoreista TLSF ja Half Tree osoittautuivat parhaiten soveltuviksi. TLSF on kuitenkin erittäin hidas verrattuna Buddy -allokaattoriin. Half Tree puolestaan on selvästi parempi, tarjoten edelleen matalan fragmentation, mutta ilman merkittävää kompromissia suorituskyvyssä. Half Treen fragmentaatio on noin 15% Buddy-allokaattorin fragmentaatiosta ja suorituskyky heikkenee vain 0–15% muistijäljestä riippuen. Vaaditun muistin määrässä alempi fragmentaatio tarkoittaa noin 25% parannusta. Työ täytti sille asetetut tavoitteet. Half Tree allokaattori tarjoaa merkittävän parannuksen muistitehokkuudessa Buddy-allokaattoriin verrattuna, tekemättä suuria uhrauksia suorituskyvyssä
    corecore