DESIGN OF THE MANUALLY-MANAGED VARIABLE-SIZE FIRST-FIT POOL design.mps.poolmvff incomplete doc gavinm 1998-09-09 INTRODUCTION .intro: The pool was created in a response to a belief that EPDL/EPDR's first fit policy is beneficial for some classes of client behaviour, but the performance of a linear free list was unacceptable. This pool implements a first (or last) fit policy for variable-sized manually-managed objects, with control over first/last, segment preference high/low, and slot fit low/high. Document History .hist.0: GavinM wrote a list of methods and function plus some notes 1998-09-09. .hist.1: Added overview, removed bogus ArenaEnter design, and described buffered allocation. pekka 1999-01-06 .hist.2: Modified for the "Sunset On Segments" redesign of segments. Buffered allocation is no longer limited to segment boundaries. OVERVIEW .over: This pool implements certain variants of the address-ordered first-fit policy. The implementation allows allocation across segment boundaries. .over.buffer: Buffered allocation is also supported, but in that case, the buffer-filling policy is worst-fit. Buffered and unbuffered allocation can be used at the same time, but in that case, the first ap must be created before any allocations. .over.buffer.class: The pool uses the simplest buffer class, BufferClass. This is appropriate since these buffers don't attach to segments, and hence don't constrain buffered regions to lie within segment boundaries. .over.segments: The pool uses the simplest segment class (SegClass). There's no need for anything more complex. METHODS .method: The MVFF pool supports the following methods: .method.init: Res MVFFInit(Pool pool, va_list arg) This takes six vararg parameters: - extendBy -- the segment size; - avgSize -- the average object size; - alignment -- the alignment of allocations and frees (must be at least sizeof(void*)); - slotHigh -- whether to allocate objects at the end of free blocks found, as opposed to at the start (for unbuffered allocation); - arenaHigh -- whether to express SegPrefHIGH to the arena, as opposed to SegPrefLOW; - firstFit -- whether to use the suitable block of lowest address, as opposed to the highest (for unbuffered allocation). .method.init.epdl: To simulate the EPDL pool, specify extendBy, avgSize, and maxSize as normal, and use slotHigh=FALSE, arenaHigh=FALSE, firstFit=TRUE. .method.init.epdr: To simulate the EPDL pool, specify extendBy, avgSize, and maxSize as normal, and use slotHigh=TRUE, arenaHigh=TRUE, firstFit=TRUE. .method.init.other: The performance characteristics of other combinations are unknown. .method.finish: The PoolFinish method, .method.alloc: Alloc and Free methods are supported, implementing the policy set by the pool params (see .method.init). .method.describe: The usual describe method. .method.buffer: The buffer methods implement a worst-fit fill strategy. EXTERNAL FUNCTIONS .function: MVFF supports the following external functions: .function.free-size: size_t mps_mvff_free_size(mps_pool_t pool) This function returns the total size of free space in segments allocated to the MVFF pool instance. .function.size: size_t mps_mvff_size(mps_pool_t pool) This function returns the total memory used by pool segments, whether free or allocated. .function.class: mps_class_t mps_class_mvff(void) This function returns the class object for the pool class, to be used in pool creation. IMPLEMENTATION .impl.free-list: The pool stores its free list in a CBS (see design.mps.cbs). It uses the CBS's mayUseInline facility to avoid running out of memory to store the free this. This is the reason for the alignment restriction above. DETAILS .design.seg-size: When adding a segment, we use extendBy as the segment size unless the object won't fit, in which case we use the object size (in both cases we align up). .design.seg-fail: If allocating a segment fails, we try again with a segment size just large enough for the object we're allocating. This is in response to request.mps.170186.
2002-06-07 | RB | Converted from MMInfo database design document. |
This document is copyright © 1995-2002 Ravenbrook Limited. All rights reserved. This is an open source license. Contact Ravenbrook for commercial licensing options.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement, are disclaimed. In no event shall the copyright holders and contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
$Id: //info.ravenbrook.com/project/mps/version/1.102/design/poolmvff/index.html#1 $
Ravenbrook / Projects / Memory Pool System / Master Product Sources / Design Documents