feat: decouple partition location from executor metadata
Which issue does this PR close?
Closes #1851.
Rationale for this change
In the current implementation there is a problem - in the PartitionLocation that is used in each shuffle operation (for each partition in the previous stage) there was executor_metadata field (which is of ExecutorMetadata type) filled with unnecessary info, because it did not add up any information that could be used by ShuffleReaderExec to extract partition (or i.e resume the execution from a failed stage)
What changes are included in this PR?
ExecutorMetadata was decoupled from PartitionLocation and now it is used as a separate struct for:
- registering executor
- in heartbeats
- REST API info fetch
PartitionLocation is now exposed only to the executor_id, host and port, which is sufficient for fetching needed partitions by the ShuffleReaderExec
This way we can save up a lot of space and data-transfer during each shuffle operation (potentially removing possibility of Scheduler's OOM errors and improving speed of queries with lots of partitions)
Are there any user-facing changes?
Yes.
In the REST API interface ExecutorResponse doesnt contain nested struct with Executor's hardware and OS info. It was flattened.
Potential follow-up:
- check the TUI REST API integration
Thank you for your review and ideas @milenkovicm Going to tackle it
Refactored the code:
- In the .proto spec now we are sending the
PartitionLocationalong with a map ofExecutorMetadata(used byShuffleReaderPartition). So we can now transfer aVec<>of locations and access the executor's metadata via itsid. - On the native side - added
ExecutorMetadatain thePartitionLocationbehind anArc<>to avoid heavy copying. - Made parts of the .proto spec in the
ExecutorMetadataoptional
@sandugood thank you for the PR. I was wondering if you could provide some sort of before and after benchmarks to gain more confidence here
The OOM crash was reproduced by @gabotechs Wonder if you could potentially test it against this version? Thanks a lot
had a quick look, decoupling executor connection information from partition location makes sense. will try to have another look later. thanks @sandugood
@sandugood , @milenkovicm I closed my PR to prioritize this approach which seems to be more promising and pragmatic
I'm running TPCH (SF10) Q2 with 512 partitions
cargo run --bin tpch -- benchmark ballista -p /Users/marko/TMP/tpch_data/tpch-data-sf10/ -f parquet -i 1 --port 50050 --host 127.0.0.1 -c datafusion.execution.target_partitions=512 -q 2
before PR
Error, decoded message length too large: found 43952013 bytes, the limit is: 16777216 bytes
after PR has been applied
Error, decoded message length too large: found 18947588 bytes, the limit is: 16777216 byte
so its like 2.5x improvement which is good direction
I know there are other things we have to do in order to make using even less data like proposed in #1876 using uuid instead of strings 🤔
good progress @sandugood any suggestions @coderfender ?
Yeah, I will definitely dig into that Saving few bytes here and there makes massive change at scale Thanks for review @milenkovicm
furthermore,
when running Q2 with 256 partitions, executor takes around 460MB with this patch, and 550MB without (which might not be very good metrics to start with) but what i see
with this PR:
Query 2 took 6.989 s and returned 100 rows
Total time: 6.989 s
and without:
Query 2 took 12.037 s and returned 100 rows
Total time: 12.037 s
(unless i made some kind of mess-up with test runs)
Im running latest main with
cargo run --bin ballista-executor --release -- -c 4 --work-dir /path/to/work/dir./
we might not be able to save much on top of this changes, and removing executor_id from metadata might not be justified to bring new type (especially as number of executors might not be too big) so id suggest to try to encapsulate partition locations and executor maps and then if further optimisations could be done we can take them
running with 1024 partitions
Error, decoded message length too large: found 51824978 bytes, the limit is: 16777216 bytes
Refactored the code and placed it inside the PartitionLocationExt .proto spec. Seemed like a good reason to save some bytes there.
However, by running the same Q-2 query on TPCH SF-2 - cargo run --bin tpch -- benchmark ballista -p /home/sandu/datafusion-ballista/data -f parquet -i 1 --port 50050 --host 127.0.0.1 -c datafusion.execution.target_partitions=512 -q 2
Got:
Error, decoded message length too large: found 18834462 bytes, the limit is: 16777216 bytes
Saved 100k (comparing to previous test report) by this change, but couldn't fit it inside the default threshold. cc @milenkovicm @coderfender
Apologies @sandugood Will review this asap AFK for short summer break
sorry @sandugood for delay, will review this PR in next few days, can you please rebase it
Thanks @milenkovicm No need to hurry, take your time