On second thought i think i can actually make that work.  I was thinking you'd want a full blown interval tree, but it could be done using the same walk I'm doing for writing.  Since this is still a rare case, I'm fine adding this, or not adding it, depending on what people prefer<br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 9, 2016 at 10:26 AM Zachary Turner <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ob, one more thing.  Larger queries will still be reused IF offset of the previous request is the same as offset of the current request.<br><br>What doesn't work is if they overlap but start at different locations.  Eg<br><br>Read 1: offset 0, length 1024<br>Read 2: offset 512, length 256<br><br>Even in that case though, if the 256 byte read didn't cross the discontinuity, it would be satisfied without the cache.  So probability is very low of running into this<br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 9, 2016 at 10:22 AM Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">zturner added inline comments.<br>
<br>
================<br>
Comment at: lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp:47-48<br>
@@ -46,3 +46,4 @@<br>
<br>
   auto CacheIter = CacheMap.find(Offset);<br>
   if (CacheIter != CacheMap.end()) {<br>
+    // Try to find an alloc that was large enough for this request.<br>
----------------<br>
majnemer wrote:<br>
> Doesn't this mean that larger queries that happened earlier are not reused?<br>
><br>
> Let's say we start with an empty cache.<br>
> Then a read request for 4096 bytes from offset 0 happens.<br>
> Then a read request for 1024 bytes at offset 1024 happens.<br>
> Won't the second request not share with the first?<br>
You are correct.  And I thought of that, but it makes the data structure more complicated, and I didn't think it was worth it for a code path that would almost never get exercised anyway.  This is mostly here so you don't shoot yourself in the foot, but as Rui mentioned earlier, read/write on the same pdb is not going to be a common thing at all, so I made it just smart enough that if you use it your program will still work, but still stupid enough that I didn't have to devise a new complicated data structure.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D21157" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21157</a><br>
<br>
<br>
<br>
</blockquote></div></blockquote></div>