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
There are several places with new byte[] and new double[] that need pooling.
Also, the code like below needs modern-era rewrite with Unsafe.Read, Unsafe.CopyBlk or even SIMD (see corefxlab/Kestrel) if the IL opcode doesn't vectorize internally.
var data = new byte[sizeof(double)];
for (int byteIndex = 0; byteIndex < data.Length; byteIndex++)
{
data[byteIndex] = Marshal.ReadByte(pointer, offset + byteIndex);
}
return BitConverter.ToDouble(data, 0);
There are probably other low-hanging fruits such as mentioned above.
Consider using Span and/or OwnedMemory backed by R's unmanaged memory.
Try to avoid changing Marshal methods to Unsafe just for the sake of it. Only obvious cases such as reading a single double via a loop over its bytes. Later could review all Marshal usages.
Review ArrayConvertAllTwoDim method in ArrayConverter. I believe there is a simpler way to convert 1D <-> 2D array using System.Array.
P.S. For Spreads, any R usage is considered slow, i.e. not an online algo, but batch processing or complex math. So better be safe and do not break things, rather profile remaining non-obvious cases and fix them ad-hoc.
The text was updated successfully, but these errors were encountered:
There are several places with
new byte[]
andnew double[]
that need pooling.Also, the code like below needs modern-era rewrite with
Unsafe.Read
,Unsafe.CopyBlk
or even SIMD (see corefxlab/Kestrel) if the IL opcode doesn't vectorize internally.There are probably other low-hanging fruits such as mentioned above.
Consider using Span and/or OwnedMemory backed by R's unmanaged memory.
Try to avoid changing
Marshal
methods toUnsafe
just for the sake of it. Only obvious cases such as reading a singledouble
via a loop over its bytes. Later could review allMarshal
usages.Review
ArrayConvertAllTwoDim
method in ArrayConverter. I believe there is a simpler way to convert 1D <-> 2D array using System.Array.P.S. For Spreads, any R usage is considered slow, i.e. not an online algo, but batch processing or complex math. So better be safe and do not break things, rather profile remaining non-obvious cases and fix them ad-hoc.
The text was updated successfully, but these errors were encountered: