mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-08 04:30:45 -08:00
264 lines
No EOL
18 KiB
HTML
264 lines
No EOL
18 KiB
HTML
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>12. MVT (Manual Variable Temporal) — Memory Pool System 1.111.0 documentation</title>
|
|
|
|
<link rel="stylesheet" href="../_static/mps.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '../',
|
|
VERSION: '1.111.0',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
<link rel="copyright" title="Copyright" href="../copyright.html" />
|
|
<link rel="top" title="Memory Pool System 1.111.0 documentation" href="../index.html" />
|
|
<link rel="up" title="Pool reference" href="index.html" />
|
|
<link rel="next" title="13. SNC (Stack No Checking)" href="snc.html" />
|
|
<link rel="prev" title="11. MVFF (Manual Variable First Fit)" href="mvff.html" />
|
|
</head>
|
|
<body>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="snc.html" title="13. SNC (Stack No Checking)"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="mvff.html" title="11. MVFF (Manual Variable First Fit)"
|
|
accesskey="P">previous</a> |</li>
|
|
<li><a href="../index.html">Memory Pool System 1.111.0 documentation</a> »</li>
|
|
<li><a href="index.html" accesskey="U">Pool reference</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body">
|
|
|
|
<div class="section" id="mvt-manual-variable-temporal">
|
|
<span id="pool-mvt"></span><span id="index-0"></span><h1>12. MVT (Manual Variable Temporal)<a class="headerlink" href="#mvt-manual-variable-temporal" title="Permalink to this headline">¶</a></h1>
|
|
<p><strong>MVT</strong> <a class="reference internal" href="../glossary/m.html#term-manual-memory-management"><em class="xref std std-term">manually manages</em></a>
|
|
variable-sized, unformatted objects. It uses the <em class="dfn">temporal fit</em>
|
|
<a class="reference internal" href="../glossary/a.html#term-allocation-policy"><em class="xref std std-term">allocation policy</em></a>.</p>
|
|
<div class="section" id="temporal-fit">
|
|
<span id="index-1"></span><h2>12.1. Temporal fit<a class="headerlink" href="#temporal-fit" title="Permalink to this headline">¶</a></h2>
|
|
<p>Temporal fit attempts to place consecutive allocations next to each
|
|
other. It relies on delaying re-use as long as possible to permit freed
|
|
blocks to <a class="reference internal" href="../glossary/c.html#term-coalesce"><em class="xref std std-term">coalesce</em></a>, thus maximizing the number of consecutive
|
|
allocations that can be co-located. Temporal fit permits a very fast
|
|
allocator and a deallocator competitive in speed with all other known
|
|
policies.</p>
|
|
<p>Temporal fit is intended to take advantage of knowledge of object
|
|
<a class="reference internal" href="../glossary/l.html#term-lifetime"><em class="xref std std-term">lifetimes</em></a>: either <em>a priori</em> knowledge, or knowledge acquired
|
|
by profiling. The best performance will be achieved by allocating
|
|
objects with similar expected death times together.</p>
|
|
<p>A simple policy can be implemented to take advantage of MVT. Object
|
|
size is typically well-correlated with object life-expectancy, and
|
|
birth time plus lifetime gives death time, so allocating objects of
|
|
similar size sequentially from the same pool instance should result in
|
|
objects allocated close to each other dying at about the same time.</p>
|
|
<p>An application that has several classes of objects of widely differing
|
|
life expectancy will best be served by creating a different MVT pool
|
|
instance for each life-expectancy class. A more sophisticated policy
|
|
can use either the programmer’s knowledge of the expected lifetime of
|
|
an object, or any characteristic of objects that correlates with
|
|
lifetime, to choose an appropriate pool to allocate in.</p>
|
|
<p>Allocating objects with unknown or very different death times together
|
|
will pessimize the space performance of MVT.</p>
|
|
</div>
|
|
<div class="section" id="mvt-properties">
|
|
<span id="index-2"></span><h2>12.2. MVT properties<a class="headerlink" href="#mvt-properties" title="Permalink to this headline">¶</a></h2>
|
|
<ul class="simple">
|
|
<li>Does not support allocation via <a class="reference internal" href="../topic/allocation.html#mps_alloc" title="mps_alloc"><tt class="xref c c-func docutils literal"><span class="pre">mps_alloc()</span></tt></a>.</li>
|
|
<li>Supports allocation via <a class="reference internal" href="../glossary/a.html#term-allocation-point"><em class="xref std std-term">allocation points</em></a> only. If an
|
|
allocation point is created in an MVT pool, the call to
|
|
<a class="reference internal" href="../topic/allocation.html#mps_ap_create" title="mps_ap_create"><tt class="xref c c-func docutils literal"><span class="pre">mps_ap_create()</span></tt></a> takes no additional parameters.</li>
|
|
<li>Supports deallocation via <a class="reference internal" href="../topic/allocation.html#mps_free" title="mps_free"><tt class="xref c c-func docutils literal"><span class="pre">mps_free()</span></tt></a>.</li>
|
|
<li>Supports <a class="reference internal" href="../glossary/a.html#term-allocation-frame"><em class="xref std std-term">allocation frames</em></a> but does not use them to improve
|
|
the efficiency of stack-like allocation.</li>
|
|
<li>Does not support <a class="reference internal" href="../glossary/s.html#term-segregated-allocation-cache"><em class="xref std std-term">segregated allocation caches</em></a>.</li>
|
|
<li>There are no garbage collections in this pool.</li>
|
|
<li>Blocks may not contain <a class="reference internal" href="../glossary/r.html#term-reference"><em class="xref std std-term">references</em></a> to blocks in automatically
|
|
managed pools (unless these are registered as <a class="reference internal" href="../glossary/r.html#term-root"><em class="xref std std-term">roots</em></a>).</li>
|
|
<li>Allocations may be variable in size.</li>
|
|
<li>The <a class="reference internal" href="../glossary/a.html#term-alignment"><em class="xref std std-term">alignment</em></a> of blocks is not configurable: it is the
|
|
<a class="reference internal" href="../glossary/n.html#term-natural-alignment"><em class="xref std std-term">natural alignment</em></a> of the platform (see
|
|
<a class="reference internal" href="../topic/platform.html#MPS_PF_ALIGN" title="MPS_PF_ALIGN"><tt class="xref c c-macro docutils literal"><span class="pre">MPS_PF_ALIGN</span></tt></a>).</li>
|
|
<li>Blocks do not have <a class="reference internal" href="../glossary/d.html#term-dependent-object"><em class="xref std std-term">dependent objects</em></a>.</li>
|
|
<li>Blocks are not automatically <a class="reference internal" href="../glossary/r.html#term-reclaim"><em class="xref std std-term">reclaimed</em></a>.</li>
|
|
<li>Blocks are not <a class="reference internal" href="../glossary/s.html#term-scan"><em class="xref std std-term">scanned</em></a>.</li>
|
|
<li>Blocks are not protected by <a class="reference internal" href="../glossary/b.html#term-barrier-1"><em class="xref std std-term">barriers<sup>(1)</sup></em></a>.</li>
|
|
<li>Blocks do not <a class="reference internal" href="../glossary/m.html#term-moving-garbage-collector"><em class="xref std std-term">move</em></a>.</li>
|
|
<li>Blocks may not be registered for <a class="reference internal" href="../glossary/f.html#term-finalization"><em class="xref std std-term">finalization</em></a>.</li>
|
|
<li>Blocks must not belong to an <a class="reference internal" href="../glossary/o.html#term-object-format"><em class="xref std std-term">object format</em></a>.</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="mvt-interface">
|
|
<span id="index-3"></span><h2>12.3. MVT interface<a class="headerlink" href="#mvt-interface" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include "mpscmv2.h"</span>
|
|
</pre></div>
|
|
</div>
|
|
<dl class="function">
|
|
<dt id="mps_class_mvt">
|
|
<a class="reference internal" href="../topic/pool.html#mps_class_t" title="mps_class_t">mps_class_t</a> <tt class="descname">mps_class_mvt</tt><big>(</big>void<big>)</big><a class="headerlink" href="#mps_class_mvt" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Return the <a class="reference internal" href="../glossary/p.html#term-pool-class"><em class="xref std std-term">pool class</em></a> for an MVT (Manual Variable
|
|
Temporal) <a class="reference internal" href="../glossary/p.html#term-pool"><em class="xref std std-term">pool</em></a>.</p>
|
|
<p>When creating an MVT pool, <a class="reference internal" href="../topic/pool.html#mps_pool_create" title="mps_pool_create"><tt class="xref c c-func docutils literal"><span class="pre">mps_pool_create()</span></tt></a> takes five
|
|
extra arguments:</p>
|
|
<div class="highlight-c"><div class="highlight"><pre><span class="n">mps_res_t</span> <span class="n">mps_pool_create</span><span class="p">(</span><span class="n">mps_pool_t</span> <span class="o">*</span><span class="n">pool_o</span><span class="p">,</span> <span class="n">mps_arena_t</span> <span class="n">arena</span><span class="p">,</span>
|
|
<span class="n">mps_class_t</span> <span class="n">mps_class_mvt</span><span class="p">(),</span>
|
|
<span class="kt">size_t</span> <span class="n">minimum_size</span><span class="p">,</span>
|
|
<span class="kt">size_t</span> <span class="n">mean_size</span><span class="p">,</span>
|
|
<span class="kt">size_t</span> <span class="n">maximum_size</span><span class="p">,</span>
|
|
<span class="n">mps_count_t</span> <span class="n">reserve_depth</span><span class="p">,</span>
|
|
<span class="n">mps_count_t</span> <span class="n">fragmentation_limit</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><tt class="docutils literal"><span class="pre">minimum_size</span></tt>, <tt class="docutils literal"><span class="pre">mean_size</span></tt>, and <tt class="docutils literal"><span class="pre">maximum_size</span></tt> are the
|
|
predicted minimum, mean, and maximum <a class="reference internal" href="../glossary/s.html#term-size"><em class="xref std std-term">size</em></a> of
|
|
<a class="reference internal" href="../glossary/b.html#term-block"><em class="xref std std-term">blocks</em></a> expected to be allocated in the pool. Blocks
|
|
smaller than <tt class="docutils literal"><span class="pre">minimum_size</span></tt> and larger than <tt class="docutils literal"><span class="pre">maximum_size</span></tt> may
|
|
be allocated, but the pool is not guaranteed to manage them
|
|
space-efficiently. Furthermore, partial freeing is not supported
|
|
for blocks larger than <tt class="docutils literal"><span class="pre">maximum_size</span></tt>; doing so will result in
|
|
the storage of the block never being reused. <tt class="docutils literal"><span class="pre">mean_size</span></tt> need
|
|
not be an accurate mean, although the pool will manage
|
|
<tt class="docutils literal"><span class="pre">mean_size</span></tt> blocks more efficiently if it is.</p>
|
|
<p><tt class="docutils literal"><span class="pre">reserve_depth</span></tt> is the expected hysteresis of the population of
|
|
the pool. When blocks are freed, the pool will retain sufficient
|
|
storage to allocate <tt class="docutils literal"><span class="pre">reserve_depth</span></tt> blocks of <tt class="docutils literal"><span class="pre">mean_size</span></tt> for
|
|
near term allocations (rather than immediately making that storage
|
|
available to other pools).</p>
|
|
<p>If a pool has a stable population, or one which only grows over
|
|
the lifetime of the pool, or one which grows steadily and then
|
|
shrinks steadily, use a reserve depth of 0.</p>
|
|
<p>It is always safe to use a reserve depth of 0, but if the
|
|
population typically fluctuates in a range (for example, the
|
|
client program repeatedly creates and destroys a subset of blocks
|
|
in a loop), it is more efficient for the pool to retain enough
|
|
storage to satisfy that fluctuation. For example, if a pool has an
|
|
object population that typically fluctuates between 8,000 and
|
|
10,000, use a reserve depth of 2,000.</p>
|
|
<p>The reserve will not normally be available to other pools for
|
|
allocation, even when it is not used by the pool. If this is
|
|
undesirable, a reserve depth of 0 may be used for a pool whose
|
|
object population does vary, at a slight cost in efficiency. The
|
|
reserve does not guarantee any particular amount of allocation.</p>
|
|
<p><tt class="docutils literal"><span class="pre">fragmentation_limit</span></tt> is a percentage from 1 to 100 (inclusive).
|
|
It sets an upper limit on the space overhead of MVT, in case block
|
|
death times and allocations do not correlate well. If the free
|
|
space managed by the pool as a ratio of all the space managed by
|
|
the pool exceeds <tt class="docutils literal"><span class="pre">fragmentation_limit</span></tt>, the pool falls back to a
|
|
first fit allocation policy, exploiting space more efficiently at
|
|
a cost in time efficiency. A fragmentation limit of 0 would cause
|
|
the pool to operate as a first-fit pool, at a significant cost in
|
|
time efficiency: therefore this is not permitted.</p>
|
|
<p>A fragmentation limit of 100 causes the pool to always use
|
|
temporal fit (unless resources are exhausted). If the objects
|
|
allocated in the pool have similar lifetime expectancies, this
|
|
mode will have the best time- and space-efficiency. If the objects
|
|
have widely varying lifetime expectancies, this mode will be
|
|
time-efficient, but may be space-inefficient. An intermediate
|
|
setting can be used to limit the space-inefficiency of temporal
|
|
fit due to varying object life expectancies.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="mvt-introspection">
|
|
<span id="index-4"></span><h2>12.4. MVT introspection<a class="headerlink" href="#mvt-introspection" title="Permalink to this headline">¶</a></h2>
|
|
<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include "mpscmv2.h"</span>
|
|
</pre></div>
|
|
</div>
|
|
<dl class="function">
|
|
<dt id="mps_mvt_free_size">
|
|
size_t <tt class="descname">mps_mvt_free_size</tt><big>(</big><a class="reference internal" href="../topic/pool.html#mps_pool_t" title="mps_pool_t">mps_pool_t</a><em> pool</em><big>)</big><a class="headerlink" href="#mps_mvt_free_size" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Return the total amount of free space in an MVT pool.</p>
|
|
<p><tt class="docutils literal"><span class="pre">pool</span></tt> is the MVT pool.</p>
|
|
<p>Returns the total free space in the pool, in <a class="reference internal" href="../glossary/b.html#term-byte-1"><em class="xref std std-term">bytes<sup>(1)</sup></em></a>.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="mps_mvt_size">
|
|
size_t <tt class="descname">mps_mvt_size</tt><big>(</big><a class="reference internal" href="../topic/pool.html#mps_pool_t" title="mps_pool_t">mps_pool_t</a><em> pool</em><big>)</big><a class="headerlink" href="#mps_mvt_size" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Return the total size of an MVT pool.</p>
|
|
<p><tt class="docutils literal"><span class="pre">pool</span></tt> is the MVT pool.</p>
|
|
<p>Returns the total size of the pool, in <a class="reference internal" href="../glossary/b.html#term-byte-1"><em class="xref std std-term">bytes<sup>(1)</sup></em></a>. This
|
|
is the sum of allocated space and free space.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar">
|
|
<div class="sphinxsidebarwrapper">
|
|
<p class="logo"><a href="../index.html">
|
|
<img class="logo" src="../_static/logo.png" alt="Logo"/>
|
|
</a></p>
|
|
<h3><a href="../index.html">Table Of Contents</a></h3>
|
|
<ul>
|
|
<li><a class="reference internal" href="#">12. MVT (Manual Variable Temporal)</a><ul>
|
|
<li><a class="reference internal" href="#temporal-fit">12.1. Temporal fit</a></li>
|
|
<li><a class="reference internal" href="#mvt-properties">12.2. MVT properties</a></li>
|
|
<li><a class="reference internal" href="#mvt-interface">12.3. MVT interface</a></li>
|
|
<li><a class="reference internal" href="#mvt-introspection">12.4. MVT introspection</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="mvff.html"
|
|
title="previous chapter">11. MVFF (Manual Variable First Fit)</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="snc.html"
|
|
title="next chapter">13. SNC (Stack No Checking)</a></p><h4>Contact us</h4>
|
|
|
|
<p class="topless"><a href="mailto:mps-questions@ravenbrook.com">mps-questions@ravenbrook.com</a></p>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="snc.html" title="13. SNC (Stack No Checking)"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="mvff.html" title="11. MVFF (Manual Variable First Fit)"
|
|
>previous</a> |</li>
|
|
<li><a href="../index.html">Memory Pool System 1.111.0 documentation</a> »</li>
|
|
<li><a href="index.html" >Pool reference</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer">
|
|
© <a href="../copyright.html">Copyright</a> 2012, Ravenbrook Limited.
|
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
|
|
</div>
|
|
</body>
|
|
</html> |