Sergiy Teplyakov 🇺🇦 🇺🇸

3.6K posts

Sergiy Teplyakov 🇺🇦 🇺🇸

Sergiy Teplyakov 🇺🇦 🇺🇸

@STeplyakov

Principal Software Engineer at Azure Physical Networking. Ukraine → US

WA, USA Beigetreten Mart 2010
202 Folgt3.4K Follower
Angehefteter Tweet
Sergiy Teplyakov 🇺🇦 🇺🇸
Hey #dotnet people! Exciting news! I've launched my YouTube channel: "Dissecting the Code". It's going to be very similar to my blog, where I'll cover .NET internals, performance tips & tricks, and more deep dives. #csharp I've already published the first two videos: ➡️ Episode 0: What You'll Learn Here ➡️ Episode 1: Dissecting Variable Lifetime I hope you'll like it! Please share, subscribe, and let me know what you think! Your support means a lot to me. 🙏 Links to the channel & videos are 👇
Sergiy Teplyakov 🇺🇦 🇺🇸 tweet media
English
7
31
195
16.7K
Sergiy Teplyakov 🇺🇦 🇺🇸
New video on Dissecting the Code YouTube Channel: "How LINQ works?" - youtu.be/hFKCOeUfZaA?si… I've seen too many cases when misunderstanding of IEnumerables was causing confusion for devs and the desire to ban LINQ in the codebases altogether. To understand LINQ we should understand iterator blocks. And this is what I'm covering for almost 20 minutes! :)
YouTube video
YouTube
English
0
1
10
821
Tom Cox
Tom Cox@tomcoxcodes·
@STeplyakov Can it be extended to methods that I implement through attributes?
English
1
0
0
39
Sergiy Teplyakov 🇺🇦 🇺🇸
"Zero" cost delegates in .NET 10 JIT in .NET 10 in some cases can fully eliminate the abstraction cost of using delegates. Enumerable.Any can be as efficient as hand-written loop that takes a span out of a list!
Sergiy Teplyakov 🇺🇦 🇺🇸 tweet media
English
6
18
141
7.5K
Bugs Bunny
Bugs Bunny@BugsBunny30143·
@STeplyakov Sadly, in most cases, we still see the closures for non-static delegates. .NET 10 is a giant leap forward though. For years I tried to cache delegates. They are small, but they are heap objects. Local inline functions (functions inside of other functions) aren’t tho.
English
1
0
0
96
Sergiy Teplyakov 🇺🇦 🇺🇸
@BugsBunny30143 How exactly this is helpful for LINQ;) Yes, you can always create a method pointer that matches a given signature and call the method. But this has quite a limited applicability.
English
1
0
0
118
Bugs Bunny
Bugs Bunny@BugsBunny30143·
@STeplyakov U know, U can put the delegate signature in an interface, then call the method in the interface implemented instance and avoid all that allocation, right? That way, the method and the data it acts upon are in the same class. ;)
English
1
0
0
116
Sergiy Teplyakov 🇺🇦 🇺🇸
@tomcoxcodes The delegate de-abstraction works for any delegates. The spanification was added to a bunch of places, and Any is one of them, but not the only one. Many LINQ methods now rely on it.
English
1
0
0
220
Tom Cox
Tom Cox@tomcoxcodes·
@STeplyakov Good to know.. I will try to leverage this.. I assume it's only well know methods like Any? Any docs availability on this?
English
1
0
0
239
Andrija Huzjak
Andrija Huzjak@watbywbarif·
@STeplyakov Great, there is nothing nicer than updating you environment and have things work faster! Especially as the opposite is the norm 😉
English
1
0
0
304
Sergiy Teplyakov 🇺🇦 🇺🇸
@PauloMorgado The delegate should be called tens of thousands of times for JIT to try to use all of the optimizations. Works best for short-lived delegates used with LINQ. Heavy delegates probably won't be called as much and hence won't be optimized. Plus, they won't be inlineable probably.
English
0
0
1
28
Paulo Morgado
Paulo Morgado@PauloMorgado·
@STeplyakov Does it apply to every delegate usage, or does it require something special from the methods receiving and invoking the delegate?
English
1
0
0
22
Sergiy Teplyakov 🇺🇦 🇺🇸
Next video on Dissecting the Code channel. This time I cover .NET 10 performance improvements around de-abstracting the delegates. In .NET 10, the LINQ Any method can easily outperform a manual loop over a list! Awesome job, .NET team! youtu.be/-h5251IWv-Y?si…
YouTube video
YouTube
English
2
2
10
1.7K
Sergiy Teplyakov 🇺🇦 🇺🇸
As always, would appreciate spreading the word and sharing the video. And if you have recommendations on what I can cover next, I'll be happy to hear that!
English
0
0
0
258
Sergiy Teplyakov 🇺🇦 🇺🇸 retweetet
Dr Milan Milanović
Dr Milan Milanović@milan_milanovic·
I wanted to understand how GPT works, so I ported Karpathy's microgpt.py to C# from scratch. No frameworks and NuGet packages, just plain math in ~600 lines of code. It builds a tiny GPT that learns from 32K human names and invents new ones. Every piece is there: autograd, attention, Adam optimizer, the works. Just at a scale you can actually sit down and read. I also wrote a prerequisites guide that walks through all the math and ML you need, starting at a high school level. If you've ever wanted to peek under the hood of ChatGPT without drowning in linear algebra textbooks, this might help. github.com/milanm/AutoGra…
Andrej Karpathy@karpathy

New art project. Train and inference GPT in 243 lines of pure, dependency-free Python. This is the *full* algorithmic content of what is needed. Everything else is just for efficiency. I cannot simplify this any further. gist.github.com/karpathy/8627f…

English
31
194
1.9K
198.4K
Sergiy Teplyakov 🇺🇦 🇺🇸
Another video on Dissecting the Code YouTube channel: "ConfigureAwait best practices". I feel we have a cargo cult on using ConfigureAwait without thinking too much. I've seen cases when the application code was filled with it "to improve performance" or "to avoid deadlocks". And it was very hard to convince that this is not how ConfigureAwait should be used. In this video I'm covering why we have ConfigureAwait in the first place and how to use it correctly. youtu.be/bUHQeY-DlBc?si…
YouTube video
YouTube
English
1
5
14
1.5K
EgorBo
EgorBo@EgorBo·
@STeplyakov Which made it slightly less Escape-Analysis friendly :|
English
1
0
0
617
Sergiy Teplyakov 🇺🇦 🇺🇸
Do you know that just changing the C# langversion might affect performance? The code generation for method group conversion has changed in C# 11 to avoid allocations in certain cases.
Sergiy Teplyakov 🇺🇦 🇺🇸 tweet media
English
1
1
36
2.9K
Sergiy Teplyakov 🇺🇦 🇺🇸
It's super nice to see that my latest video about de-abstraction in .NET crossed 2K views in a week and is already the most watched video on "Dissecting the Code" channel! Thanks everyone for watching! P.S. If you have a topic you want me to cover, I'll be happy to do that!
Sergiy Teplyakov 🇺🇦 🇺🇸 tweet media
English
1
1
6
637