Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

The object pool is a pattern to re-use objects instead to create them all the time.

Slide 3

Slide 3 text

In .NET the object pattern is built-in via ObjectPool NuGet: Microsoft.Extensions.ObjectPool Code Flow: ▪ Create Pool ▪ Request instance from pool ▪ Use instance ▪ Reset instance ▪ Return instance to pool

Slide 4

Slide 4 text

https://github.com/BenjaminAbt/SustainableCode No Pool vs. Pool Very little code overhead with a very large effect String Builder Sample

Slide 5

Slide 5 text

Efficiency Results https://github.com/BenjaminAbt/dotnet-perf-stringbuilder-pooled The code without pool needs 1.8x more power and time and consumes more allocations in this very simple scenario! The standard string operations as a comparison require much more power and generate more allocations than the string builder.

Slide 6

Slide 6 text

Conclusion / Advise Object Pooling is a real performance booster, makes applications more efficient and creates less allocations and thus requires less memory More power means higher performance and/or lower operating costs at the same time, since smaller CPU and memory instances can be used to reach the same performance. For string processing, the StringBuilder is worthwhile in 99% of cases. Some .NET string operations are already using a StringBuilder implementation under the hood (internal type ValueStringBuilder). However, manual string builder implementations can reuse instances through Object Pooling and thus be even more powerful. https://github.com/BenjaminAbt/SustainableCode Advise

Slide 7

Slide 7 text

No content