Skip to content

Commit

Permalink
update catapult traceviewer to fix chrome issue related to crbug.com/…
Browse files Browse the repository at this point in the history
…1036492
  • Loading branch information
d99kris committed Sep 17, 2022
1 parent 5f17077 commit 6533eb1
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 24 deletions.
25 changes: 5 additions & 20 deletions ext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,12 @@ linked from [Catapult Tracing](https://chromium.googlesource.com/catapult/+/HEAD
In case Catapult needs to be updated (it happened when updating to Python 3.x
support) the recommended method is:

1. Build cpuusage
1. Run script to update external modules

./genman.sh
./ext/update.sh

2. Run tests
2. Perform any necessary updates to the update.sh script to make tests pass.

cd build && ctest --output-on-failure

3. Perform any necessary updates to the Catapult copy in
build/share/cpuusage/catapult to make tests pass.

4. When all tests are passing, create a new tar-ball and make sure to exclude
test_data, e.g. `rm -rf share/cpuusage/catapult/tracing/test_data`
The tar-ball can be created like this:

tar -czvf ~/c1.tar.gz share/cpuusage/catapult

Then replace the original file:

cp ~/c1.tar.gz ../ext/catapult.tar.gz

5. Finally delete the previous build directory and try build and run tests
again.
3. Once all tests are passing, ext/catapult.tar.gz will be updated
automatically.

Binary file modified ext/catapult.tar.gz
Binary file not shown.
85 changes: 85 additions & 0 deletions ext/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env bash

# Copyright (C) 2022 Kristofer Berggren
# All rights reserved.
#
# cpuusage is distributed under the BSD 3-Clause license, see LICENSE for
# details.

TMPCATAPULT="/tmp/cpuusage-catapult"

prereq()
{
if [[ ! -d "${TMPCATAPULT}" ]]; then
git clone https://chromium.googlesource.com/catapult ${TMPCATAPULT} || exit 1
else
echo "using existing clone in ${TMPCATAPULT}"
fi

if [[ ! -d "build" ]]; then
./make.sh build || exit 1
else
echo "using existing build in ./build"
fi
}

update_catapult()
{
pushd ./build/share/cpuusage/catapult/ > /dev/null && \
rm -rf ./* && \
cp ${TMPCATAPULT}/LICENSE LICENSE && \
cp -a ${TMPCATAPULT}/tracing tracing && \
rm -rf tracing/test_data && \
mkdir common && \
cp -a ${TMPCATAPULT}/common/py_vulcanize common/ && \
mkdir third_party && \
cp -a ${TMPCATAPULT}/third_party/beautifulsoup4-4.9.3 third_party/ && \
cp -a ${TMPCATAPULT}/third_party/polymer third_party/ && \
popd > /dev/null && \
echo "updated catapult module" || exit 1
}

package_catapult()
{
pushd ./build > /dev/null && \
rm -f catapult.tar.gz && \
tar -czvf catapult.tar.gz share/cpuusage/catapult && \
popd > /dev/null && \
cp ./build/catapult.tar.gz ./ext/catapult.tar.gz && \
rm -f ./build/catapult.tar.gz && \
echo "packaged catapult module" || exit 1
}

test_catapult()
{
SCRIPT="./build/share/cpuusage/catapult/tracing/bin/trace2html"
TESTJSON="./tests/ex.json"
TMPHTML="./build/sanity_test.html"
python3 ${SCRIPT} ${TESTJSON} --output=${TMPHTML} > /dev/null && \
rm "${TMPHTML}" && \
echo "sanity test passed" || exit 1
}

test_all()
{
./make.sh tests && \
echo "all tests passed" || exit 1
}

cleanup()
{
rm -rf build && \
rm -rf "${TMPCATAPULT}" && \
echo "cleanup complete" || exit 1
}

prereq
update_catapult
test_catapult
test_all
update_catapult
package_catapult
#cleanup

echo "success"
exit 0
6 changes: 3 additions & 3 deletions src/cpuusage
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash

# Copyright (C) 2017-2021 Kristofer Berggren
# Copyright (C) 2017-2022 Kristofer Berggren
# All rights reserved.
#
# cpuusage is distributed under the BSD 3-Clause license, see LICENSE for
Expand Down Expand Up @@ -78,7 +78,7 @@ showusage()
# Version
showversion()
{
echo "cpuusage v1.47"
echo "cpuusage v1.48"
echo ""
echo "Copyright (C) 2017-2022 Kristofer Berggren"
echo ""
Expand Down
2 changes: 1 addition & 1 deletion src/cpuusage.1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
.TH CPUUSAGE "1" "January 2022" "cpuusage v1.47" "User Commands"
.TH CPUUSAGE "1" "September 2022" "cpuusage v1.48" "User Commands"
.SH NAME
cpuusage \- instrumentation CPU profiler
.SH SYNOPSIS
Expand Down
11 changes: 11 additions & 0 deletions tests/ex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"otherData": {
"timestamp":"2022-09-06 19:41:31 +0800",
"os":"Darwin 21.6.0",
"cores":"4"
},
"traceEvents": [
{ "ph":"B", "cat":"perf", "pid":"13441", "tid":"0x105cf3600", "name":"wrap_pthread_mutex_lock + 0", "ts":1662464491302117 },
{ "ph":"E", "cat":"perf", "pid":"13441", "tid":"0x105cf3600", "name":"wrap_pthread_mutex_lock + 0", "ts":1662464491302122 }
]
}

0 comments on commit 6533eb1

Please sign in to comment.