I created a branch for this
https://tools.assembla.com/svn/chdk/branches/dng-async-writeNew version checked in
- Writes header in dng_write task, per philmoz suggestion
- For cameras with multiple raw buffers, writes as much data as is ready
- For cameras with only one raw buffer, try to leave DNG_END_MARGIN to overlap with dereversing
- Doesn't clean dcache if not using cached raw
- Use msleep(0) immediately after creating the task to let it run. I verified that this does in fact start the task (if it's higher priority), and calling msleep(0) does not wait 10 ms. This sometimes allows the reversing to start before the thumbs are finished.
On d10, this gives the best performance so far (~3180 ms)
On a540, it seems a bit worse than the work-3 version (1400 ms vs 1300).
Some comments on the debug counters
wsleep (ws in misc debug)
counts how many times the file writer task waited. This happens if there isn't reversed data past the written data. This can happen if writing the header finishes before the first chunk is completed. Lower is better, since writing is the most time consuming part, you don't want this task waiting around.
wcount (wc)
how many chunks were written. Generally, lower is better. Optimal will probably be 2 on cameras with multiple raw buffers, or 3 on cameras with only one.
rsleep (rs)
how many times the main task waited for the write to complete (in the de-reversing process for cams with only one raw buffer, or waiting at the end).
adjustable parameters
DNG_CHUNK_SIZE
how big a chunk the reversing is done in. Smaller values mean the writer task can get to work sooner, but may cause it to do more writes
DNG_END_MARGIN
This only applies to cameras with one raw buffer, and is meant to avoid the situation I described in my previous post. This defines the minimum amount of the buffer that will have to be de-reversed after all writes are completed.
It's not clear to me how to optimize this for different cameras.