-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:lana-k/sqliteviz
- Loading branch information
Showing
15 changed files
with
423 additions
and
285 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# An easy way to run tests locally without Nodejs installed: | ||
# | ||
# docker build -t sqliteviz/test -f Dockerfile.test . | ||
# | ||
|
||
FROM node:12 | ||
|
||
RUN set -ex; \ | ||
apt update; \ | ||
apt install -y chromium firefox-esr; \ | ||
npm install -g npm@7 | ||
|
||
WORKDIR /tmp/build | ||
|
||
COPY package.json package-lock.json ./ | ||
COPY lib lib | ||
RUN npm install | ||
|
||
COPY . . | ||
|
||
RUN set -ex; \ | ||
sed -i 's/browsers: \[.*\],/browsers: ['"'FirefoxHeadlessTouch'"'],/' karma.conf.js | ||
|
||
RUN npm run lint -- --no-fix && npm run test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM emscripten/emsdk:2.0.24 | ||
FROM emscripten/emsdk:3.0.1 | ||
|
||
WORKDIR /tmp/build | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
# SQLite WebAssembly build micro-benchmark | ||
|
||
This directory contains a micro-benchmark for evaluating SQLite | ||
WebAssembly builds performance on typical SQL queries, run from | ||
`make.sh` script. It can also serve as a smoke test. | ||
|
||
The benchmark operates on a set of SQLite WebAssembly builds expected | ||
in `lib/build-$NAME` directories each containing `sql-wasm.js` and | ||
`sql-wasm.wasm`. Then it creates a Docker image for each, and runs | ||
the benchmark in Firefox and Chromium using Karma in the container. | ||
|
||
After successful run, the benchmark result of each build is contained | ||
in `build-$NAME-result.json`. The JSON result files can be analysed | ||
using `result-analysis.ipynb` Jupyter notebook. | ||
This directory contains a micro-benchmark for evaluating SQLite WebAssembly | ||
builds performance on read and write SQL queries, run from `make.sh` script. If | ||
the script has permission to `nice` processes and [Procpath][1] is installed, | ||
e.g. it is run with `sudo -E env PATH=$PATH ./make.sh`, it'll `renice` all | ||
processes running inside the benchmark containers. It can also serve as a smoke | ||
test (e.g. for memory leaks). | ||
|
||
The benchmark operates on a set of SQLite WebAssembly builds expected in | ||
`lib/build-$NAME` directories each containing `sql-wasm.js` and | ||
`sql-wasm.wasm`. Then it creates a Docker image for each, and runs the | ||
benchmark in Firefox and Chromium using Karma in the container. | ||
|
||
After successful run, the benchmark produces the following per each build: | ||
|
||
- `build-$NAME-result.json` | ||
- `build-$NAME.sqlite` (if Procpath is installed) | ||
- `build-$NAME.svg` (if Procpath is installed) | ||
|
||
These files can be analysed using `result-analysis.ipynb` Jupyter notebook. | ||
The SVG is a chart with CPU and RSS usage of each test container (i.e. Chromium | ||
run, then Firefox run per container). | ||
|
||
[1]: https://pypi.org/project/Procpath/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This command may run when "sqljs-benchmark-run" does not yet exist or run | ||
[renice:watch] | ||
interval: 2 | ||
repeat: 30 | ||
environment: | ||
ROOT_PID=docker inspect -f "{{.State.Pid}}" sqljs-benchmark-run 2> /dev/null || true | ||
query: | ||
PIDS=$..children[?(@.stat.pid in [$ROOT_PID])]..pid | ||
command: | ||
echo $PIDS | tr , '\n' | xargs --no-run-if-empty -I{} -- renice -n -5 -p {} | ||
|
||
# Expected input arguments: database_file | ||
[track:record] | ||
interval: 1 | ||
stop_without_result: 1 | ||
environment: | ||
ROOT_PID=docker inspect -f "{{.State.Pid}}" sqljs-benchmark-run | ||
query: | ||
$..children[?(@.stat.pid == $ROOT_PID)] | ||
pid_list: $ROOT_PID | ||
|
||
# Expected input arguments: database_file, plot_file | ||
[track:plot] | ||
moving_average_window: 5 | ||
title: Chromium vs Firefox (№1 RSS, №2 CPU) | ||
custom_query_file: | ||
procpath/top2_rss.sql | ||
procpath/top2_cpu.sql |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
WITH diff_all AS ( | ||
SELECT | ||
record_id, | ||
ts, | ||
stat_pid, | ||
stat_utime + stat_stime - LAG(stat_utime + stat_stime) OVER ( | ||
PARTITION BY stat_pid | ||
ORDER BY record_id | ||
) tick_diff, | ||
ts - LAG(ts) OVER ( | ||
PARTITION BY stat_pid | ||
ORDER BY record_id | ||
) ts_diff | ||
FROM record | ||
), diff AS ( | ||
SELECT * FROM diff_all WHERE tick_diff IS NOT NULL | ||
), one_time_pid_condition AS ( | ||
SELECT stat_pid | ||
FROM record | ||
GROUP BY 1 | ||
ORDER BY SUM(stat_utime + stat_stime) DESC | ||
LIMIT 2 | ||
) | ||
SELECT | ||
ts, | ||
stat_pid pid, | ||
100.0 * tick_diff / (SELECT value FROM meta WHERE key = 'clock_ticks') / ts_diff value | ||
FROM diff | ||
JOIN one_time_pid_condition USING(stat_pid) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
WITH one_time_pid_condition AS ( | ||
SELECT stat_pid | ||
FROM record | ||
GROUP BY 1 | ||
ORDER BY SUM(stat_rss) DESC | ||
LIMIT 2 | ||
) | ||
SELECT | ||
ts, | ||
stat_pid pid, | ||
stat_rss / 1024.0 / 1024 * (SELECT value FROM meta WHERE key = 'page_size') value | ||
FROM record | ||
JOIN one_time_pid_condition USING(stat_pid) |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.