datafusion-ballista icon indicating copy to clipboard operation
datafusion-ballista copied to clipboard

feat: decouple partition location from executor metadata

Open sandugood opened this issue 5 months ago • 13 comments

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

sandugood avatar Jun 09 '26 21:06 sandugood

Thank you for your review and ideas @milenkovicm Going to tackle it

sandugood avatar Jun 10 '26 12:06 sandugood

Refactored the code:

  1. In the .proto spec now we are sending the PartitionLocation along with a map of ExecutorMetadata (used by ShuffleReaderPartition). So we can now transfer a Vec<> of locations and access the executor's metadata via its id.
  2. On the native side - added ExecutorMetadata in the PartitionLocation behind an Arc<> to avoid heavy copying.
  3. Made parts of the .proto spec in the ExecutorMetadata optional

sandugood avatar Jun 16 '26 10:06 sandugood

@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

coderfender avatar Jun 17 '26 07:06 coderfender

The OOM crash was reproduced by @gabotechs Wonder if you could potentially test it against this version? Thanks a lot

sandugood avatar Jun 17 '26 07:06 sandugood

had a quick look, decoupling executor connection information from partition location makes sense. will try to have another look later. thanks @sandugood

milenkovicm avatar Jun 17 '26 12:06 milenkovicm

@sandugood , @milenkovicm I closed my PR to prioritize this approach which seems to be more promising and pragmatic

coderfender avatar Jun 17 '26 21:06 coderfender

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 ?

milenkovicm avatar Jun 18 '26 10:06 milenkovicm

Yeah, I will definitely dig into that Saving few bytes here and there makes massive change at scale Thanks for review @milenkovicm

sandugood avatar Jun 18 '26 10:06 sandugood

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./

milenkovicm avatar Jun 18 '26 11:06 milenkovicm

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

milenkovicm avatar Jun 18 '26 11:06 milenkovicm

running with 1024 partitions

Error, decoded message length too large: found 51824978 bytes, the limit is: 16777216 bytes

milenkovicm avatar Jun 18 '26 13:06 milenkovicm

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

sandugood avatar Jun 20 '26 15:06 sandugood

Apologies @sandugood Will review this asap AFK for short summer break

milenkovicm avatar Jun 27 '26 06:06 milenkovicm

sorry @sandugood for delay, will review this PR in next few days, can you please rebase it

milenkovicm avatar Jul 13 '26 21:07 milenkovicm

Thanks @milenkovicm No need to hurry, take your time

sandugood avatar Jul 14 '26 18:07 sandugood