title: When does a Vec reallocate if no default size is provided?
body: <p>I'm currently learning Rust, and there are some aspects I would like to understand in order to be able to create more efficient code, so the question is, whats the default size of a <code>Vec::new()</code> and when does it reallocate if it exceeds the default size? I'm seeing some performance issues when working with vectors (I think this is the main reason) once they grow enough. The vector has <code>Vec&lt;u8&gt;</code> values, so, the resultant vector is like the following</p>
  <pre class="lang-rs prettyprint-override"><code>let items: Vec&lt;Vec&lt;u8&gt;&gt; = Vec::new();
  </code></pre>
  <p>I'm doing massive insertions just to see if it's capable of handling millions of values, but as soon as it gets to ~30k values, the insertion process tends to double the time, and as time goes by, it will double again.</p>
  <p>I want to store some identifiers within the vector in order to later on implement some pagination on the vector for an API, but I think using unbounded vectors is causing this issue, I'm not sure.</p>
  <p>Besides the usage of vectors, I'm also using a Hashmap at the same time to insert the <code>Vec&lt;u8&gt;</code> key and some object as value, so Hashmap can also be the issue.</p>