Open chipkent opened 1 year ago
After much struggle with the environment on my laptop, I ran some tests with a slightly modified version of @chipkent 's code and got this result. The conclusion: the performance hit by applying the dh_null_to_nan
decorator is surprisingly small 10 - 15%. However with dh_null_to_na
(to Pandas series), it is much worse, which can be explained by the fact that
The same result can be seen across the spectrum of group numbers, row counts.
Based on these results, I think we probably should avoid providing the option of auto-conversion-to-pd-na and simply auto converting Java arrays to numpy arrays and auto applying the null conversion. This will make
dh_null_to_na
decorator and check for its application at runtime to determine if numpy array conversion should be automatically run.No conversion
@dh_null_to_nan
@dh_null_to_na
I ran into a case where the UDF is type annotated to receive numpy int64 ndarray as an input parameter and return the same type but instead of getting a float64 ndarray and returning a float64 ndarray. This made me think that the 'implicit' auto-null conv and its side effect of auto promotion integer arrays to float64 arrays is really too aggressive and will trip a lot of users. So it seems that having a auto_null_conv
decorator to force explicit use of it is still the way to go.
I added a new variant to @chipkent 's original script of the custom Python function with type hints and ran it under the https://github.com/deephaven/deephaven-core/pull/5291. The key results are:
The full output:
A user asked me to examine the performance of the
grouping_agg
function in the code below. He believed that "slow" performance he was seeing was the result ofgroup_by
followed byungroup
. I created the following benchmarks to examine performance. These benchmarks indicate thegroup_by
followed byungroup
is efficient, but how logic is represented as functions can make a 7x performance difference.The numbers below were generated on a v0.29 release candidate.
There are some interesting things to note: 1) Python to Java typecasting does not appear to make a material performance difference. This casting should be happening in both cases.
2) Performance is reasonably consistent across different numbers of rows, once the number of rows is sufficiently large.
3) Performance is reasonably consistent across different numbers of groups.
4) Performance is highly variable depending upon how logic is represented.
This data suggests that: