improve filesort()
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 40
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
Taking a look at the file based sort now, and recording observations and design notes here as I go.
Current implementation
based on bucket sort
- Manager reads the first
nsamp=1000rows of file (or a sample of distributed data frame) - Manager uses quantiles to choose approximately equal sized bins based on sample
- Each worker reads all the data in and keeps only those that belong to its chunk
- Each worker sorts it's chunk and makes it a global variable
outdfnm
Notes
- Data must fit in memory on the cluster
- The entire data is read
ktimes, once for each of thekworkers.
Alternative 1: Single read
data.table has high performance reading and sorting using multithreading. If the data will fit in memory then it may well be faster to read and sort in the manager, then send to the workers using distribsplit().
Alternative 2: Temporary file based
Use steps 1 and 2 in the current implementation to determine bins. Then:
- Assign each worker a subset of the distributed files to read and split
- Each worker reads these files in chunks, splitting the chunk and appending into it's own private set of bins. This results in the following temporary directory structure:
- worker1
file_bin1
file_bin2
...
- worker2
file_bin1
file_bin2
...
etc.
Finally, each worker is responsible for reading and sorting a subset of the bins. If there are more bins than workers then we can write the sorted files to disk without requiring that the data fit in memory. This approach requires 2 reads and 1 write, instead of k reads.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the filesort() implementation and the current bucket-sort flow described here, including distribsplit() and the data.table comparison. The issue records alternatives but does not define a selected design or acceptance criteria, so a contributor would need maintainer guidance before identifying what “done” means.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data, distributed-systems, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100