can cai
09/03/2025, 5:27 PMdef stream_plan(
self,
plan: DistributedPhysicalPlan,
partition_sets: dict[str, PartitionSet[ray.ObjectRef]],
) -> Iterator[RayMaterializedResult]:
plan_id = plan.id()
t=time.time()
sz=len(cp.dumps(plan))
print("plan pickle bytes:", sz, "secs:", time.time()-t)
ray.get(self.runner.run_plan.remote(plan, partition_sets))
while True:
materialized_result = ray.get(self.runner.get_next_partition.remote(plan_id))
if materialized_result is None:
break
yield materialized_result
During the test, I found that the size of DistributedPhysicalPlan reached 13GB, which is very unreasonable. Moreover, the serialization process took a very long time, nearly 10 minutes.
Is there any way to easily analyze what is too big in the DistributedPhysicalPlan Object?
plan pickle bytes: 13298686802 secs: 596.3822300434113Colin Ho
09/03/2025, 5:37 PMdf.explain(True) ?can cai
09/03/2025, 5:47 PM== Unoptimized Logical Plan ==
* Limit: 10
|
* PythonScanOperator: LanceDBScanOperator(/mnt/bos-text/python_merged.lance)
| File schema = seq_id#Int64, ext#Utf8, file_size_in_byte#Int64,
| program_lang#Utf8, doc_type#Utf8, text#Utf8, filename#Utf8, repo_name#Utf8,
| sub_path#Utf8, stars#Utf8, dataset#Utf8, pt#Utf8, tar_path#Utf8, file_path#Utf8
| Partitioning keys = []
| Output schema = seq_id#Int64, ext#Utf8, file_size_in_byte#Int64,
| program_lang#Utf8, doc_type#Utf8, text#Utf8, filename#Utf8, repo_name#Utf8,
| sub_path#Utf8, stars#Utf8, dataset#Utf8, pt#Utf8, tar_path#Utf8, file_path#Utf8
== Optimized Logical Plan ==
* Limit: 10
| Stats = { Approx num rows = 0, Approx size bytes = 0 B, Accumulated selectivity
| = 1.00 }
|
* Num Scan Tasks = 8354
| File schema = seq_id#Int64, ext#Utf8, file_size_in_byte#Int64,
| program_lang#Utf8, doc_type#Utf8, text#Utf8, filename#Utf8, repo_name#Utf8,
| sub_path#Utf8, stars#Utf8, dataset#Utf8, pt#Utf8, tar_path#Utf8, file_path#Utf8
| Partitioning keys = []
| Limit pushdown = 10
| Output schema = seq_id#Int64, ext#Utf8, file_size_in_byte#Int64,
| program_lang#Utf8, doc_type#Utf8, text#Utf8, filename#Utf8, repo_name#Utf8,
| sub_path#Utf8, stars#Utf8, dataset#Utf8, pt#Utf8, tar_path#Utf8, file_path#Utf8
| Stats = { Approx num rows = 0, Approx size bytes = 0 B, Accumulated selectivity
| = 1.00 }
== Physical Plan ==
* Limit: 10
|
* ScanTaskSource:
| Num Scan Tasks = 8354
| Estimated Scan Bytes = 0
| Pushdowns: {limit: 10}
| Schema: {seq_id#Int64, ext#Utf8, file_size_in_byte#Int64, program_lang#Utf8,
| doc_type#Utf8, text#Utf8, filename#Utf8, repo_name#Utf8, sub_path#Utf8,
| stars#Utf8, dataset#Utf8, pt#Utf8, tar_path#Utf8, file_path#Utf8}
| Scan Tasks: [
| {daft.io.lance.lance_scan:_lancedb_table_factory_function}
| {daft.io.lance.lance_scan:_lancedb_table_factory_function}
| {daft.io.lance.lance_scan:_lancedb_table_factory_function}
| ...
| {daft.io.lance.lance_scan:_lancedb_table_factory_function}
| {daft.io.lance.lance_scan:_lancedb_table_factory_function}
| {daft.io.lance.lance_scan:_lancedb_table_factory_function}
| ]Colin Ho
09/03/2025, 5:51 PMColin Ho
09/03/2025, 5:52 PMHowever, I printed out the size of a single ScanTask, which was only 0.75MB.What is the size when you pickle a single scantask?
can cai
09/03/2025, 5:54 PMColin Ho
09/03/2025, 6:11 PMdaft/io/lance/lance_scan.py we don't take the limit into consideration when creating scan tasks now.
However, each fragment has physical_rows and num_deletions properties https://github.com/lancedb/lance/blob/main/python/python/lance/fragment.py#L384, which we can use to correctly get the number of rows from the fragment, given that there are no filters. Looks like this is what happens in count_rows as well: https://github.com/lancedb/lance/blob/main/rust/lance/src/dataset/fragment.rs#L1049-L1055
cc @Jay @Cory GrinsteadJay
09/04/2025, 12:15 AMJay
09/04/2025, 12:15 AMJay
09/04/2025, 12:16 AMColin Ho
09/04/2025, 12:17 AMColin Ho
09/04/2025, 12:17 AMJay
09/04/2025, 12:19 AMJay
09/04/2025, 12:24 AMcount_rows. Do you need me to supplement the implementation for this?Colin Ho
09/04/2025, 1:10 AMJay
09/04/2025, 1:23 AMcan cai
09/04/2025, 7:27 AMJay
09/05/2025, 2:34 AMJay
09/05/2025, 2:34 AM