@Override
  public LogChunk append(int chunkPayloadCapacity,
                         boolean reserveNextChunkIdField) throws IOException {
    checkPayloadCapacity(chunkPayloadCapacity, reserveNextChunkIdField);

    int pageSize = storage.pageSize();

    int totalChunkLength = LogChunkImpl.chunkLengthForPayload(chunkPayloadCapacity, reserveNextChunkIdField);
    if (totalChunkLength > pageSize) {
      throw new IllegalArgumentException("Requested chunkPayloadCapacity(=" + chunkPayloadCapacity + ") is too big: " +
                                         "chunk with header (=" + totalChunkLength + ") must fit pageSize(=" + pageSize + ")");
    }

    //RC: It is teasing to 'pre-touch' the mmapped buffer before acquiring the lock to trigger page-fault (if any) outside
    //    the lock, thus reducing the chance of getting stuck on page-fault while keeping the lock.
    //    But it seems to me, it provides no additional parallelism, since even with page-fault moved out of lock -- any
    //    other thread that comes here needs to access the same pages (header + current data page) => will get stuck on
    //    exactly the same page-fault interrupt anyway. 'Pre-touching' provides no additional parallelism, it only changes
    //    _how_ the threads will wait: without pre-touch one thread waits on the page-fault, and others waiting on lock,
    //    with pre-touch -- all the threads will wait on page-fault interrupt before lock.

    synchronized (allocationLock) {
      long chunkOffsetInFile = allocateSpaceForChunk(totalChunkLength);
      AlignmentUtils.assert64bAligned(chunkOffsetInFile, "chunkOffsetInFile");

      MMappedFileStorage.Page page = storage.pageByOffset(chunkOffsetInFile);
      int offsetInPage = storage.toOffsetInPage(chunkOffsetInFile);


      LogChunkImpl chunk = LogChunkImpl.putRegularChunk(
        page.rawPageBuffer(),
        totalChunkLength, offsetInPage, chunkOffsetInFile,
        reserveNextChunkIdField
      );

      header.addToDataRecordsCount(1);
      header.updateFirstUnCommittedOffset(chunkOffsetInFile + totalChunkLength);

      return chunk;
    }
  }
@Override
  public LogChunk append(int chunkPayloadCapacity,
                         boolean reserveNextChunkIdField)