Open dangershony opened 5 years ago
I think my uint256 is already more efficient as I use Span.
@NicolasDorier I'd take a look at ArrayPool
I save more by allocating on the stack with spans.
maybe the threshold of the gain is based on the amount of allocated bytes, for little objects like uint256 maybe I agree (benchmark is always the response to doubts, probably I'll do some when I'll start working on Spans)
Even implement object pooling for uint256 could be an improvement, but to be able to use them properly and be seamlessly used with Span+ArrayPoolref struct
type
Well when I'll ve some result to share I will
Actually I tried long ago to have structs for Money and uint256. Was not as good as I expected.
It actually consumed more RAM for the ConcurrentChain
for example because instead of having pointers on one object, we had duplicated objects.
but did your test were using Span at the time?
with ref struct
you can just borrow items from the ArrayPool as binary and cast them to Span<uint256>
and internal datastructure of uint256, instead of relying on 8 UInt32, could be composed just of a byte array where you use Span to have logical views like if it were 8 variables
I was not testing with Span
and not with ref struct either.
Considering this commit https://github.com/MetacoSA/NBitcoin/pull/671
We have some benchmarks and ideas to improve uint256 here https://github.com/stratisproject/StratisBitcoinFullNode/pull/3379
@nopara73 @maciejzaleski @MithrilMan