OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.45k stars 2.41k forks source link

Use Microsoft.IO.RecyclableMemoryStream #16946

Closed adamradocz closed 2 weeks ago

adamradocz commented 3 weeks ago

Is your feature request related to a problem?

No.

Describe the solution you'd like

In the code, new MemoryStream()s could be optimized with pooling by using the Microsoft.IO.RecyclableMemoryStream nuget.

github-actions[bot] commented 3 weeks ago

Thank you for submitting your first issue, awesome! 🚀 We're thrilled to receive your input. If you haven't completed the template yet, please take a moment to do so. This ensures that we fully understand your feature request or bug report. On what happens next, see the docs.

hishamco commented 3 weeks ago

I noticed that you suggested this in Oqtane Framework too :) I just read about the RecyclableMemoryStream I never mind letting you push a PR if @sebastienros has no objection

sebastienros commented 3 weeks ago

I am very familiar with RecyclableMemoryStream and find it very well-done. I personally use it as an IBufferWriter which is supports too (not just Stream).

From the PR I see we use MemoryStream mostly with existing arrays. In that case MemoryStream is not allocating anything so using the RMS is useless, assuming we are not adding more data to the stream.

However there might be other places where we don't use MemoryStream explicitly and could benefit from this library, like template generation. Let's see...

github-actions[bot] commented 3 weeks ago

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.