1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
<!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/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>WiredTiger: Performance monitoring with statistics</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>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="wiredtiger.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 style="height: 56px;">
<td id="projectlogo"><a href="http://wiredtiger.com/"><img alt="Logo" src="LogoFinal-header.png" alt="WiredTiger" /></a></td>
<td style="padding-left: 0.5em;">
<div id="projectname">
 <span id="projectnumber">Version 3.2.1</span>
</div>
<div id="projectbrief"><!-- 3.2.1 --></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="banner">
<a href="https://github.com/wiredtiger/wiredtiger">Fork me on GitHub</a>
<a class="last" href="http://groups.google.com/group/wiredtiger-users">Join my user group</a>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',false,false,'search.php','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">
$(document).ready(function(){initNavTree('tune_statistics.html','');});
</script>
<div id="doc-content">
<div class="header">
<div class="headertitle">
<div class="title">Performance monitoring with statistics </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>WiredTiger optionally maintains a variety of statistics, when the <code>statistics</code> configuration string is specified to <a class="el" href="group__wt.html#gacbe8d118f978f5bfc8ccb4c77c9e8813" title="Open a connection to a database. ">wiredtiger_open</a>; see <a class="el" href="statistics.html">Statistics</a> for general information about statistics, and <a class="el" href="data_sources.html#data_statistics">Statistics Data</a> for information about accessing the statistics.</p>
<p><b> Note that maintaining run-time statistics involves updating shared-memory data structures and may decrease application performance. </b></p>
<p>The statistics gathered by WiredTiger can be combined to derive information about the system's behavior. For example, a cursor can be opened on the statistics for a table:</p>
<div class="fragment"><div class="line"> error_check(session->open_cursor(session, <span class="stringliteral">"statistics:table:access"</span>, NULL, NULL, &cursor));</div></div><!-- fragment --><p> Then this code calculates the "fragmentation" of a table, defined here as the percentage of the table that is not part of the current checkpoint:</p>
<div class="fragment"><div class="line"> int64_t ckpt_size, file_size, percent;</div><div class="line"> get_stat(cursor, <a class="code" href="group__wt.html#ga3ba4d6c12abe10285dc3b599f082a4e4">WT_STAT_DSRC_BLOCK_CHECKPOINT_SIZE</a>, &ckpt_size);</div><div class="line"> get_stat(cursor, <a class="code" href="group__wt.html#ga2af5c768712ce6c6b840badd17dd13b9">WT_STAT_DSRC_BLOCK_SIZE</a>, &file_size);</div><div class="line"></div><div class="line"> percent = 0;</div><div class="line"> <span class="keywordflow">if</span> (file_size != 0)</div><div class="line"> percent = 100 * ((file_size - ckpt_size) / file_size);</div><div class="line"> printf(<span class="stringliteral">"Table is %"</span> PRId64 <span class="stringliteral">"%% fragmented\n"</span>, percent);</div></div><!-- fragment --><p> The following example calculates the "write amplification", defined here as the ratio of bytes written to the filesystem versus the total bytes inserted, updated and removed by the application.</p>
<div class="fragment"><div class="line"> int64_t app_insert, app_remove, app_update, fs_writes;</div><div class="line"></div><div class="line"> get_stat(cursor, <a class="code" href="group__wt.html#gaec7145b45392656825b8404ae1fb4f46">WT_STAT_DSRC_CURSOR_INSERT_BYTES</a>, &app_insert);</div><div class="line"> get_stat(cursor, <a class="code" href="group__wt.html#gaf9cc721c75f42a110e0f6af104087b4d">WT_STAT_DSRC_CURSOR_REMOVE_BYTES</a>, &app_remove);</div><div class="line"> get_stat(cursor, <a class="code" href="group__wt.html#ga21596e9d2f3d0c992bcade65b85cb5eb">WT_STAT_DSRC_CURSOR_UPDATE_BYTES</a>, &app_update);</div><div class="line"></div><div class="line"> get_stat(cursor, <a class="code" href="group__wt.html#ga212a7e9d219e279da8b10adfaaab2afc">WT_STAT_DSRC_CACHE_BYTES_WRITE</a>, &fs_writes);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (app_insert + app_remove + app_update != 0)</div><div class="line"> printf(<span class="stringliteral">"Write amplification is %.2lf\n"</span>,</div><div class="line"> (<span class="keywordtype">double</span>)fs_writes / (app_insert + app_remove + app_update));</div></div><!-- fragment --><p> Both examples use this helper function to retrieve statistics values from a cursor:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span></div><div class="line">get_stat(<a class="code" href="struct_w_t___c_u_r_s_o_r.html">WT_CURSOR</a> *cursor, <span class="keywordtype">int</span> stat_field, int64_t *valuep)</div><div class="line">{</div><div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span> *desc, *pvalue;</div><div class="line"></div><div class="line"> cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#ad1088d719df40babc1f57d086691ebdc">set_key</a>(cursor, stat_field);</div><div class="line"> error_check(cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#a7e25b2ced2cf3ec68bd5429bf921c79f">search</a>(cursor));</div><div class="line"> error_check(cursor-><a class="code" href="struct_w_t___c_u_r_s_o_r.html#af85364a5af50b95bbc46c82e72f75c01">get_value</a>(cursor, &desc, &pvalue, valuep));</div><div class="line">}</div></div><!-- fragment --></div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="index.html">Reference Guide</a></li><li class="navelem"><a class="el" href="programming_lang_java.html">Writing WiredTiger applications in Java</a></li>
<li class="footer">Copyright (c) 2008-2019 MongoDB, Inc. All rights reserved. Contact <a href="mailto:info@wiredtiger.com">info@wiredtiger.com</a> for more information.</li>
</ul>
</div>
</body>
</html>
|