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

ARROW-17812: [Gandiva][Docs] Add C++ Gandiva User Guide #14200

Merged
merged 8 commits into from
Nov 8, 2022

Conversation

wjones127
Copy link
Member

No description provided.

@github-actions
Copy link

@wjones127
Copy link
Member Author

FYI @js8544

@js8544
Copy link
Collaborator

js8544 commented Sep 22, 2022

Thanks!

@js8544
Copy link
Collaborator

js8544 commented Sep 22, 2022

@pitrou Would you mind reviewing this PR? I am planning on improving Gandiva's doc based on Will's work.

Copy link
Member

@pitrou pitrou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice and well-written, thanks a lot @wjones127 !

docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
Gandiva was designed to take advantage of the Arrow memory format and modern
hardware. Compiling expressions using LLVM allows the execution to be optimized
to the local runtime environment and hardware, including available SIMD
instructions. To minimize optimization overhead, all Gandiva functions are
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really all Gandiva functions (including e.g. simple additions) or the most costly ones?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I would say "To reduce optimization overhead".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to "many", though I'm not sure which is right. I wrote this about a year ago, based on what I could understand from the Arrow and Dremio blog posts. But I've forgotten where I might have gotten this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pitrou As far as I understand all functions are precompiled to LLVM IR. For example addition is defined here as a C function: https://github.com/apache/arrow/blob/master/cpp/src/gandiva/precompiled/arithmetic_ops.cc#L85. During the build process, all functions will first be compiled to LLVM IR format(https://github.com/apache/arrow/blob/master/cpp/src/gandiva/precompiled/CMakeLists.txt#L88) and loaded by the LLVM engine before any computation occurs (https://github.com/apache/arrow/blob/master/cpp/src/gandiva/engine.cc#L257).

docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
@pitrou
Copy link
Member

pitrou commented Sep 22, 2022

@ksuarez1423 Do you want to take a look at the additions here?

Copy link
Contributor

@ksuarez1423 ksuarez1423 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this is really nice! I really like the flow of explaining trees, then evaluation of trees, without overlap. That really makes things easier to follow, and I left a comment at each place that I was a little lost.

docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
====================

Gandiva provides a general expression representation where expressions are
represented by a tree of nodes. The expression trees are built using
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth explaining what the nodes represent in particular. While I can figure it out in the next section, where function nodes are discussed, having to wait for that clarity feels weird to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what would really be helpful would be to draw an expression tree, but idk if I want to do that in this PR.

I don't really know how to describe what a node itself means. That's why I first describe the leaves, and then the composite nodes. And then give an example.

If you have a suggestion, though, I'd happily take it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something's off in the writing, then -- I did not find myself thinking of "composite nodes" after reading, only leaf nodes, then something that's above that. It might be worth going more in depth in an additional paragraph, at least.

As for how to describe them, internal nodes represent operations that handle multiple leaves, while leaves contain fields and literals, I believe? I haven't written any Gandiva, so if I'm off-key here, we could talk further.


Once a Projector or Filter is created, it can be evaluated on Arrow record batches.
These execution kernels are single-threaded on their own, but are designed to be
reused to process distinct record batches in parallel.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could an example be provided of how to do this? Even if it's just "use them in your OpenMP threads," that still provides some useful guidance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm not familiar enough with multi-threading in C++ to have a ready example for that. We have some task and thread pool machinery in Arrow, but that's not what users would be expected to use.

docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
@wjones127
Copy link
Member Author

@github-actions crossbow submit preview-docs

@github-actions
Copy link

Revision: 79deadc

Submitted crossbow builds: ursacomputing/crossbow @ actions-3d38fbfa71

Task Status
preview-docs Github Actions

@wjones127 wjones127 force-pushed the ARROW-17812-gandiva-user-guide branch from 3099fe0 to 7149a2c Compare October 24, 2022 21:25
@wjones127
Copy link
Member Author

@github-actions crossbow submit preview-docs

@github-actions
Copy link

Revision: 7149a2c

Submitted crossbow builds: ursacomputing/crossbow @ actions-2243107e33

Task Status
preview-docs Github Actions

@wjones127 wjones127 requested review from pitrou and ksuarez1423 and removed request for pitrou October 31, 2022 20:00
@pitrou pitrou requested review from js8544 and removed request for ksuarez1423 October 31, 2022 20:01
Copy link
Collaborator

@js8544 js8544 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

docs/source/cpp/gandiva.rst Outdated Show resolved Hide resolved
@wjones127 wjones127 merged commit 5182d62 into apache:master Nov 8, 2022
@ursabot
Copy link

ursabot commented Nov 9, 2022

Benchmark runs are scheduled for baseline = 8a5aa67 and contender = 5182d62. 5182d62 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Failed ⬇️0.27% ⬆️0.07%] test-mac-arm
[Finished ⬇️0.27% ⬆️0.0%] ursa-i9-9960x
[Failed ⬇️0.18% ⬆️0.04%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] 5182d62f ec2-t3-xlarge-us-east-2
[Failed] 5182d62f test-mac-arm
[Finished] 5182d62f ursa-i9-9960x
[Finished] 5182d62f ursa-thinkcentre-m75q
[Finished] 8a5aa671 ec2-t3-xlarge-us-east-2
[Finished] 8a5aa671 test-mac-arm
[Finished] 8a5aa671 ursa-i9-9960x
[Failed] 8a5aa671 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@ursabot
Copy link

ursabot commented Nov 9, 2022

['Python', 'R'] benchmarks have high level of regressions.
ursa-i9-9960x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants