How much out of order are the blocks stored in the blk*.dat files? To be more exact: Given two blocks A and B, with heights A &lt; B, but with positions in the blk file (we'll call them pA and pB) pA > pB.

What is the maximum amount of blocks that there could be stored in a blk*.dat file, between pB and pA?

For instance, let's say this is a blk*.dat file:

C D B E F G A H I

We can see here that block A is stored 3 blocks later than B, despite A having a lower height than B. Is there a maximum amount for this value (which in this case is 3)?
1024.

/** Size of the "block download window": how far ahead of our current height do we fetch?
 *  Larger windows tolerate larger download speed differences between peer, but increase the potential
 *  degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning
 *  harder). We'll probably want to make this a per-peer adaptive value at some point. */
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;


(Source.)