Writing High-Performance C# and .NET Code - .Net Oxford - July 2019

2024 ж. 22 Мам.
47 768 Рет қаралды

There are amazing things happening with C# and .NET Core in regards to performance. We have new types such as Span and Memory for working with and parsing in-memory data. We have pipelines for high-performance IO and we have ArrayPool, MemoryPool and OjectPool to help reduce GC allocations. Many more great things are on the horizon in .NET Core 3.0 such as Utf8String and new built-in JSON APIs which add to the performance arsenal. Internally, these have been used by Microsoft teams to optimise .NET Core and ASP.NET Core. Now it's time to apply them to your code!
These features can seem complex, unapproachable and difficult to apply. In this session, Steve will share his journey of learning about and applying these tools when building high-throughput .NET Core worker services. You'll learn about the motivations that led Steve to begin exploring these cool new features and you'll see how they can be applied to production code. This talk is for developers, who like Steve, are ready to begin their journey towards writing faster .NET code, which allocates less.
Speaker: Steve Gordon
Steve Gordon is a Microsoft MVP, Pluralsight author, senior developer and community lead based in Brighton. He works for Madgex developing and supporting their data products built using .NET Core technologies. Steve is passionate about community and all things .NET related, having worked with ASP.NET for over 15 years.
Steve is currently developing cloud native services, using .NET Core, ASP.NET Core and Docker. He enjoys sharing his knowledge through his blog, in videos and by presenting at user groups and conferences. Steve is excited to be a part of the .NET community and founded .NET South East, a .NET Meetup group based in Brighton. He enjoys contributing to and maintaining OSS projects, most actively helping save lives with open source software and the Humanitarian Toolbox (www.htbox.org). You can find Steve online at his blog www.stevejgordon.co.uk and on Twitter as @stevejgordon
_
About Pusher:
Pusher is a hosted service with APIs, developer tools and open source libraries that greatly simplify integrating real-time functionality into web and mobile applications.
Pusher will automatically scale when required, removing all the pain of setting up and maintaining a secure, real-time infrastructure.
Pusher is already trusted to do so by thousands of developers and companies like GitHub, MailChimp, the Financial Times, Buffer and many more.
Getting started takes just a few seconds: simply go to pusher.com and create a free account. Happy hacking!

Пікірлер
  • 4:30 Aspects of Performance 15:25 Measuring Application Performance 26:35 Span and ReadOnlySpan 45:38 Memory 58:55 ArrayPool 1:04:31 System.IO.Pipelines 1:19:54 JSON APIs 1:33:26 Further reading

    @mikasa3427@mikasa34273 жыл бұрын
  • Sometimes I forget that there are people out there writing code that doesn't interact with a database and actually need to optimize their code. The database is always like 90% of the performance cost with whatever I write, so optimization always feels very pointless for myself.

    @shelbytimbrook2095@shelbytimbrook20953 жыл бұрын
    • Take DynamoDB as a counterexample that has ultra low latency guarantees. The data is stored on SSDs to ensure much faster access than something like a traditional SQL database. You can also scale its throughput up as high as you could dream if you have the money. It has its costs though: Mainly its literal cost in dollars but also an inability to create queries as easily. Or consider how something like Redis can give you microsecond times. It doesn't sound right to blame it all on a database and call it a day.

      @AG-ld6rv@AG-ld6rv2 жыл бұрын
  • Great content! Well-structured!

    @dirkmuller6851@dirkmuller68513 жыл бұрын
  • There's a trove of valuable information in here. Thank you!

    @ZakkeryDiaz@ZakkeryDiaz4 жыл бұрын
    • Glad you found it useful! :-)

      @steve-gordon@steve-gordon4 жыл бұрын
  • That isn't an easy talk to give. Hats off for pulling it off

    @Miggleness@Miggleness4 жыл бұрын
    • Thanks!

      @steve-gordon@steve-gordon4 жыл бұрын
  • Amazing talk!

    @rudrabhattacharya3622@rudrabhattacharya36223 жыл бұрын
  • Very informative..thanks for posting.

    @adipaachintha2136@adipaachintha21364 жыл бұрын
  • Amazing!

    @carolynnesilva@carolynnesilva3 жыл бұрын
  • At 1:04:03, was a fair comparison being done? After all, ArrayPool has to allocate the memory the first time too. Was the test comparing allocating an array versus reusing an ArrayPool (by creating an array through it, returning it, and then benchmarking the time to retrieve it)?

    @AG-ld6rv@AG-ld6rv2 жыл бұрын
  • Span.. and slices.. Not pointers! But they kinda are, but special managed pointers.

    @SmartK8@SmartK83 жыл бұрын
    • So are regular variables. Except that those are more heavily managed than spans are, which is exactly their point.

      @zemom.a.8171@zemom.a.81712 жыл бұрын
  • A loooooooooooooooooooot of introduction until he comes to any concrete point.

    @teckyify@teckyify4 жыл бұрын
  • If you want high perf don not use .net. Use any compiled language where you free your object. Also use no objects at all but thats not possible.

    @Esico6@Esico64 жыл бұрын
    • In .Net you have the option of disposing of your objects manually, or letting the Garbage Colletor do it for you. You clearly don't know what you're talking about

      @elkhoukhi@elkhoukhi3 жыл бұрын
    • @@elkhoukhi have u ever compared between .NET and low level language such as C++ ? Check out there :///

      @kevz3351@kevz33513 жыл бұрын
    • @@kevz3351 when it comes to execution speed, the difference between something like C# is very small compared to rust or C++. Thats still a better tradeoff than having to deal with memory safety problems. Plus it depends what the language is designed to archieve. C# was developed to be more of a software programming language. While C++ was designed to be more used in systems- and hardware programming. There was a fun quote I read somewhere saying that C++ is at least 4 months slower than C#, the punchline being that optimization in C++ is a pain while its more manageable in C# with similar results.

      @zemom.a.8171@zemom.a.81712 жыл бұрын
    • @@zemom.a.8171 ok

      @kevz3351@kevz33512 жыл бұрын
KZhead