Skip to content

Commit 31fd220

Browse files
committed
Add diesel to the rustc perf test suite
As far as I know diesel is a rather strange workload for rustc. According to some short measurements most of the time compiling diesel is spend type checking the crate and resolving trait bounds. I see multiple reasons for this: * Diesel builts a complex abstract query dsl for SQL based on rust generics. All fo this needs to be type checked. * Diesel generates a ton of trait impls for tuples of various sizes. There are features to set the supported max size to 16, 32, 64 and 128 tuple elements. As this is a benchmark, I've chosen to set it to 128 to maximize the number of impls. As consequence of this diesels compile times are quite sensitive to changes touching the type system in general and the trait resolution in detail. Any change that will introduce a behaviour which does not scale well with the number of available trait impls will likely result in a huge increase for this benchmark.
1 parent e28471d commit 31fd220

File tree

353 files changed

+50935
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

353 files changed

+50935
-0
lines changed

collector/benchmarks/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ These are real programs that are important in some way, and worth tracking.
4141
These are real programs that are known to stress the compiler in interesting
4242
ways.
4343

44+
- **diesel**: A type save SQL query builder. Utilizes the type system to
45+
ensure a lot of invariants. Stresses anything related to resolving
46+
trait bounds, by having a lot of trait impls for a large number of different
47+
types.
4448
- **encoding**: Character encoding support. Contains some large tables.
4549
- **html5ever**: An HTML parser. Stresses macro parsing code significantly.
4650
- **inflate**: An old implementation of the DEFLATE algorithm. Stresses the
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
indent_style = space
14+
indent_size = 4
15+
16+
[*.rs]
17+
indent_style = space
18+
indent_size = 4
19+
20+
[*.toml]
21+
indent_style = space
22+
indent_size = 4
23+
24+
[*.md]
25+
trim_trailing_whitespace = false
26+
27+
[*.{yml,yaml}]
28+
indent_style = space
29+
indent_size = 2
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The database to use when testing against Postgres.
2+
PG_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/diesel_test
3+
# The database to use when running the Postgres examples during testing.
4+
PG_EXAMPLE_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/diesel_example
5+
6+
# The database to use when testing against MySQL.
7+
MYSQL_DATABASE_URL=mysql://[email protected]:3306/diesel_test
8+
# The database to use when running the MySQL examples during testing.
9+
MYSQL_EXAMPLE_DATABASE_URL=mysql://[email protected]:3306/diesel_example
10+
# A database different from the others above used for certain unit tests.
11+
# TODO: this is magical, explain what it's there for.
12+
MYSQL_UNIT_TEST_DATABASE_URL=mysql://[email protected]:3306/diesel_unit_test
13+
14+
# The database to use when testing against SQLite.
15+
SQLITE_DATABASE_URL=/tmp/diesel_test.sqlite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [sgrif, weiznich]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!--
2+
If you want to report a bug, we added some points below you can fill out. If you want to request a feature, feel free to remove all the irrelevant text. In addition to this [issue tracker](https://github.com/diesel-rs/diesel/issues), you can also talk to Diesel maintainers and users on [Gitter](https://gitter.im/diesel-rs/diesel).
3+
-->
4+
5+
## Setup
6+
7+
### Versions
8+
9+
- **Rust:**
10+
- **Diesel:**
11+
- **Database:**
12+
- **Operating System**
13+
14+
### Feature Flags
15+
16+
- **diesel:**
17+
18+
## Problem Description
19+
20+
21+
### What are you trying to accomplish?
22+
23+
24+
### What is the expected output?
25+
26+
27+
### What is the actual output?
28+
29+
30+
### Are you seeing any additional errors?
31+
32+
33+
### Steps to reproduce
34+
35+
<!--
36+
Please include as much of your codebase as needed to reproduce the error. If the relevant files are large, please consider linking to a public repository or a [Gist](https://gist.github.com/).
37+
38+
Please post as much of your database schema as necessary. If you are using `infer_schema!`, you can use `diesel print-schema` and post the relevant parts from that.
39+
-->
40+
41+
## Checklist
42+
43+
- [ ] I have already looked over the [issue tracker](https://github.com/diesel-rs/diesel/issues) for similar issues.
44+
- [ ] This issue can be reproduced on Rust's stable channel. (Your issue will be
45+
closed if this is not the case)
46+
47+
<!--
48+
Thank you for your submission! You're helping make Diesel more robust 🎉
49+
50+
We'll try to respond as quickly as possible.
51+
-->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Security audit
2+
on:
3+
push:
4+
paths:
5+
- '**/Cargo.toml'
6+
- '**/Cargo.lock'
7+
schedule:
8+
- cron: '0 0 */7 * *'
9+
jobs:
10+
security_audit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions-rs/audit-check@v1
15+
with:
16+
token: ${{ secrets.GITHUB_TOKEN }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
on:
2+
pull_request:
3+
types:
4+
- labeled
5+
6+
name: Benchmarks
7+
8+
jobs:
9+
benchmarks:
10+
if: github.event.label.name == 'run-benchmarks'
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
backend: ["postgres", "sqlite", "mysql"]
15+
steps:
16+
- name: Checkout sources
17+
if: steps.bench.outputs.triggered == 'true'
18+
uses: actions/checkout@v2
19+
20+
- name: Install postgres (Linux)
21+
if: matrix.backend == 'postgres'
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y libpq-dev postgresql
25+
echo "host all all 127.0.0.1/32 md5" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf
26+
sudo service postgresql restart && sleep 3
27+
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
28+
sudo service postgresql restart && sleep 3
29+
echo '::set-env name=PG_DATABASE_URL::postgres://postgres:postgres@localhost/'
30+
31+
- name: Install sqlite (Linux)
32+
if: matrix.backend == 'sqlite'
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y libsqlite3-dev
36+
echo '::set-env name=SQLITE_DATABASE_URL::/tmp/test.db'
37+
38+
39+
- name: Install mysql (Linux)
40+
if: matrix.backend == 'mysql'
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get -y install mysql-server libmysqlclient-dev
44+
sudo /etc/init.d/mysql start
45+
mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot -proot
46+
echo '::set-env name=MYSQL_DATABASE_URL::mysql://root:root@localhost/diesel_test'
47+
48+
- name: Run benches
49+
uses: jasonwilliams/criterion-compare-action@move_to_actions
50+
with:
51+
cwd: "diesel_bench"
52+
token: ${{ secrets.GITHUB_TOKEN }}
53+

0 commit comments

Comments
 (0)