You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation uses a lot of byte[] instances internally, some of which are multiple kilobytes in size. There are some modern patterns that can help reduce the impact of this on garbage collection. Most of these, to one degree or another, can be used with .NET Standard 2.0 given a dependency on the System.Memory package.
Using buffers from the ArrayPool
Use of Memory<T> and Span<T> to represent slices of arrays rather than copying to new arrays
Reusing MemoryStream instances
I'm interested in improving some of these things myself. However, fully improving this will require some breaking changes to the API surface:
Accepting images as ReadOnlyMemory<byte> so the consumer may pass in an array slice
Some method of returning ReadOnlyMemory<byte> from generate to prevent an extra array copy from the MemoryStream
Rework SemanticTagBaseValue to avoid boxing value types to the heap, probably using type-specific variants
While were at it, there are possibly some other tweaks which could be done in the same breaking release. Perhaps using DateTimeOffset in DateField rather than DateTime, that sort of thing.
I'm curious if changes like this would be considered acceptable for a 4.x release. I don't want to put in the time if it isn't desired. I feel like this has a lot of value for high-traffic servers receiving lots of requests to generate passes, especially given potential calls to refresh pass data.
The text was updated successfully, but these errors were encountered:
The current implementation uses a lot of
byte[]
instances internally, some of which are multiple kilobytes in size. There are some modern patterns that can help reduce the impact of this on garbage collection. Most of these, to one degree or another, can be used with .NET Standard 2.0 given a dependency on theSystem.Memory
package.ArrayPool
Memory<T>
andSpan<T>
to represent slices of arrays rather than copying to new arraysI'm interested in improving some of these things myself. However, fully improving this will require some breaking changes to the API surface:
ReadOnlyMemory<byte>
so the consumer may pass in an array sliceReadOnlyMemory<byte>
from generate to prevent an extra array copy from theMemoryStream
SemanticTagBaseValue
to avoid boxing value types to the heap, probably using type-specific variantsWhile were at it, there are possibly some other tweaks which could be done in the same breaking release. Perhaps using
DateTimeOffset
inDateField
rather thanDateTime
, that sort of thing.I'm curious if changes like this would be considered acceptable for a 4.x release. I don't want to put in the time if it isn't desired. I feel like this has a lot of value for high-traffic servers receiving lots of requests to generate passes, especially given potential calls to refresh pass data.
The text was updated successfully, but these errors were encountered: