-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: One-pass column optimization #491
Draft
martindurant
wants to merge
29
commits into
dask-contrib:main
Choose a base branch
from
martindurant:one-pass
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b18b3af
start
martindurant 3cdc778
Remove unused
martindurant c57693c
Pass reports around
martindurant 0c367df
remember to commit
martindurant 9c654b1
first working (for parquet)
martindurant e6c5ce3
Merge branch 'main' into one-pass
martindurant f56f77a
stop
martindurant 75b4416
most pass
martindurant a5c319d
fix most
martindurant 243fbc1
probably better
martindurant 6eebf87
Reinstate necessary_columns (needs doc)
martindurant 8bbe409
Merge branch 'main' into one-pass
martindurant 43b2e43
pass buffer names around, not columns
martindurant e5828fb
Clear cache between tests
martindurant df0cf2f
Merge branch 'main' into one-pass
martindurant b593f87
Another one squashed
martindurant e410b61
Squash errors that only show when uproot.dask and hist.dask are insta…
martindurant cd537e2
fix uproot
martindurant baf6f46
fix report
martindurant e29e929
if meta fails
martindurant f61fdd7
rev
martindurant 2c3abd0
concat enforce condition
martindurant 04abbc8
temp
martindurant d876f00
squached some
martindurant 8e1d507
add note
martindurant d1922ab
Merge branch 'main' into one-pass
martindurant fc9589b
Fix concat form comparison
martindurant 961dd0c
one more squashed
martindurant c8b254b
fix IO report
martindurant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we lift
_report
from the meta to the Layer? I know that it's more state to keep in sync, but I don't love the act of tagging non-reserved attributes onto an Awkward Array, and this will better separate the stateful part of typetracer from the stateless part.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpivarski I wonder whether we should add a new
merge
function toTypeTracerReport
. Due to the uniqueness of layer IDs, and the existing association of reports with layouts, we can replace the need to carry a set of reports with a single report viaI haven't yet thought about the memory implication for effectively having "larger" reports, but this might be a nicer UX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These Awkward Arrays are not accessible to users ("
_meta
" has an underscore); they're internal, bookkeeping objects. There's a similar use of temporary attributes in conversions from Arrow:https://github.com/scikit-hep/awkward/blob/727ff9ca4759aed52e0b4f21d3daa66724582c61/src/awkward/_connect/pyarrow/conversions.py#L69-L71
and
https://github.com/scikit-hep/awkward/blob/727ff9ca4759aed52e0b4f21d3daa66724582c61/src/awkward/operations/ak_from_arrow.py#L75-L79
We're using the convenience of Python objects as dicts to handle a bookkeeping problem that would get more complicated if we were to try to do it in a statically typable way (although we could also make these "backdoors" into nullable, private attributes that are unused in almost all other circumstances).
An attempt to do this a bit more by-the-book with Indexes unfortunately made too much noise. The Index class has an arbitrary
metadata
that can be used to stash whatever we need:https://github.com/scikit-hep/awkward/blob/727ff9ca4759aed52e0b4f21d3daa66724582c61/src/awkward/index.py#L43-L52
although it was only ever used for one thing: associating a multidimensional integer array slice with an Index, which is one-dimensional.
https://github.com/scikit-hep/awkward/blob/727ff9ca4759aed52e0b4f21d3daa66724582c61/src/awkward/_slicing.py#L143-L145
That's pretty obscure, but Index now has this mechanism everywhere, and it must make people wonder why it's there.
A hacky solution, like attaching temporary metadata to a Python object as though it were a dict, can prevent an implementation detail about a corner case from getting "noisy," alerting all parts of the code about its existence. If the hacky solution is implemented incorrectly and the hack spreads, then we'd be wishing we had that noise to help understand what's going wrong, but if it's implemented correctly and no one finds out what happens in Vegas, making it formal would obfuscate the normal case with an outlier.
So I'd be in favor of leaving in the
_report
attribute handling, especially if something ensures that it never leaves the graph-optimization phase. The example above with a__pyarrow_original
attribute (which includes its context in its name, by the way) has an explicit, recursive procedure to ensure that no layouts escapeak.from_arrow
with that attribute intact. I don't know if there's a similar guarantee for_report
.