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

[feature](tools) embed async profiler to help user generate flame graph for frontend #35010

Merged
merged 5 commits into from
May 17, 2024

Conversation

924060929
Copy link
Contributor

@924060929 924060929 commented May 17, 2024

Proposed changes

background: some users want to find the bottleneck of the frontend, but they can not provide their query sql and schema because of privacy, so I embed async profiler to help they generate flame graph for frontend in their environment.

There has a script file ${FE_DEPLOY_PATH}/bin/profile_fe.sh do the profile:
start profiler example

$ bin/profile_fe.sh
$ PROFILE_SECONDS=1 bin/profile_fe.sh

This is the real example:

$ PROFILE_SECONDS=1 bin/profile_fe.sh
DORIS_HOME: /Users/lanhuajian/github/doris/output/fe
JAVA: /Users/lanhuajian/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home/bin/java
DorisFE pid: 29494
Begin profiling 1 seconds and generate flame graph to /Users/lanhuajian/github/doris/output/fe/log/profile_20240517154934.html...

Profiling for 1 seconds
Done
Generated flame graph to /Users/lanhuajian/github/doris/output/fe/log/profile_20240517154934.html

You can use web browser to open the generated html file to troubleshooting performance issues.

The flame graph html file would look like this:
image

Note: this profiler use the async-profiler tool, so it only support in Linux and MacOS

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In bin/profile_fe.sh line 22:
    cd "${curdir}/.."
    ^---------------^ SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

Did you mean: 
    cd "${curdir}/.." || exit


In bin/profile_fe.sh line 47:
FE_PID=`jps | grep DorisFE | awk '{print $1}'`
       ^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
FE_PID=$(jps | grep DorisFE | awk '{print $1}')


In bin/profile_fe.sh line 48:
if [[ -z "$FE_PID" ]]; then
          ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
if [[ -z "${FE_PID}" ]]; then


In bin/profile_fe.sh line 52:
echo "DorisFE pid: $FE_PID"
                   ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DorisFE pid: ${FE_PID}"


In bin/profile_fe.sh line 55:
NOW=`date +'%Y%m%d%H%M%S'`
    ^--------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
NOW=$(date +'%Y%m%d%H%M%S')

For more information:
  https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |...
  https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
  https://www.shellcheck.net/wiki/SC2250 -- Prefer putting braces around vari...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- bin/profile_fe.sh.orig
+++ bin/profile_fe.sh
@@ -44,15 +44,15 @@
     exit 1
 fi
 
-FE_PID=`jps | grep DorisFE | awk '{print $1}'`
+FE_PID=$(jps | grep DorisFE | awk '{print $1}')
 if [[ -z "$FE_PID" ]]; then
-  echo "DorisFe not started"
-  exit 1
+    echo "DorisFe not started"
+    exit 1
 fi
 echo "DorisFE pid: $FE_PID"
 
 mkdir -p "${DORIS_HOME}/log"
-NOW=`date +'%Y%m%d%H%M%S'`
+NOW=$(date +'%Y%m%d%H%M%S')
 PROFILE_OUTPUT="${DORIS_HOME}/log/profile_${NOW}.html"
 if [[ -z "${PROFILE_SECONDS}" ]]; then
     PROFILE_SECONDS="10"
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In bin/profile_fe.sh line 22:
    cd "${curdir}/.."
    ^---------------^ SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

Did you mean: 
    cd "${curdir}/.." || exit


In bin/profile_fe.sh line 48:
if [[ -z "$FE_PID" ]]; then
          ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
if [[ -z "${FE_PID}" ]]; then


In bin/profile_fe.sh line 52:
echo "DorisFE pid: $FE_PID"
                   ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DorisFE pid: ${FE_PID}"

For more information:
  https://www.shellcheck.net/wiki/SC2164 -- Use 'cd ... || exit' or 'cd ... |...
  https://www.shellcheck.net/wiki/SC2250 -- Prefer putting braces around vari...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors
'shfmt ' found no issues.

Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In bin/profile_fe.sh line 48:
if [[ -z "$FE_PID" ]]; then
          ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
if [[ -z "${FE_PID}" ]]; then


In bin/profile_fe.sh line 52:
echo "DorisFE pid: $FE_PID"
                   ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DorisFE pid: ${FE_PID}"

For more information:
  https://www.shellcheck.net/wiki/SC2250 -- Prefer putting braces around vari...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors
'shfmt ' found no issues.

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label May 17, 2024
Copy link
Contributor

PR approved by at least one committer and no changes requested.

Copy link
Contributor

PR approved by anyone and no changes requested.

@924060929
Copy link
Contributor Author

run buildall

@924060929 924060929 merged commit 76bf419 into apache:master May 17, 2024
31 of 34 checks passed
@924060929 924060929 deleted the embed_async_profiler branch May 17, 2024 10:52
dataroaring pushed a commit that referenced this pull request May 26, 2024
…ph for frontend (#35010)

background: some users want to find the bottleneck of the frontend, but they can not provide their query sql and schema because of privacy, so I embed async profiler to help they generate flame graph for frontend in their environment.

There has a script file `${FE_DEPLOY_PATH}/bin/profile_fe.sh` do the profile:
start profiler example
```shell
$ bin/profile_fe.sh
$ PROFILE_SECONDS=1 bin/profile_fe.sh
```

This is the real example:
```shell
$ PROFILE_SECONDS=1 bin/profile_fe.sh
DORIS_HOME: /Users/lanhuajian/github/doris/output/fe
JAVA: /Users/lanhuajian/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home/bin/java
DorisFE pid: 29494
Begin profiling 1 seconds and generate flame graph to /Users/lanhuajian/github/doris/output/fe/log/profile_20240517154934.html...

Profiling for 1 seconds
Done
Generated flame graph to /Users/lanhuajian/github/doris/output/fe/log/profile_20240517154934.html
```

You can use web browser to open the generated html file to troubleshooting performance issues.

The flame graph html file would look like this:
<img width="1432" alt="image" src="https://github.com/apache/doris/assets/8806055/032a021e-6cbe-4e82-acf5-34a22dac3546">


**Note**: this profiler use the `async-profiler` tool, so it only support in Linux and MacOS
924060929 added a commit to 924060929/incubator-doris that referenced this pull request Jun 7, 2024
…ph for frontend (apache#35010)

background: some users want to find the bottleneck of the frontend, but they can not provide their query sql and schema because of privacy, so I embed async profiler to help they generate flame graph for frontend in their environment.

There has a script file `${FE_DEPLOY_PATH}/bin/profile_fe.sh` do the profile:
start profiler example
```shell
$ bin/profile_fe.sh
$ PROFILE_SECONDS=1 bin/profile_fe.sh
```

This is the real example:
```shell
$ PROFILE_SECONDS=1 bin/profile_fe.sh
DORIS_HOME: /Users/lanhuajian/github/doris/output/fe
JAVA: /Users/lanhuajian/Library/Java/JavaVirtualMachines/corretto-17.0.10/Contents/Home/bin/java
DorisFE pid: 29494
Begin profiling 1 seconds and generate flame graph to /Users/lanhuajian/github/doris/output/fe/log/profile_20240517154934.html...

Profiling for 1 seconds
Done
Generated flame graph to /Users/lanhuajian/github/doris/output/fe/log/profile_20240517154934.html
```

You can use web browser to open the generated html file to troubleshooting performance issues.

The flame graph html file would look like this:
<img width="1432" alt="image" src="https://github.com/apache/doris/assets/8806055/032a021e-6cbe-4e82-acf5-34a22dac3546">

**Note**: this profiler use the `async-profiler` tool, so it only support in Linux and MacOS
morningman pushed a commit that referenced this pull request Jun 7, 2024
morningman pushed a commit to apache/doris-website that referenced this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. dev/2.1.4-merged dev/3.0.0-merged reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants