Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateless Row Conversion #4811

Closed
tustvold opened this issue Sep 13, 2023 · 4 comments · Fixed by #4819
Closed

Stateless Row Conversion #4811

tustvold opened this issue Sep 13, 2023 · 4 comments · Fixed by #4819
Assignees
Labels
arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate enhancement Any new improvement worthy of a entry in the changelog

Comments

@tustvold
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Currently row conversion is stateful, relying on a separate RowConverter to maintain this global state.

This has a number of drawbacks:

Describe the solution you'd like

I would like to propose removing the dictionary preservation logic, instead always hydrating the dictionaries values when encoding. This in turn would allow simplifying the API to no longer have a notion of a stateful RowConverter.

This may represent a performance regression for dictionaries with small number of values. We should definitely quantify this, but it is my expectation that this will only occur for dictionaries with a very low number of values. It is currently the case that even arrays with low numbers of distinct values may contain non-trivial number of values as a result of the way dictionaries are handled by the various kernels and readers, and so I'm inclined to not weigh this very highly.

Describe alternatives you've considered

Additional context

@alamb
Copy link
Contributor

alamb commented Sep 13, 2023

I personally think this proposal is very compelling because using high cardinality dictionaries has caused us significant pain in IOx due to the memory accumulated in the row converters. We have several non trivial PRs to properly account for and try to avoid using dictionary encoding for these cases -- see apache/datafusion#7130 and apache/datafusion#7401 for example

Also, a stateful row converter has caused other operations like apache/datafusion#7379 from @wiedld become significantly more complicatated as it can't be shared between threads

Thus, in my mind the ideal outcome would be that we can remove the stateful row conversion and minimize the performance penalty for relatively low cardinality dictionaries. I am hopeful that @tustvold 's ideas to make string encoding more efficient (e.g. #4812) could be part of this answer

@tustvold tustvold self-assigned this Sep 13, 2023
@alamb
Copy link
Contributor

alamb commented Sep 13, 2023

The one case I can think of where a stafeful row converter is likely to have massive benefit is with low cardinality dictionaries that have very large individual values (e.g. 2MB strings for each entry). I have no idea how common that type of data is in practice.

tustvold added a commit to tustvold/arrow-rs that referenced this issue Sep 15, 2023
tustvold added a commit to tustvold/arrow-rs that referenced this issue Sep 15, 2023
tustvold added a commit to tustvold/arrow-rs that referenced this issue Sep 15, 2023
tustvold added a commit that referenced this issue Sep 17, 2023
#4811) (#4819)

* Stateless Row Encoding / Don't Preserve Dictionaries (#4811)

* Add low cardinality benchmarks
@tustvold tustvold added the arrow Changes to the arrow crate label Sep 18, 2023
@tustvold
Copy link
Contributor Author

label_issue.py automatically added labels {'arrow'} from #4819

@tustvold tustvold added the arrow-flight Changes to the arrow-flight crate label Sep 18, 2023
@tustvold
Copy link
Contributor Author

label_issue.py automatically added labels {'arrow-flight'} from #4819

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants