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

doc: Add initial doc how to expand Comet exceptions #170

Merged
merged 3 commits into from
Mar 6, 2024

Conversation

comphead
Copy link
Contributor

@comphead comphead commented Mar 6, 2024

Which issue does this PR close?

Closes #104 .

Rationale for this change

Adding docs how to extend Comet exceptions by leveraging DF backtraces

What changes are included in this PR?

How are these changes tested?

@comphead comphead requested review from viirya and sunchao March 6, 2024 01:24
@comphead
Copy link
Contributor Author

comphead commented Mar 6, 2024

@snmvaughan cc

DEBUGGING.md Outdated
Start Comet with `RUST_BACKTRACE=1`

```commandline
RUST_BACKTRACE=1 $SPARK_HOME/spark-shell --jars spark/target/comet-spark-spark3.4_2.12-0.1.0-SNAPSHOT.jar --conf spark.sql.extensions=org.apache.comet.CometSparkSessionExtensions --conf spark.comet.enabled=true --conf spark.comet.exec.enabled=true --conf spark.comet.exec.all.enabled=true
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, if we don't enable RUST_BACKTRACE=1, is there any performance penalty from enabling backtrace?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. If there's no penalty without enabling RUST_BACKTRACE=1, I think we can build with backtrace enabled and disabled it at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just curious, if we don't enable RUST_BACKTRACE=1, is there any performance penalty from enabling backtrace?

We had some discussion back in the day on this apache/datafusion#7522 (comment)

The problem was with analyzer, and in Comet we use physical plan, however it might still have some overhead IMHO, as it has to call Backtrace::enabled function which will def take some cpu cycles

Copy link
Contributor

@advancedxy advancedxy left a comment

Choose a reason for hiding this comment

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

wow, thanks for this doc. I think it's super useful.

DEBUGGING.md Outdated
```
Note:
- The backtrace coverage in Datafusion is still improving. So there is a chance the error still not covered, feel free to file a [ticket](https://github.com/apache/arrow-datafusion/issues)
- The backtrace doesn't come for free and therefore intended for debugging purposes
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious to know, what percentage of overhead are we talking about? Like 1%, 5% or something 10%?

DEBUGGING.md Outdated
To do that with Comet it is needed to enable `backtrace` in https://github.com/apache/arrow-datafusion-comet/blob/main/core/Cargo.toml

```
datafusion-common = { version = "36.0.0", features = ["backtrace"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like we should update the cargo.toml to include backtrace feature by default for local/debug build?

DEBUGGING.md Outdated
Start Comet with `RUST_BACKTRACE=1`

```commandline
RUST_BACKTRACE=1 $SPARK_HOME/spark-shell --jars spark/target/comet-spark-spark3.4_2.12-0.1.0-SNAPSHOT.jar --conf spark.sql.extensions=org.apache.comet.CometSparkSessionExtensions --conf spark.comet.enabled=true --conf spark.comet.exec.enabled=true --conf spark.comet.exec.all.enabled=true
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. If there's no penalty without enabling RUST_BACKTRACE=1, I think we can build with backtrace enabled and disabled it at runtime.

DEBUGGING.md Outdated
Start Comet with `RUST_BACKTRACE=1`

```commandline
RUST_BACKTRACE=1 $SPARK_HOME/spark-shell --jars spark/target/comet-spark-spark3.4_2.12-0.1.0-SNAPSHOT.jar --conf spark.sql.extensions=org.apache.comet.CometSparkSessionExtensions --conf spark.comet.enabled=true --conf spark.comet.exec.enabled=true --conf spark.comet.exec.all.enabled=true
Copy link
Contributor

Choose a reason for hiding this comment

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

A little off the topic. For distributed environments, I believe --conf spark.executorEnv.RUST_BACKTRACE=1 should be passed to make sure executor's JVM is started with backtrace enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is good idea if we decide to keep backtrace enabled always

@comphead
Copy link
Contributor Author

comphead commented Mar 6, 2024

If we ok with the initial text lets merge it and I'll create a followup to measure performance with backtrace feature enabled/disabled

DEBUGGING.md Outdated
@@ -30,6 +30,62 @@ LLDB or the LLDB that is bundled with XCode. We will use the LLDB packaged with

_Caveat: The steps here have only been tested with JDK 11_ on Mac (M1)

# Expand Comet exception details
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems a bit weird to put this between the first paragraph and the section of Debugging for Advanced Developers which are both talking about IDEs..

How about put this part after Additional Info?

Otherwise, thos doc LGTM.

@comphead comphead requested review from sunchao and advancedxy March 6, 2024 18:01
Copy link
Member

@sunchao sunchao left a comment

Choose a reason for hiding this comment

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

LGTM

DEBUGGING.md Outdated

```

There is a verbose exception option by leveraging Datafusion [backtraces](https://arrow.apache.org/datafusion/user-guide/example-usage.html#enable-backtraces)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
There is a verbose exception option by leveraging Datafusion [backtraces](https://arrow.apache.org/datafusion/user-guide/example-usage.html#enable-backtraces)
There is a verbose exception option by leveraging DataFusion [backtraces](https://arrow.apache.org/datafusion/user-guide/example-usage.html#enable-backtraces)

DEBUGGING.md Outdated
```

There is a verbose exception option by leveraging Datafusion [backtraces](https://arrow.apache.org/datafusion/user-guide/example-usage.html#enable-backtraces)
This option allows to append native Datafusion stacktrace to the original error message.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This option allows to append native Datafusion stacktrace to the original error message.
This option allows to append native DataFusion stacktrace to the original error message.

DEBUGGING.md Outdated

There is a verbose exception option by leveraging Datafusion [backtraces](https://arrow.apache.org/datafusion/user-guide/example-usage.html#enable-backtraces)
This option allows to append native Datafusion stacktrace to the original error message.
To enable this option with Comet it is needed to include `backtrace` feature in [Cargo.toml](https://github.com/apache/arrow-datafusion-comet/blob/main/core/Cargo.toml) for Datafusion dependencies
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
To enable this option with Comet it is needed to include `backtrace` feature in [Cargo.toml](https://github.com/apache/arrow-datafusion-comet/blob/main/core/Cargo.toml) for Datafusion dependencies
To enable this option with Comet it is needed to include `backtrace` feature in [Cargo.toml](https://github.com/apache/arrow-datafusion-comet/blob/main/core/Cargo.toml) for DataFusion dependencies

DEBUGGING.md Outdated
...
```
Note:
- The backtrace coverage in Datafusion is still improving. So there is a chance the error still not covered, feel free to file a [ticket](https://github.com/apache/arrow-datafusion/issues)
Copy link
Member

@viirya viirya Mar 6, 2024

Choose a reason for hiding this comment

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

Suggested change
- The backtrace coverage in Datafusion is still improving. So there is a chance the error still not covered, feel free to file a [ticket](https://github.com/apache/arrow-datafusion/issues)
- The backtrace coverage in DataFusion is still improving. So there is a chance the error still not covered, feel free to file a [ticket](https://github.com/apache/arrow-datafusion/issues).

DEBUGGING.md Outdated
```
Note:
- The backtrace coverage in Datafusion is still improving. So there is a chance the error still not covered, feel free to file a [ticket](https://github.com/apache/arrow-datafusion/issues)
- The backtrace doesn't come for free and therefore intended for debugging purposes
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- The backtrace doesn't come for free and therefore intended for debugging purposes
- The backtrace doesn't come for free and therefore intended for debugging purposes.

Copy link
Member

Choose a reason for hiding this comment

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

I'm afraid that "doesn't come for free" reads a bit ambiguous. Maybe change to more explicit way like "The backtrace comes with performance cost ...".

@comphead
Copy link
Contributor Author

comphead commented Mar 6, 2024

Addressed all the comments, thanks folks for helping with the review. I plan to merge it within 1 hr, if no other comments

@comphead comphead merged commit 0915342 into apache:main Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include Rust's native stack trace in CometNativeException
4 participants