You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reported very slow performance compared to DuckDB in ibis-project #8492
DataFusion
DataFusion never ran out of memory and had a memory profile similar to DuckDB:
single digit GBs peak memory.
However, it was still extremely slow compared to DuckDB, about 9-10 minutes to
run the whole workload.
Similarly to Polars I compared both the Ibis implementation and a hand-written
SQL version (built from the generated Ibis code). Both had the same performance
I also looked at perf top while the DataFusion workload was running and saw this:
To Reproduce
TBD (first thing would be to get a datafusion only reproducer)
I wonder if the slowness in regexp / time spent compiling stuff is related to not being able to pre-compile the argument and instead re-creating the regular expression for each batch.
I looked into the regular expression matching code in DataFusion -- there is a lot of room for improvement:
It translates each argument into an array (even when the argument is a constant). Thus DataFusion is effectively compiling the regular expression for each row (not even each batch) which is unsurprisingly quite expensive
This is very fixable but the way the functions are wired in will take some finagling I think
Activity
alamb commentedon Dec 11, 2023
I wonder if the slowness in regexp / time spent compiling stuff is related to not being able to pre-compile the argument and instead re-creating the regular expression for each batch.
@thinkharderdev mentioned something similar for #8051
cpcloud commentedon Dec 11, 2023
Thanks for creating the issue!
The example can be simplified a bit.
It should be sufficient to see the performance difference with DuckDB by:
SELECT.Dandandan commentedon Dec 12, 2023
A similar problem (recompiling the regex again and again) I found some time ago in the clickbench benchmark as well (query 28):
https://github.com/JayjeetAtGithub/datafusion-duckdb-benchmark/blob/main/clickbench/queries-datafusion.sql#L29
zhangxffff commentedon Dec 14, 2023
test with simple regexp_match query with
index-0.parquetarray-datafusiontook 47.847 seconds.duckdbtook 3.029 secondsWeijun-H commentedon Dec 14, 2023
Maybe related to this #8524
cpcloud commentedon Dec 14, 2023
Seems unlikely to be related to #8524. The issue is present for a single file.
alamb commentedon Dec 14, 2023
I had some ideas on how to speed up regular expression evaluation here: #8051 (comment)
comphead commentedon Dec 15, 2023
Attaching Flamegraph for the query
alamb commentedon Dec 15, 2023
The blog post is now published: https://ibis-project.org/posts/pydata-performance-part2/
alamb commentedon Dec 15, 2023
I looked into the regular expression matching code in DataFusion -- there is a lot of room for improvement:
It translates each argument into an array (even when the argument is a constant). Thus DataFusion is effectively compiling the regular expression for each row (not even each batch) which is unsurprisingly quite expensive
This is very fixable but the way the functions are wired in will take some finagling I think
alamb commentedon Dec 23, 2023
@viirya found some very low hanging fruit:
#8538#8631cpcloud commentedon Dec 23, 2023
Happy to try the query again once the next release is out!
viirya commentedon Dec 23, 2023
It is #8631 actually. 😄
my-vegetable-has-exploded commentedon Mar 23, 2024
Hi, could you share the method to draw the flamegraph?
There is a large "unknown" in my flame graph, which prevents me from tracking the function call chain.
Here is my shell to generate the flamegraph using
datafusion-cli.Thanks very much. @comphead
alamb commentedon Mar 23, 2024
@comphead recently added this to the contributor guide: https://arrow.apache.org/datafusion/library-user-guide/profiling.html#building-a-flamegraph