Skip to content

Replace single-item pinned buffers in System.Net.WebSockets.Client with PinnableBufferCache. #14911

Closed

Description

@pgavlin
No description provided.

Activity

  1. benaadams commented on Aug 7, 2015

    @benaadams
    Member

    Can you also maintain the overloads or equivalents that exist in 4.5.2/4.6 where the internal buffers can be provided?

    e.g. AcceptWebSocketAsync(string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval, ArraySegment internalBuffer)

    With application domain knowledge of message size, message frequency, connected client count etc, I'd prefer to pre-allocate a very large buffer into LoH and out of the generations, pin the whole thing and chop it into ArraySegments for use either as send/receive buffers

  2. benaadams commented on Aug 8, 2015

    @benaadams
    Member

    Also means with careful buffer alignments can cut out a data copy with dotnet/coreclr#36

  3. davidsh commented on Aug 8, 2015

    @davidsh
    Contributor
  4. CIPop commented on Aug 10, 2015

    @CIPop
    Contributor

    /cc: @vancem

    @benaadams Thank you for your feedback! The pattern that you describe is mostly correct and is still possible without the added complexity of the APIs accepting a buffer (or buffer size). The only part that should be left out of application code is pinning the buffer: this will be performed once, within the first call using that buffer.

    At this moment, the implementation for ClientWebSocket is caching the pinned send/receive buffers. If subsequent operations will reuse the buffers, no re-pinning will be performed internally. In the case you describe, you would only have one buffer (and multiple ArraySegments) which means that pinning is done exactly once.

    dotnet/corefx#2505 is making this even better by adding internal use of PinnableBufferCache. This will allow caching pinned buffers for cases where the application is not following the recommended pattern you described.

    Regarding dotnet/coreclr#36: This is good to know although I'm not sure this would apply to ClientWebSocket. We've removed the memory copy step: instead we pass the data buffers directly to the underlying Win32/WinHttp layer.

  5. benaadams commented on Aug 10, 2015

    @benaadams
    Member

    Ah yes, sorry, so this would be for server websockets which isn't in yet - am a little premature with my feedback and commenting on wrong feature 😈

  6. CIPop commented on Aug 10, 2015

    @CIPop
    Contributor

    /cc: @Tratcher

    @benaadams Actually the comments fit well for both sides. For server side you should start following https://github.com/aspnet/. The Server-side WebSockets require close integration with the server they run on and so will most likely depend on the service's host (WebListener or IIS for the Windows implementation).

  7. SidharthNabar commented on Oct 12, 2015

    @SidharthNabar

    @benaadams - Since your request was intended for server WebSockets which is not tracked in this repo, I am closing this issue. Please open an issue in the ASP.NET 5 repo that Cristian mentioned above.

  8. davidsh commented on Feb 28, 2016

    @davidsh
    Contributor

    Re-opening this issue. It was closed incorrectly.

    Since your request was intended for server WebSockets which is not tracked in this repo, I am closing this issue. Please open an issue in the ASP.NET 5 repo that Cristian mentioned above.

    This issue is for the System.Net.WebSocket.Client code.

  9. self-assigned this
    on Feb 28, 2016
  10. removed their assignment
    on Nov 18, 2016
  11. karelz commented on Dec 5, 2016

    @karelz
    Member

    This may be a bit involved - we need to check PinnableBufferCache if it is fully implemented for our purpose here.

  12. davidsh commented on Aug 31, 2017

    @davidsh
    Contributor

    Closing this issue since PinnableBufferCache is now being replaced with Span and other higher performance choices.

  13. transferred this issue fromdotnet/corefxon Jan 31, 2020
  14. added this to the 2.1.0 milestone on Jan 31, 2020
  15. ghost locked as resolved and limited conversation to collaborators on Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Netenhancementtenet-performance

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions