Skip to content

Fix reads across chunk boundaries - #350

Merged
felixbuenemann merged 2 commits into
plexdrive:masterfrom
felixbuenemann:fix-reads-across-chunk-boundaries
Sep 5, 2020
Merged

felixbuenemann merged 2 commits into
plexdrive:masterfrom
felixbuenemann:fix-reads-across-chunk-boundaries

Conversation

@felixbuenemann

@felixbuenemann felixbuenemann commented Feb 25, 2020 •

Copy link
Copy Markdown
Collaborator

When using Direct-IO requests are not guaranteed to be aligned on page
size boundary, like with buffered IO. This means a read request can
start at the end of one chunk and finish at the beginning of the next
chunk. In cases where this happens we now request multiple chunks in
GetChunk and assemble the response data.

This also removed the float conversions in adjustResponseChunk.

IMPORTANT: Must be merged after #349 to avoid corruption, since we would repeat the off-by-one byte.

ToDos:

  • Add unit tests for splitRequestChunks

@felixbuenemann felixbuenemann changed the title Fix reads across chunk boundaries WIP: Fix reads across chunk boundaries Feb 26, 2020
@felixbuenemann

felixbuenemann commented Feb 26, 2020 •

Copy link
Copy Markdown
Collaborator Author

The current approach is suboptimal, since we block on each part until requesting the next part. I'll modify the code so that all parts are requested at once using a large response channel.

Update: Implemented in d389ce4.

@felixbuenemann felixbuenemann changed the title WIP: Fix reads across chunk boundaries Fix reads across chunk boundaries Feb 26, 2020
@felixbuenemann

Copy link
Copy Markdown
Collaborator Author

OK, requesting the chunk slices in parallel was a real pain in the ass to implement, but it works fine now.

@felixbuenemann

Copy link
Copy Markdown
Collaborator Author

Btw. this can also happen when max_readahead is set with buffered io.

@felixbuenemann felixbuenemann self-assigned this Mar 1, 2020
@felixbuenemann
felixbuenemann force-pushed the fix-reads-across-chunk-boundaries branch 3 times, most recently from e338984 to 051544d Compare September 5, 2020 21:59
When using Direct-IO requests are not guaranteed to be aligned on page
size boundary, like with buffered IO. This means a read request can
start at the end of one chunk and finish at the beginning of the next
chunk. In cases where this happens we now request multiple chunks in
GetChunk and assemble the response data.
This improved performance, since we don't have to wait for each slice
sequentially, but can request them all at once.
Since the channel order does not have to match the request order, we
track a sequence number with each request to allow reassembly of the
response out of order.
@felixbuenemann
felixbuenemann force-pushed the fix-reads-across-chunk-boundaries branch from 051544d to 8d4122a Compare September 5, 2020 23:26
@felixbuenemann
felixbuenemann merged commit 0330ec3 into plexdrive:master Sep 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址