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

Work out why SQL tests are 3x slower than others #22

Closed
wokket opened this issue Sep 18, 2021 · 4 comments · Fixed by #157
Closed

Work out why SQL tests are 3x slower than others #22

wokket opened this issue Sep 18, 2021 · 4 comments · Fixed by #157
Assignees
Labels
triage Work out what the issue is

Comments

@wokket
Copy link
Collaborator

wokket commented Sep 18, 2021

No description provided.

@erikbra
Copy link
Owner

erikbra commented Sep 19, 2021

I think it is due to startup time. SQL Server is painfully slow to actually be ready to accept connections compared to the other ones. But there might be something else as well, of course

@wokket
Copy link
Collaborator Author

wokket commented Sep 21, 2021

Filling in some info here:

While SQL is slow to start, it's not drastically slower than MySql on my machine, and the startup is only once per run which doesn't explain the speed of the individual tests.

Started MariaDB Server docker container (2636ms): grate-mariadb-vxpoisstit
Listening on port: 49318
Waiting until server is ready
.
.
.
...ready (6185ms).
  Passed EnsureUserTokensAreReplaced [392 ms]
Removed MariaDB Server docker container (1730ms): grate-mariadb-vxpoisstit

Started PostgreSQL docker container (1749ms): grate-postgresql-zipiypznee
Listening on port: 49319
Waiting until server is ready
.
...ready (2355ms).
  Passed EnsureUserTokensAreReplaced [376 ms]
Removed PostgreSQL docker container (1434ms): grate-postgresql-zipiypznee

Started SQL server docker container (1792ms): grate-sqlserver-bbdmgconou
Listening on port: 49320
Waiting until server is ready
.
.
.
...ready (8547ms).
  Passed EnsureUserTokensAreReplaced [6 s]
Removed SQL server docker container (6092ms): grate-sqlserver-bbdmgconou

I re-pointed my sql unit tests at a local SQL instance (not docker) and it's still much slower than the other DB's so def something weird going on.

I'll keep digging...

@wokket
Copy link
Collaborator Author

wokket commented Sep 21, 2021

It's the Dbase create:

Started MariaDB Server docker container (1706ms): grate-mariadb-lefikztrth
Listening on port: 49343
Waiting until server is ready
.
.
.
.
...ready (8191ms).
Conns init: 0ms
DB Create: 55ms
Grate structures init: 97ms
Got DB Versions: 42ms

  Passed EnsureUserTokensAreReplaced [378 ms]
Removed MariaDB Server docker container (1863ms): grate-mariadb-lefikztrth
Started PostgreSQL docker container (2266ms): grate-postgresql-rcadsovvyp
Listening on port: 49344
Waiting until server is ready
.
...ready (2355ms).
Conns init: 0ms
DB Create: 306ms
Grate structures init: 61ms
Got DB Versions: 12ms

  Passed EnsureUserTokensAreReplaced [412 ms]
Removed PostgreSQL docker container (1435ms): grate-postgresql-rcadsovvyp
Started SQL server docker container (1672ms): grate-sqlserver-khnmhqxten
Listening on port: 49345
Waiting until server is ready
.
.
.
...ready (6223ms).
Conns init: 0ms
DB Create: 5578ms
Grate structures init: 101ms
Got DB Versions: 28ms

@erikbra erikbra added the triage Work out what the issue is label Sep 23, 2021
@erikbra erikbra self-assigned this Dec 17, 2021
erikbra added a commit that referenced this issue Dec 17, 2021
* Turned OFF connection pooling on SQL Server connection string for tests
  - Found several discussions on this, e.g. dotnet/SqlClient#601
  - Tried turning off pooling, and it solved the problem...
* Upgraded SQL server docker image used in test from 2017-latest to
  latest (2019 at the time) - didn't make any difference, just to stay
  current.
erikbra added a commit that referenced this issue Dec 17, 2021
* Turned OFF connection pooling on SQL Server connection string for tests
  - Found several discussions on this, e.g. dotnet/SqlClient#601
  - Tried turning off pooling, and it solved the problem...
* Upgraded SQL server docker image used in test from 2017-latest to
  latest (2019 at the time) - didn't make any difference, just to stay
  current.
@erikbra erikbra linked a pull request Dec 17, 2021 that will close this issue
@erikbra
Copy link
Owner

erikbra commented Dec 17, 2021

The whole issue was apparently connection pooling. I don't know exactly, but we use a lot of different connection string (multiple databases), so we get one connection pool per connection, and (not very surprisingly), there seems to be quite a lot of overhead creating a connection pool, at least when we only use each pool a small amount of time, and then move on.

erikbra added a commit that referenced this issue Dec 17, 2021
* Turned OFF connection pooling on SQL Server connection string for tests
  - Found several discussions on this, e.g. dotnet/SqlClient#601
  - Tried turning off pooling, and it solved the problem...
* Upgraded SQL server docker image used in test from 2017-latest to
  latest (2019 at the time) - didn't make any difference, just to stay
  current.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Work out what the issue is
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants