<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/10309">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">astobj2: Reduce memory overhead.<br><br>Reduce options to 2-bit field, magic to 30 bit field. Move ref_counter<br>next to options the fields will pack.<br><br>This reduces memory overhead for every ao2 object by 8 bytes on x86_64.<br><br>Change-Id: Idc1baabb35ec3b3d8de463c4fa3011eaf7fcafb5<br>---<br>M main/astobj2.c<br>1 file changed, 7 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/09/10309/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/astobj2.c b/main/astobj2.c</span><br><span>index 63058e1..46afa49 100644</span><br><span>--- a/main/astobj2.c</span><br><span>+++ b/main/astobj2.c</span><br><span>@@ -48,7 +48,6 @@</span><br><span> * The magic number is used for consistency check.</span><br><span> */</span><br><span> struct __priv_data {</span><br><span style="color: hsl(0, 100%, 40%);">- int ref_counter;</span><br><span> ao2_destructor_fn destructor_fn;</span><br><span> /*! This field is used for astobj2 and ao2_weakproxy objects to reference each other */</span><br><span> void *weakptr;</span><br><span>@@ -56,15 +55,17 @@</span><br><span> /*! User data size for stats */</span><br><span> size_t data_size;</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+ /*! Number of references held for this object */</span><br><span style="color: hsl(120, 100%, 40%);">+ int ref_counter;</span><br><span> /*! The ao2 object option flags */</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t options;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t options:2;</span><br><span> /*! magic number. This is used to verify that a pointer passed in is a</span><br><span> * valid astobj2 or ao2_weak reference */</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t magic;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint32_t magic:30;</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#define AO2_MAGIC 0xa570b123</span><br><span style="color: hsl(0, 100%, 40%);">-#define AO2_WEAK 0xa570b122</span><br><span style="color: hsl(120, 100%, 40%);">+#define AO2_MAGIC 0x3a70b123</span><br><span style="color: hsl(120, 100%, 40%);">+#define AO2_WEAK 0x3a70b122</span><br><span> #define IS_AO2_MAGIC_BAD(p) (AO2_MAGIC != (p->priv_data.magic | 1))</span><br><span> </span><br><span> /*!</span><br><span>@@ -692,8 +693,8 @@</span><br><span> }</span><br><span> </span><br><span> /* Initialize common ao2 values. */</span><br><span style="color: hsl(0, 100%, 40%);">- obj->priv_data.ref_counter = 1;</span><br><span> obj->priv_data.destructor_fn = destructor_fn; /* can be NULL */</span><br><span style="color: hsl(120, 100%, 40%);">+ obj->priv_data.ref_counter = 1;</span><br><span> obj->priv_data.options = options;</span><br><span> obj->priv_data.magic = AO2_MAGIC;</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10309">change 10309</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10309"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Idc1baabb35ec3b3d8de463c4fa3011eaf7fcafb5 </div>
<div style="display:none"> Gerrit-Change-Number: 10309 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>