Session
Would you like a Slice of Span<>?
Slicing services consciously has become the Zeitgeist of modern software architecture. But are you slicing equally well into your memory?
Both Span and ReadOnlySpan have become the most prevalent abstractions over contiguous memory in .NET (i.e. heap arrays, stackalloc blocks and native memory). Just like the good old ArraySegment, these two allow allocation-free sub-views into such memory regions while generalizing high-performance algorithms. But with great power comes great responsibility, so the Compiler enforces strict lifetime checks. Some of which are partially lifted with C# 13, but most remain by design for these ref structs. Understanding these restrictions is vital to enabling non-breaking adoption of this 16-bytes-sized powerhouse.
Since their inception in 2018, the C# language is more and more alleviating Span (and other ref structs), as well as the BCL of the yearly .NET releases is increasingly embracing its usage in both implementation details and the public surface area. High time to learn all about Span via these slices of knowledge:
- ref structs, ref (readonly) fields, ref (readonly) locals, ref (readonly) returns
- anatomy of Span and ReadOnlySpan
- Collection Expressions and params Collections
- slicing Syntax and Semantics
- allocation-free usage patterns and related high-performance Memory-APIs, including Memory, ReadOnlyMemory and IMemoryOwner
- usage of (ReadOnly)Span in the BCL and Libraries of the Ecosystem
- Scope Checks, scoped keyword and UnscopedRef-Attribute and the brand new allows ref struct generic anti-constraint
- dangerous operations via Unsafe and MemoryMarshal
My challenge is to make you an Aficionado of this ByRef-like type and a Connoisseur of all related Memory APIs. This code-heavy session will train your eye to detect potential utilization of Span and friends in your Libraries and Applications, to unlock measurable performance gains that make your code best friends with the Runtime and the GC.
So let's have our (slice of) cake and eat it, too!
For a shorter abstract on the website, feel free to remove the paragraph that lists the items of the agenda.
Stefan Pölz
Clean C# Coder – Test-driven .NET Developer
Vienna, Austria
Links
Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.
Jump to top