Skip to content

SqlClient high memory consumption when there is disk IO saturation #65

@DavidObando

Description

@DavidObando

Repro environment

  • Windows 10
  • LocalDb
  • npm
  • loadtest: npm install -g loadtest
  • dotnet 1.0.0-preview2-002823

Scenario description

Stress test for ASP.NET and Entity Framework. The code is here. There's a server side and a client side to the test.
For the server side, execute the app with dotnet run -c Release.
For the client side, execute .\loadtest.ps1 -iterations 50000 -rps 500
The -rps 500 part is important, as the issue only manifests itself when disk IO is saturated.

Observed results

Once the test starts running we're reaching disk IO saturation almost immediately. The memory increases dramatically, up to 1 GB in private bytes when loadtest is run with the parameters stated above. After the test is up, we force GC collection once and take some measurements of the managed heap:

  • Gen 0: 49,440 bytes
  • Gen 1: 384,344 bytes
  • Gen 2: 5,178,176 bytes
  • LOH: 6,375,520 bytes

Totalling roughly 12 MB.

That said, the application is currently taking 959 MB in total committed memory. I'm assuming then that there's native memory being held.

A profile trace of the execution shows that most of the time is being spent in ReadSniSyncOverAsync.

Expected results

We expect the memory to not grow as much as it's doing now.

Notes

After forcing GC collection a number of times, we end up bringing the committed memory down to 515 MB and it stabilizes there. The managed heap shrinks from 12 MB to 10 MB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Performance 📈Issues that are targeted to performance improvements.

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions