Welcome, Guest. Please login or register.

Author Topic: The New MorphOS Memory System  (Read 3259 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline PiruTopic starter

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
The New MorphOS Memory System
« on: February 10, 2009, 07:30:12 PM »
I wrote a small article about the new memory system in MorphOS 2.0 and beyond. It describes the background, design goals, some of the challenges met and the actual technical implementation.

The Article
 

Offline PiruTopic starter

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: The New MorphOS Memory System
« Reply #1 on: February 11, 2009, 06:09:11 AM »
@Trev
Quote
Re: legacy MEMF_REVERSE usage, if you observed that your allocations were in the upper half of memory (either physically or with respect to memory lists), wouldn't using MEMF_REVERSE have decreased allocation time by at least a factor of two, barring fragmentation?

The way MEMF_REVERSE flag is implemented in the First Fit algo is actually even slower than normal allocations. It always must scan all free memory blocks to find the last matching one (since they're sorted by address). Also, with TLSF the MEMF_REVERSE flag only adds complexity to the routine without adding any performance, or reducing the fragmentation.
Quote
It also seems to me that using an allocaligned-like function would have increased fragmentation with very little benefit, particularly for alignments <= 16, by unnecessarily increasng the size of the system memory lists.

Allocaligned kind of functions are only used to get memory aligned to specific granularily. Often it's needed for DMA operations, getting memory aligned to PPC code/stack alignment requirements or MMU page size aligned memory areas. You indeed should not use them lightly as they increase fragmentation quite dramatically. Luckily with TLSF the fragmentation no longer is an issue.
 

Offline PiruTopic starter

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: The New MorphOS Memory System
« Reply #2 on: February 11, 2009, 08:02:52 AM »
@Trev
Quote
Which is why I've been allocating size+align-1, keeping track of the original pointer, and just passing around pointer&~align without reallocating....

That's a good strategy, indeed. This way it won't break with allocation systems that don't implement AllocAbs() properly. It also is faster than AllocMem+FreeMem+AllocAbs sequence, and indeed does not add additional fragmentation. The obvious downside is holding extra "align" bytes of memory (shouldn't be a problem these days).