Skip to content

Fixed concurrent reset and keepalive perform - #3767

Merged
vonzshik merged 4 commits into
npgsql:mainfrom
vonzshik:3765-connector-reset-keepalive-fix
May 25, 2021
Merged

vonzshik merged 4 commits into
npgsql:mainfrom
vonzshik:3765-connector-reset-keepalive-fix

Conversation

@vonzshik

Copy link
Copy Markdown
Contributor

Fixes #3765

@vonzshik
vonzshik requested a review from roji as a code owner May 21, 2021 15:05

@roji roji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me.

This isn't supposed to affect our multiplexing fast path (should be unbound Close always), but I ran anyway and got these results:

commit scenario Run 1 Run 2
65d0a3c Before change 487,782 487,451
829c114 After change 477,584 481,072

So possibly a 1.3% regression... I can (and probably should) do more runs to confirm this.

Detailed run results
dotnet run -- --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/platform.benchmarks.yml --scenario fortunes --profile aspnet-citrine-lin --application.framework net6.0 --application.options.outputFiles Z:\projects\npgsql\src\Npgsql\bin\Release\net6.0\Npgsql.dll --variable warmup=45 --variable duration=180

Before (65d0a3c)

| db                  |         |
| ------------------- | ------- |
| CPU Usage (%)       | 38      |
| Cores usage (%)     | 1,074   |
| Working Set (MB)    | 46      |
| Build Time (ms)     | 1,734   |
| Start Time (ms)     | 353     |
| Published Size (KB) | 914,035 |


| application           |                                 |
| --------------------- | ------------------------------- |
| CPU Usage (%)         | 97                              |
| Cores usage (%)       | 2,703                           |
| Working Set (MB)      | 455                             |
| Private Memory (MB)   | 1,585                           |
| Build Time (ms)       | 10,293                          |
| Start Time (ms)       | 1,354                           |
| Published Size (KB)   | 90,270                          |
| .NET Core SDK Version | 6.0.100-preview.6.21271.10      |
| ASP.NET Core Version  | 6.0.0-preview.6.21271.5+ded367a |
| .NET Runtime Version  | 6.0.0-preview.6.21271.6+c1ed0db |


| load                   |            |
| ---------------------- | ---------- |
| CPU Usage (%)          | 32         |
| Cores usage (%)        | 894        |
| Working Set (MB)       | 37         |
| Private Memory (MB)    | 363        |
| Start Time (ms)        | 0          |
| First Request (ms)     | 72         |
| Requests/sec           | 487,782    |
| Requests               | 87,849,387 |
| Mean latency (ms)      | 1.11       |
| Max latency (ms)       | 31.68      |
| Bad responses          | 0          |
| Socket errors          | 0          |
| Read throughput (MB/s) | 633.12     |
| Latency 50th (ms)      | 0.99       |
| Latency 75th (ms)      | 1.19       |
| Latency 90th (ms)      | 1.49       |
| Latency 99th (ms)      | 4.18       |

After (829c114)

| db                  |         |
| ------------------- | ------- |
| CPU Usage (%)       | 39      |
| Cores usage (%)     | 1,084   |
| Working Set (MB)    | 46      |
| Build Time (ms)     | 1,728   |
| Start Time (ms)     | 348     |
| Published Size (KB) | 914,035 |


| application           |                                 |
| --------------------- | ------------------------------- |
| CPU Usage (%)         | 96                              |
| Cores usage (%)       | 2,680                           |
| Working Set (MB)      | 463                             |
| Private Memory (MB)   | 1,593                           |
| Build Time (ms)       | 2,814                           |
| Start Time (ms)       | 1,606                           |
| Published Size (KB)   | 90,270                          |
| .NET Core SDK Version | 6.0.100-preview.6.21271.10      |
| ASP.NET Core Version  | 6.0.0-preview.6.21271.5+ded367a |
| .NET Runtime Version  | 6.0.0-preview.6.21271.6+c1ed0db |


| load                   |            |
| ---------------------- | ---------- |
| CPU Usage (%)          | 31         |
| Cores usage (%)        | 865        |
| Working Set (MB)       | 37         |
| Private Memory (MB)    | 363        |
| Start Time (ms)        | 0          |
| First Request (ms)     | 71         |
| Requests/sec           | 477,584    |
| Requests               | 86,012,899 |
| Mean latency (ms)      | 1.12       |
| Max latency (ms)       | 24.03      |
| Bad responses          | 0          |
| Socket errors          | 0          |
| Read throughput (MB/s) | 619.88     |
| Latency 50th (ms)      | 1.02       |
| Latency 75th (ms)      | 1.22       |
| Latency 90th (ms)      | 1.51       |
| Latency 99th (ms)      | 3.84       |

Comment thread src/Npgsql/Internal/NpgsqlConnector.cs Resolved
Comment thread src/Npgsql/Internal/NpgsqlConnector.cs Resolved
Comment thread src/Npgsql/Internal/NpgsqlConnector.cs Resolved
@vonzshik
vonzshik requested a review from roji May 23, 2021 17:18

@roji roji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did another run with longer measurement times, difference is negligible (and in any case we're not supposed to be going through this path at all).

commit scenario Run 1
65d0a3c Before change 481,631
0aa9627 After change 478,258
Detailed run results

65d0a3c

dotnet run -- --config https://raw.githubusercontent.com/aspnet/Benchmarks/main/scenarios/platform.benchmarks.yml --scenario fortunes --profile aspnet-citrine-lin --application.framework net6.0 --application.options.outputFiles Z:\projects\npgsql\src\Npgsql\bin\Release\net6.0\Npgsql.dll --variable warmup=45 --variable duration=240

| db                  |         |
| ------------------- | ------- |
| CPU Usage (%)       | 38      |
| Cores usage (%)     | 1,052   |
| Working Set (MB)    | 46      |
| Build Time (ms)     | 1,672   |
| Start Time (ms)     | 348     |
| Published Size (KB) | 914,035 |


| application           |                                 |
| --------------------- | ------------------------------- |
| CPU Usage (%)         | 96                              |
| Cores usage (%)       | 2,675                           |
| Working Set (MB)      | 456                             |
| Private Memory (MB)   | 1,586                           |
| Build Time (ms)       | 2,661                           |
| Start Time (ms)       | 1,607                           |
| Published Size (KB)   | 90,293                          |
| .NET Core SDK Version | 6.0.100-preview.6.21274.3       |
| ASP.NET Core Version  | 6.0.0-preview.6.21273.1+5c3fa67 |
| .NET Runtime Version  | 6.0.0-preview.6.21274.2+ebba451 |


| load                   |             |
| ---------------------- | ----------- |
| CPU Usage (%)          | 31          |
| Cores usage (%)        | 878         |
| Working Set (MB)       | 37          |
| Private Memory (MB)    | 363         |
| Start Time (ms)        | 0           |
| First Request (ms)     | 71          |
| Requests/sec           | 481,631     |
| Requests               | 115,639,416 |
| Mean latency (ms)      | 1.12        |
| Max latency (ms)       | 24.02       |
| Bad responses          | 0           |
| Socket errors          | 0           |
| Read throughput (MB/s) | 625.13      |
| Latency 50th (ms)      | 1.00        |
| Latency 75th (ms)      | 1.20        |
| Latency 90th (ms)      | 1.50        |
| Latency 99th (ms)      | 4.05        |

0aa9627

| db                  |         |
| ------------------- | ------- |
| CPU Usage (%)       | 38      |
| Cores usage (%)     | 1,051   |
| Working Set (MB)    | 47      |
| Build Time (ms)     | 1,725   |
| Start Time (ms)     | 330     |
| Published Size (KB) | 914,035 |


| application           |                                 |
| --------------------- | ------------------------------- |
| CPU Usage (%)         | 96                              |
| Cores usage (%)       | 2,686                           |
| Working Set (MB)      | 466                             |
| Private Memory (MB)   | 1,587                           |
| Build Time (ms)       | 2,617                           |
| Start Time (ms)       | 1,601                           |
| Published Size (KB)   | 90,293                          |
| .NET Core SDK Version | 6.0.100-preview.6.21274.3       |
| ASP.NET Core Version  | 6.0.0-preview.6.21273.1+5c3fa67 |
| .NET Runtime Version  | 6.0.0-preview.6.21274.2+ebba451 |


| load                   |             |
| ---------------------- | ----------- |
| CPU Usage (%)          | 31          |
| Cores usage (%)        | 873         |
| Working Set (MB)       | 37          |
| Private Memory (MB)    | 363         |
| Start Time (ms)        | 0           |
| First Request (ms)     | 73          |
| Requests/sec           | 478,258     |
| Requests               | 114,829,874 |
| Mean latency (ms)      | 1.12        |
| Max latency (ms)       | 26.28       |
| Bad responses          | 0           |
| Socket errors          | 0           |
| Read throughput (MB/s) | 620.76      |
| Latency 50th (ms)      | 1.01        |
| Latency 75th (ms)      | 1.21        |
| Latency 90th (ms)      | 1.50        |
| Latency 99th (ms)      | 3.96        |

@vonzshik
vonzshik merged commit 2e10c15 into npgsql:main May 25, 2021
@vonzshik
vonzshik deleted the 3765-connector-reset-keepalive-fix branch May 25, 2021 08:55
vonzshik added a commit that referenced this pull request May 25, 2021
@vonzshik

Copy link
Copy Markdown
Contributor Author

Backported to 5.0.6 via 17f172c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NpgsqlConnector.Reset can run concurrently to a keepalive

3 participants