Files
libaaruformat/docs/html/options_8h.html

217 lines
18 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libaaruformat: include/aaruformat/structs/options.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">libaaruformat<span id="projectnumber">&#160;1.0</span>
</div>
<div id="projectbrief">Aaru Data Preservation Suite - Format Library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(function(){initNavTree('options_8h.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">options.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<p>&lt; For bool type used in <a class="el" href="structaaru__options.html" title="Parsed user-specified tunables controlling compression, deduplication, hashing and DDT geometry.">aaru_options</a>.
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;stdbool.h&gt;</code><br />
<code>#include &lt;stdint.h&gt;</code><br />
</div>
<p><a href="options_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-nested-classes" class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:aaru_5Foptions" id="r_aaru_5Foptions"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structaaru__options.html">aaru_options</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Parsed user-specified tunables controlling compression, deduplication, hashing and DDT geometry. <a href="structaaru__options.html#details">More...</a><br /></td></tr>
</table>
<a name="details" id="details"></a><h2 id="header-details" class="groupheader">Detailed Description</h2>
<div class="textblock"><p>&lt; For bool type used in <a class="el" href="structaaru__options.html" title="Parsed user-specified tunables controlling compression, deduplication, hashing and DDT geometry.">aaru_options</a>. </p>
<p>For fixed-width integer types.</p>
<p>Image creation / open tuning options structure and related semantics.</p>
<p>The library accepts a semicolon-delimited key=value options string (see <a class="el" href="internal_8h.html#aaae42bff244df727b6c029f58d4957df" title="Parses the options string for AaruFormat image creation/opening.">parse_options()</a>). Recognized keys: compress=true|false Enable/disable block compression (LZMA for data blocks, FLAC for audio tracks). deduplicate=true|false If true, identical (duplicate) sectors are stored once (DDT entries point to same physical block). If false, duplicates are still tracked in DDT but each occurrence is stored independently (no storage savings). DDT itself is always present. dictionary=&lt;bytes&gt; LZMA dictionary size in bytes (fallback default 33554432 if 0 or invalid). table_shift=&lt;n&gt; DDT v2 table shift (default 9) (items per primary entry = 2^n when multi-level). data_shift=&lt;n&gt; Global data shift (default 12). Defines per-block address granularity: the low 2^n range encodes the sector (or unit) offset within a block; higher bits combine with block_alignment to derive block file offsets. Used by DDT but not limited to it. block_alignment=&lt;n&gt; log2 alignment of underlying data blocks (default 9 =&gt; 512 bytes) (block size = 2^n). md5=true|false Generate MD5 checksum (stored in checksum block if true). sha1=true|false Generate SHA-1 checksum. sha256=true|false Generate SHA-256 checksum. blake3=true|false Generate BLAKE3 checksum (may require build-time support; ignored if unsupported). spamsum=true|false Generate SpamSum fuzzy hash.</p>
<p>Defaults (when option string NULL or key omitted): compress=true, deduplicate=true, dictionary=33554432, table_shift=9, data_shift=12, block_alignment=9, md5=false, sha1=false, sha256=false, blake3=false, spamsum=false.</p>
<p>Validation / normalization done in <a class="el" href="internal_8h.html#aaae42bff244df727b6c029f58d4957df" title="Parses the options string for AaruFormat image creation/opening.">parse_options()</a>:</p><ul>
<li>Zero / missing dictionary resets to default 33554432.</li>
<li>Zero table_shift resets to 9.</li>
<li>Zero data_shift resets to 12.</li>
<li>Zero block_alignment resets to 9.</li>
</ul>
<p>Rationale:</p><ul>
<li>table_shift, data_shift and block_alignment mirror fields stored in on-disk headers (see <a class="el" href="structAaruHeaderV2.html" title="Version 2 container header with GUID, alignment shifts, and feature negotiation bitmaps.">AaruHeaderV2</a> &amp; <a class="el" href="structDdtHeader2.html" title="Header preceding a version 2 hierarchical deduplication table.">DdtHeader2</a>); data_shift is a global per-block granularity exponent (not DDT-specific) governing how in-block offsets are encoded.</li>
<li>compress selects adaptive codec usage: LZMA applied to generic/data blocks, FLAC applied to audio track payloads.</li>
<li>deduplicate toggles storage optimization only: the DDT directory is always built for addressing; disabling simply forces each sector's content to be written even if already present (useful for forensic byte-for-byte duplication).</li>
<li>dictionary tunes compression ratio/memory use; large values increase memory footprint.</li>
<li><a class="el" href="structChecksums.html" title="Collected wholeimage checksums / hashes present in a checksum block.">Checksums</a> are optional; enabling multiple increases CPU time at write finalization.</li>
</ul>
<p>Performance / space trade-offs (deduplicate=false):</p><ul>
<li>Significantly larger image size: every repeated sector payload is written again.</li>
<li>Higher write I/O and longer creation time for highly redundant sources (e.g., zero-filled regions) compared to deduplicate=true, although CPU time spent on duplicate detection/hash lookups is reduced.</li>
<li>Potentially simpler post-process forensic validation (physical ordering preserved without logical coalescing).</li>
<li>Use when exact physical repetition is more critical than storage efficiency, or to benchmark raw device throughput.</li>
<li>For typical archival use-cases with large zero / repeated patterns, deduplicate=true markedly reduces footprint.</li>
</ul>
<p>Approximate in-RAM hash map usage for deduplication (deduplicate=true): The on-disk DDT can span many secondary tables, but only the primary table plus a currently loaded secondary (and possibly a small cache) reside in memory; their footprint is typically &lt;&lt;5% of total indexed media space and is often negligible compared to the hash map used to detect duplicate sectors. Therefore we focus here on the hash / lookup structure ("hash_map") memory, not the entire DDT on-disk size.</p>
<p>Worst-case (all sectors unique) per 1 GiB of user data: sectors_per_GiB = 2^30 / sector_size hash_bytes ≈ sectors_per_GiB * H (H ≈ 16 bytes: 8-byte fingerprint + ~8 bytes map overhead)</p>
<p>Resulting hash_map RAM per GiB (unique sectors): +-----------&mdash;+---------------&mdash;+---------------------------&mdash;+ | Sector size | Sectors / GiB | Hash map (~16 B / sector) | +-----------&mdash;+---------------&mdash;+---------------------------&mdash;+ | 512 bytes | 2,097,152 | ~33.5 MiB (≈32.036.0 MiB) | | 2048 bytes | 524,288 | ~ 8.0 MiB (≈7.58.5 MiB) | | 4096 bytes | 262,144 | ~ 4.0 MiB (≈3.84.3 MiB) | +-----------&mdash;+---------------&mdash;+---------------------------&mdash;+</p>
<p>(Range reflects allocator + load factor variation.)</p>
<p>Targeted projections (hash map only, R=1): 2048byte sectors (~8 MiB per GiB unique) Capacity | Hash map (MiB) | Hash map (GiB) ------&mdash;+------------&mdash;+-------------&mdash; 25 GiB | ~200 | 0.20 50 GiB | ~400 | 0.39</p>
<p>512byte sectors (~34 MiB per GiB unique; using 33.5 MiB for calc) Capacity | Hash map (MiB) | Hash map (GiB) ------&mdash;+------------&mdash;+-------------&mdash; 128 GiB | ~4288 | 4.19 500 GiB | ~16750 | 16.36 1 TiB* | ~34304 | 33.50 2 TiB* | ~68608 | 67.00</p>
<p>*TiB = 1024 GiB binary. For decimal TB reduce by ~7% (×0.93).</p>
<p>Duplicate ratio scaling: Effective hash RAM ≈ table_value * R, where R = unique_sectors / total_sectors. Example: 500 GiB @512 B, R=0.4 ⇒ ~16750 MiB * 0.4 ≈ 6700 MiB (~6.54 GiB).</p>
<p>Quick rule of thumb (hash only): hash_bytes_per_GiB ≈ 16 * (2^30 / sector_size) ≈ (17.1799e9 / sector_size) bytes → ≈ 33.6 MiB (512 B), 8.4 MiB (2048 B), 4.2 MiB (4096 B) per GiB unique.</p>
<p>Memory planning tip: If projected hash_map usage risks exceeding available RAM, consider:</p><ul>
<li>Increasing table_shift (reduces simultaneous secondary loads / contention)</li>
<li>Lowering data_shift (if practical) to encourage earlier big DDT adoption with fewer unique blocks</li>
<li>Segmenting the dump into phases (if workflow permits)</li>
<li>Accepting higher duplicate ratio by pre-zero detection or sparse treatment externally.</li>
<li>Resuming the dump in multiple passes: each resume rebuilds the hash_map from scratch, so peak RAM still matches a single-pass estimate, but average RAM over total wall time can drop if you unload between passes.</li>
</ul>
<p>NOTE: DDT in-RAM portion (primary + one secondary) usually adds only a few additional MiB even for very large images, hence omitted from sizing tables. Include +5% safety margin if extremely tight on memory.</p>
<p>Guidance for table_shift / data_shift selection: Let: S = total logical sectors expected in image (estimate if unknown). T = table_shift (items per primary DDT entry = 2^T when multi-level; 0 =&gt; single-level). D = data_shift (in-block sector offset span = 2^D). BA = block_alignment (bytes) = 2^block_alignment. SS = sector size (bytes).</p>
<ol type="1">
<li><p class="startli">data_shift constraints:</p><ul>
<li>For SMALL DDT entries (12 payload bits after status): D must satisfy 0 &lt; D &lt; 12 and (12 - D) &gt;= 1 so that at least one bit remains for block index. Practical range for small DDT: 6..10 (leaves 2+ bits for block index).</li>
<li>For BIG DDT entries (28 payload bits after status): D may be larger (up to 27) but values &gt;16 rarely useful.</li>
<li>Effective address granularity inside a block = min(2^D * SS, physical block span implied by BA).</li>
<li>Choosing D too large wastes bits (larger offset range than block actually contains) and reduces the number of block index bits within a small entry, potentially forcing upgrade to big DDT earlier.</li>
</ul>
<p class="startli">Recommended starting points:</p><ul>
<li>512byte sectors, 512byte block alignment: D=9 (512 offsets) or D=8 (256 offsets) keeps small DDT viable.</li>
<li>2048byte optical sectors, 2048byte alignment: D=8 (256 offsets) typically sufficient.</li>
<li>Mixed / large logical block sizes: keep D so that (2^D * SS) ≈ typical dedup block region you want addressable.</li>
</ul>
</li>
<li><p class="startli">block capacity within an entry:</p><ul>
<li>SMALL DDT: usable block index bits = 12 - D. Max representable block index (small) = 2^(12-D) - 1.</li>
<li>BIG DDT: usable block index bits = 28 - D. Max representable block index (big) = 2^(28-D) - 1.</li>
<li>If (requiredBlockIndex &gt; max) you must either reduce D or rely on big DDT.</li>
</ul>
<p class="startli">Approximate requiredBlockIndex ≈ (TotalUniqueBlocks) where TotalUniqueBlocks ≈ (S * SS) / (BA * (2^D * SS / (SS))) = S / (2^D * (BA / SS)) Simplified (assuming BA = SS): TotalUniqueBlocks ≈ S / 2^D.</p>
</li>
<li><p class="startli">table_shift considerations (multi-level DDT):</p><ul>
<li>Primary entries count ≈ ceil(S / 2^T). Choose T so this count fits memory and keeps lookup fast.</li>
<li>Larger T reduces primary table size, increasing secondary table dereferences.</li>
<li>Typical balanced values: T in [8..12] (256..4096 sectors per primary entry).</li>
<li>Set T=0 for single-level when S is small enough that all entries fit comfortably in memory.</li>
</ul>
<p class="startli">Memory rough estimate for single-level SMALL DDT: bytes ≈ S * 2 (each small entry 2 bytes). For BIG DDT: bytes ≈ S * 4. Multi-level: primary table bytes ≈ (S / 2^T) * entrySize + sum(secondary tables).</p>
</li>
<li>Example scenarios:<ul>
<li>50M sectors (≈25 GiB @512B), want small DDT: pick D=8 (256); block index bits=4 (max 16 blocks) insufficient. Need either D=6 (1024 block indices) or accept BIG DDT (28-8=20 bits =&gt; million+ blocks). So prefer BIG DDT here.</li>
<li>2M sectors, 2048B alignment, optical: D=8 gives S/2^D ≈ 7812 unique offsets; small DDT block index bits=4 (max 16) inadequate → choose D=6 (offset span 64 sectors) giving 6 block index bits (max 64) or just use big DDT.</li>
</ul>
</li>
<li>Practical recommendations:<ul>
<li>If unsure and image &gt; ~1M sectors: keep defaults (data_shift=12, table_shift=9) and allow big DDT.</li>
<li>For small archival (&lt;100k sectors): T=0 (single-level), D≈8..10 to keep small DDT feasible.</li>
<li>Benchmark before lowering D purely to stay in small DDT; increased secondary lookups or larger primary tables can offset saved space.</li>
</ul>
</li>
</ol>
<p>Recommended presets (approximate bands): +----------------------+----------------------+---------------------------+-------------------------------+ | Total logical sectors | table_shift (T) | data_shift (D) | Notes | +----------------------+----------------------+---------------------------+-------------------------------+ | &lt; 50,000 | 0 | 8 10 | Single-level small DDT likely | | 50K 1,000,000 | 8 9 | 9 10 | Still feasible small DDT | | 1M 10,000,000 | 9 10 | 10 12 | Borderline small -&gt; big DDT | | 10M 100,000,000 | 10 11 | 11 12 | Prefer big DDT; tune T for mem| | &gt; 100,000,000 | 11 12 | 12 | Big DDT; higher T saves memory| +-------------------&mdash;+-------------------&mdash;+------------------------&mdash;+----------------------------&mdash;+ Ranges show typical stable regions; pick the lower end of table_shift if memory is ample, higher if minimizing primary table size. Always validate actual unique block count vs payload bits.</p>
<p>NOTE: The library will automatically fall back to BIG DDT where needed; these settings bias structure, they do not guarantee small DDT retention.</p>
<p>Thread-safety: <a class="el" href="structaaru__options.html" title="Parsed user-specified tunables controlling compression, deduplication, hashing and DDT geometry.">aaru_options</a> is a plain POD struct; caller may copy freely. <a class="el" href="internal_8h.html#aaae42bff244df727b6c029f58d4957df" title="Parses the options string for AaruFormat image creation/opening.">parse_options()</a> returns by value.</p>
<p>Future compatibility: unknown keys are ignored by current parser; consumers should preserve original option strings if round-tripping is required. </p>
<p class="definition">Definition in file <a class="el" href="options_8h_source.html">options.h</a>.</p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a href="dir_aeff2545c9dfcfc842fe9d84b123cb31.html">aaruformat</a></li><li class="navelem"><a href="dir_6387aeb6e475a334d8dc12d69f21999e.html">structs</a></li><li class="navelem"><a href="options_8h.html">options.h</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
</ul>
</div>
</body>
</html>