Kevin Gosse Profile Banner
Kevin Gosse Profile
Kevin Gosse

@KooKiz

Followers
4,481
Following
111
Media
522
Statuses
4,385

Bluesky: @kevingosse .net Software developer at Datadog, passionate about .NET, performance, and debugging. Microsoft MVP.

Paris / France
Joined January 2009
Don't wanna be here? Send us removal request.
Explore trending content on Musk Viewer
Pinned Tweet
@KooKiz
Kevin Gosse
1 year
My typical workflow as a performance enthusiast: 1. Write the naive solution to a problem 2. Optimize it 3. Benchmark both solutions 4. Pretend it never happened
Tweet media one
23
64
740
@KooKiz
Kevin Gosse
5 years
We're in the middle of migrating one of our biggest apps (5000+ servers) to .net core. In yellow is CPU usage for .net framework + . In green is .net core 3.1 + aspnetcore. We've migrated other apps but it's the first time we see such a dramatic improvement
Tweet media one
17
142
577
@KooKiz
Kevin Gosse
11 months
In preparation for my talk at @update_conf , I've prepared a tool to visualize the activity of the GC. It was initially meant as a gimmick, but it turns out to be a good way to understand some GC mechanisms. For instance, here you can see the effect of
14
77
527
@KooKiz
Kevin Gosse
1 year
While reading Stephen Toub's article on .NET 8 performance, I noticed a very interesting feature introduced in .NET 8, that I never heard about: [UnsafeAccessor]. It allows you to get a reference to a private field or method of a target type while ignoring visibility checks.
Tweet media one
Tweet media two
16
82
470
@KooKiz
Kevin Gosse
2 years
Still a very early prototype, but here is Windbgpt, a #chatgpt -powered AI assistant directly in #Windbg ! It analyzes the output of the commands, and provides guidance to solve the stated problem. Here is an example of it investigating a deadlock in a .NET application.
13
93
447
@KooKiz
Kevin Gosse
4 years
I recently compiled a list of best practices in C# for Criteo, so I thought it would be interesting to share it publicly: This list is backed by experience: *all* of those items have been spotted at some point in our code and have caused production issues
13
149
432
@KooKiz
Kevin Gosse
8 months
I'm happy to finally announce the availability of this tool, under the name of GC (GummyCat) : It is mainly meant as an educative tool to understand how the memory is organized by the .NET GC (Garbage Collector). It has helped me a lot during the writing
Tweet media one
@KooKiz
Kevin Gosse
11 months
In preparation for my talk at @update_conf , I've prepared a tool to visualize the activity of the GC. It was initially meant as a gimmick, but it turns out to be a good way to understand some GC mechanisms. For instance, here you can see the effect of
14
77
527
9
84
328
@KooKiz
Kevin Gosse
7 years
Being able to write C# scripts from WinDbg is really a game changer when manipulating a memory dump with complex data structures
Tweet media one
4
132
306
@KooKiz
Kevin Gosse
1 year
A tip from a coworker that seems obvious in hindsight and yet blew my mind: you can add a profile to Windows Terminal to run C# REPL (). Great for quickly testing/prototyping stuff when you have a doubt. #dotnet
Tweet media one
9
66
276
@KooKiz
Kevin Gosse
6 months
You know this box of old cables that we all have? Two years ago I threw away the ones I would *really* never need. Among them, IDE cables. Completely useless nowadays. And of course, today, I need an IDE cable. Learn from my mistake, don't throw away anything from The Box.
Tweet media one
27
28
276
@KooKiz
Kevin Gosse
1 year
@Marie_mja77 @Linguisticae La même. Avis de passage dans la boîte aux lettres disant que le colis n'a pas pu être livré. J'appelle le numéro, on me dit que le livreur n'a pas trouvé l'adresse.
2
1
280
@KooKiz
Kevin Gosse
2 years
The year is 2022, and I'm debugging a Linux coredump in Windbg because I failed to open it properly with LLDB and GDB
Tweet media one
Tweet media two
Tweet media three
8
31
260
@KooKiz
Kevin Gosse
2 years
Regardless of the circumstances around this code, I find the reactions very interesting. I immediately thought "you can do better with a loop". But then I realized that you can understand this code with a glance, while the loop would take you a significant time to understand.
@JeroenFrijters
Jeroen Frijters
2 years
The Dutch government was forced to release the source code of their DigiD digital authentication iOS app. It is written in C#.
Tweet media one
510
1K
10K
27
8
256
@KooKiz
Kevin Gosse
3 years
Yesterday I spent the day investigating why calling a C++ library from another was crashing my app. Turns out one was compiled in debug and the other in release, and in that case std::string has a different binary layout. The more I learn about other languages, the more I love C#
8
11
226
@KooKiz
Kevin Gosse
10 months
When you add some asynchronous code to a method and have to choose between updating the 120 callers or adding a tiny .GetAwaiter().GetResult()
Tweet media one
30
3
186
@KooKiz
Kevin Gosse
1 year
It bothers me so much that on #dotnet on 64-bit, 4 bytes are wasted for *every class instance* because objects are aligned on a 8 bytes boundary and the header has a fixed size of 4 bytes.
Tweet media one
16
19
181
@KooKiz
Kevin Gosse
11 months
I tried solving old #AdventOfCode puzzles, but apparently Github Copilot has been trained on so many solutions that it solves it before I can even type anything. Not even the instructions.
Tweet media one
11
5
182
@KooKiz
Kevin Gosse
9 months
It freaks me out how unreliable the search has become in Visual Studio. That's one of the few areas it is *not* acceptable to mess up.
Tweet media one
48
7
174
@KooKiz
Kevin Gosse
5 years
We tried fixing in our internal CLR fork, and saw a dramatic improvement in our p99 response time. We will push the fix upstream in the coming days, expect some benefits if you run a memory-constrained .net core app on Linux
Tweet media one
4
34
174
@KooKiz
Kevin Gosse
1 year
First time actually using Time Travel Debugging, and loving it. I was unable to understand how a particular value was ending up in memory, with TTD it's a matter of setting what memory range you're interested in and you can then browse each memory access with their callstack 🤯
Tweet media one
4
14
151
@KooKiz
Kevin Gosse
1 year
0
0
151
@KooKiz
Kevin Gosse
4 years
Time to make it official. I'm leaving Criteo and starting today at @datadoghq . I'm joining the .NET APM team. This will probably give me plenty of new performance-related material to talk about 🙂
11
0
121
@KooKiz
Kevin Gosse
1 year
Just published an article digging deep into how arrays of doubles are aligned in #dotnet . With juicy bits about the allocation context, fake objects, and C# code that you definitely shouldn't deploy in production.
3
24
120
@KooKiz
Kevin Gosse
2 years
Just published part 3 of my ongoing series about how to write a .NET profiler in C#: This time, we write a source generator to automatically generate the code of the wrapper that we use to expose the objects to the native side. #dotnet
0
28
114
@KooKiz
Kevin Gosse
3 years
Just blogged: using ClrMD and NativeAOT to write native WinDbg extensions in C#.
3
37
108
@KooKiz
Kevin Gosse
1 year
@Raye_Alex @GendyGentil Seule l'assurance responsabilité civile est obligatoire. C'est celle qui couvre les dégâts que tu infligerais à d'autres usagers. Car malheureusement en voiture ce n'est pas toujours celui qui fait de la merde qui subit.
1
0
108
@KooKiz
Kevin Gosse
5 months
Working at Datadog, it's also writing C-like C# code that crashes on purpose.
Tweet media one
17
2
106
@KooKiz
Kevin Gosse
4 years
A reminder as I just got bitten by this: using a new Random instance per thread is NOT safe on .net framework. The seed is generated from the system clock, with a very low resolution, so there is a high risk that many threads are going to generate the same sequence of values
Tweet media one
9
24
102
@KooKiz
Kevin Gosse
3 years
I don't know if it's a feature or a bug, but I really didn't expect IntelliCode to work in a string literal. And perfectly predicting what I was typing. 🤯 #VS2022
Tweet media one
5
5
92
@KooKiz
Kevin Gosse
9 months
I just published a new article: "Exploring .NET frozen segments", where we look at how to allocate managed objects outside of the managed heap. You most definitely can, but ask yourself if you should.
9
30
99
@KooKiz
Kevin Gosse
5 years
Just blogged: debugging and fixing the Twitch desktop client. An article where I exhaustively retrace the steps behind an investigation, hoping to describe my mindset when debugging an application I know nothing about.
5
30
95
@KooKiz
Kevin Gosse
4 years
Just blogged: how to use a startup hook to easily collect GC metrics from any .net core application
4
33
92
@KooKiz
Kevin Gosse
10 months
In case you missed it, Visual Studio has a new feature to show the layout of a C++ object. It's *really* convenient when doing some interop between native and managed code.
Tweet media one
1
10
87
@KooKiz
Kevin Gosse
5 years
"aaaaaaaaaz".StartsWith("i") "aaaaaaaaa-".StartsWith("i") Can you spot the difference? Well, the latter is 2 orders of magnitude slower on Linux.
Tweet media one
6
21
85
@KooKiz
Kevin Gosse
2 years
I published the first part of a series of articles about how to write a .NET profiler in C#, thanks to NativeAOT:
@KooKiz
Kevin Gosse
2 years
I know I was supposed to write an article about the LLDB stuff, but I couldn't resist the temptation to first write a proof of concept of a .NET profiler written in C# thanks to NativeAOT
Tweet media one
2
9
51
1
20
84
@KooKiz
Kevin Gosse
8 months
That's the 5th bug found in the CLR while writing Pro .NET Memory Management 2nd Edition ( #progc2 ) 🤓
@chnasarre
Christophe Nasarre
8 months
Thanks @KooKiz for having investigated why I was triggering 2 garbage collections while building the upcoming dotnet-fullgc CLI tool - #progc2 @konradkokosa
0
0
27
0
2
80
@KooKiz
Kevin Gosse
1 year
When I wrote the cats stock market app for the Effective Debugging workshop, I really didn't expect to see it featured in so many Visual Studio articles 😺 In case you're curious, the source code is available here:
1
14
80
@KooKiz
Kevin Gosse
2 years
Just blogged: Reading .NET performance counters without the PerfCounter API Or how to skip the middle-man when trying to read perf counters from within the same process.
2
22
80
@KooKiz
Kevin Gosse
2 years
Long overdue, I published part 2 of my ongoing series to write a .NET profiler in C# : In this part, we see how to use GCHandle to map our static native method to a managed instance. #dotnet #csharp
0
31
79
@KooKiz
Kevin Gosse
5 years
After 5 years of nominations from @lancewmccarthy and @theothernt , it happened when I expected it the least. Thanks to everybody who made this possible.
Tweet media one
16
3
78
@KooKiz
Kevin Gosse
9 months
I just published a new article, about how to walk the managed heap from your #dotnet application: It only works with server GC, and is extremely unsafe. But it's also a ton of fun.
0
21
76
@KooKiz
Kevin Gosse
8 months
@SwiftOnSecurity In the same vibe, it's been a few months that whenever I click on "Update and shutdown", my desktop computer reboots at the end of the updates and stays on...
2
2
75
@KooKiz
Kevin Gosse
4 years
In case you missed it, .NET is getting a Task.WaitAsync API: Before: await Task.WhenAny(task, Task.Delay(timeout, token)) After: await task.WaitAsync(timeout, token) Nice addition, though I'm still not fan of exception-based cancellation
1
14
73
@KooKiz
Kevin Gosse
5 years
TIL: If a task has 2 await continuations, both are inlined and the second one will wait for the first one to complete. That behavior has been fixed here: This program will never complete on .net framework and .net core < 3.0:
5
16
70
@KooKiz
Kevin Gosse
6 years
TIL: The .net core implementation of Socket on Linux does not use I/O threads, and instead relies on ThreadPool.UnsafeQueueUserWorkItem. That's *very* bad for us, because it competes with the application to get threads to complete I/Os, and worsens our thread starvation problems
5
31
67
@KooKiz
Kevin Gosse
1 year
Good old Docker on Windows. Note that I didn't even start a container.
Tweet media one
16
2
68
@KooKiz
Kevin Gosse
6 months
I really, really love C# 12 collection expressions. To the point that I've started wishing that there was a ..= operator 😅
Tweet media one
6
2
67
@KooKiz
Kevin Gosse
2 years
@ShinyQuagsire Nice! I also made a program to change the input source of my LG screen (27GL850B), but I took a different approach and decompiled the OnScreen Control application to understand the protocol, then used named pipes to send my commands to OSCApplicationManager
2
1
64
@KooKiz
Kevin Gosse
1 year
I published part 4 of my ongoing series of articles about how to write a .NET profiler in C#: This time we learn how to invoke methods from a native virtual object, and write a source generator to automate the boilerplate code. #dotnet
0
18
65
@KooKiz
Kevin Gosse
8 months
Mono.Cecil is powerful but some parts are tricky to get right, especially when dealing with generics. I just discovered , that shows you how to generate the given C# code with Cecil. Incredibly useful, I can't believe I never heard of it before.
7
17
66
@KooKiz
Kevin Gosse
4 years
There are few things I enjoy as much as digging into a new codebase and methodically implementing all those optimizations. Expect a nice speedup for the Datadog .net tracer in the coming versions!
Tweet media one
1
5
61
@KooKiz
Kevin Gosse
3 years
I had a discussion a while ago with coworkers about how Windows is missing a sudo equivalent, and it turns out there are pretty good alternatives available. I've been using gsudo for a few days now and it works great. I definitely recommend it.
3
16
63
@KooKiz
Kevin Gosse
4 years
Preparing a Perf top written entirely in .NET Core, for my part in @chnasarre 's talk at DotNext
Tweet media one
1
8
59
@KooKiz
Kevin Gosse
10 months
I found this code in the .NET BCL while studying different strategies to dynamically invoke an object constructor, and wow... My head hurts 😅
Tweet media one
6
5
61
@KooKiz
Kevin Gosse
1 year
@r_saintier @laydgeur Si tu as une pompe à chaleur, si.
4
0
58
@KooKiz
Kevin Gosse
1 year
I just learned two things: p/invokes can be declared as local functions, and local functions are scoped to the current block (somehow I assumed they were scoped to the enclosing method). Included: a spoiler of my next article.
Tweet media one
2
6
60
@KooKiz
Kevin Gosse
2 years
Just blogged: Why function pointers can’t be used on instance methods? Or an exploration of the CLR ABI to understand why using function pointers on instance methods would require special support. #dotnet
4
18
58
@KooKiz
Kevin Gosse
11 months
Ready to talk about memory management in #dotnet at @update_conf . Eager to see in what creative ways @chnasarre will make the demos fail.
Tweet media one
2
5
58
@KooKiz
Kevin Gosse
6 years
Just wrote a short guide explaining how to write debugger extensions that use ClrMD and are compatible with WinDbg on Windows *and* LLDB on Linux:
1
20
59
@KooKiz
Kevin Gosse
4 years
I got inspired by the @dotnetosorg webinar on C# 9. Introducing to you... An early proof-of-concept of using source-generators and ClrMD to generate strongly-typed entities from a memory dump at compilation time, for easier inspection
Tweet media one
2
5
57
@KooKiz
Kevin Gosse
8 months
Days since it last happened: 0
Tweet media one
@KooKiz
Kevin Gosse
1 year
My typical workflow as a performance enthusiast: 1. Write the naive solution to a problem 2. Optimize it 3. Benchmark both solutions 4. Pretend it never happened
Tweet media one
23
64
740
6
1
56
@KooKiz
Kevin Gosse
10 months
That sounds fun, maybe we could do the same for #dotnet
@gunnarmorling
Gunnar Morling 🌍
10 months
📢 "The One Billion Row Challenge" How fast can YOU aggregate 1B rows using modern #Java ? Grab your threads, flex your SIMD, and kick off 2024 true coder style by joining this friendly little competition. Submissions accepted until Jan 31. 👉
Tweet media one
69
231
1K
10
11
57
@KooKiz
Kevin Gosse
2 years
@sebify Professionally we tend to reward complexity: it's much easier to demonstrate your skills by writing complex code that only you can understand, rather than a simple solution to the same problem. The latter is much harder to come up with, but feels obvious to the reader.
5
2
55
@KooKiz
Kevin Gosse
1 year
While working on #progc2 , I did some research on the SuppressGCTransition attribute. It magically speeds up p/invokes, with some pretty big drawbacks. If you want to learn more than you will ever need about that attribute, check my article: #dotnet
3
18
56
@KooKiz
Kevin Gosse
1 year
Useless but fun, you can get the address of a managed object or craft a reference without using unsafe code by abusing GC handles. #dotnet
Tweet media one
3
4
55
@KooKiz
Kevin Gosse
9 months
Small teaser for my next article, dumping the managed heap in C# without using ClrMD or the debugging API
Tweet media one
Tweet media two
1
5
54
@KooKiz
Kevin Gosse
10 months
Just in time for the new year, I've migrated my blog from medium to github pages: Feedback is welcome, especially if you notice something wrong or broken links.
4
5
53
@KooKiz
Kevin Gosse
5 years
I don't know if there's a better feeling in my job than that moment when you finally identify a bug in the GC after weeks of investigation 😊
5
2
53
@KooKiz
Kevin Gosse
5 years
When developing for aspnetcore/kestrel, keep in mind that the same HttpContext instance is reused for all the requests on a given HTTP connection (in case of keep-alive). If not, in the worst case scenario, you might end-up replying to the wrong request:
2
17
52
@KooKiz
Kevin Gosse
6 years
Just blogged on @CriteoEng : Optimizing the WinDbg DML parser. Or how using the wrong class at the wrong place can completely ruin your performance
1
16
49
@KooKiz
Kevin Gosse
6 years
Nothing new, but I believe this is a little known quirk of C#. Can you predict the output of this code?
Tweet media one
8
19
52
@KooKiz
Kevin Gosse
2 years
I know I was supposed to write an article about the LLDB stuff, but I couldn't resist the temptation to first write a proof of concept of a .NET profiler written in C# thanks to NativeAOT
Tweet media one
@KooKiz
Kevin Gosse
3 years
3 years later, I'm experimenting with another approach that doesn't require the use of the "LoadManaged" meta plugin to work with LLDB, thanks to NativeAOT
Tweet media one
1
0
8
2
9
51
@KooKiz
Kevin Gosse
6 years
If you like debugging, you never get a chance to be bored at Criteo. Today, a server unresponsive with 100% CPU usage, 200 threads stuck on a static lock in Exception.RestoreExceptionDispatchInfo. I especially like the comment on the static lock in the BCL 🙃
Tweet media one
Tweet media two
5
6
51
@KooKiz
Kevin Gosse
4 years
I'll be giving a talk at NDC Oslo next month: Designing and rewriting asynchronous tasks from scratch The concept is to start from nothing an re-implement a future/promise pattern in C#, to understand the complexity and the technical choices behind the TPL
2
7
50
@KooKiz
Kevin Gosse
1 year
I spent a lot less time in conferences this year because of the birth of my son, so I was a bit worried but it looks like I got renewed anyway 🥳 #dotnet #mvpbuzz Let's spend another year debugging obscure bugs and digging into the internals of .NET.
Tweet media one
3
0
50
@KooKiz
Kevin Gosse
11 months
While working on #progc2 , to test my understanding of regions, I imagined how the .NET GC would accommodate the allocation of an array bigger than 4MB, when setting a custom LOH threshold to 8MB. Why would that be interesting? When regions are enabled (by default in .NET 7 and
1
3
48
@KooKiz
Kevin Gosse
2 years
Another Linux core dump that I didn't manage to open with gdb, but windbg handled it flawlessly. @timmisiak have you considered porting windbg to Linux and calling it wingdb?
1
4
46
@KooKiz
Kevin Gosse
7 months
I published a write-up of the investigation: A story about advanced debugging when printf is the only sane tool at your disposal.
@KooKiz
Kevin Gosse
7 months
Segmentation fault in libmscordaccore. I guess it's time to debug the debugger 😬
Tweet media one
1
0
27
1
10
45
@KooKiz
Kevin Gosse
5 years
When we realized we could build custom versions of the CLR tweaked for our needs, things got out of hand pretty quickly 😅
Tweet media one
3
3
45
@KooKiz
Kevin Gosse
5 months
Today in our show, "Seasoned C# developers have to write some C and do everything by hand because of how poor libc is"
Tweet media one
4
1
48
@KooKiz
Kevin Gosse
11 months
@chrismckee @update_conf I admit, "something that looks like a defrag tool" that was the original goal 😅
Tweet media one
3
0
45
@KooKiz
Kevin Gosse
2 years
Shorter and elegant is not necessarily better.
4
1
43
@KooKiz
Kevin Gosse
2 years
I couldn't stop here, I had to try using NativeAOT to write a .NET GC in C# (here, just a conversion of @konradkokosa bump pointer GC)
Tweet media one
@KooKiz
Kevin Gosse
2 years
I know I was supposed to write an article about the LLDB stuff, but I couldn't resist the temptation to first write a proof of concept of a .NET profiler written in C# thanks to NativeAOT
Tweet media one
2
9
51
1
7
43
@KooKiz
Kevin Gosse
1 year
- Spend days researching. - Finally got the full picture, ready to write an article. - While writing, test an edge case to validate my understanding. - Get unexpected results. Discover a whole new mechanism. Article is postponed. - Spend days researching. - Rinse, repeat.
2
2
40
@KooKiz
Kevin Gosse
1 year
For a while I was satisfied with Medium, but I feel like they crossed a line. Konrad is migrating his blog to Github Pages, so maybe I'll do the same. As a reader, what's your take on Medium? I've seen on twitter and reddit that some people are really bothered by it.
Tweet media one
@konradkokosa
Konrad Kokosa
1 year
Migrating blog from WordPress. Wish me luck. ETA ~1 month.
4
0
28
36
0
39
@KooKiz
Kevin Gosse
7 months
The automatic decompilation feature in VS is nice, but when ctrl+clicking on a built-in .NET type it only shows the metadata. Anybody knows how to show the actual implementation, like with Resharper?
Tweet media one
12
0
40
@KooKiz
Kevin Gosse
4 years
On the importance of continuous performance measurement. We detected a performance regression on our product and were able to easily track down the exact commit that caused it. Detection and diagnosis took about 30 minutes.
Tweet media one
3
3
39
@KooKiz
Kevin Gosse
5 years
Just blogged: Or how to divert the async machinery to remove boilerplate code from your desktop applications
5
18
39
@KooKiz
Kevin Gosse
3 years
It was hard to keep the secret. I'm really hyped to see Ozcode joining Datadog. I'm looking forward to working with those amazing people who share my passion for debugging😃
3
8
40
@KooKiz
Kevin Gosse
4 years
Just published the third and last part of my investigation about diagnosing an InvalidProgramException from a memory dump: Digging into the structure of an IL method, and finding a few bugs in SOS while doing so
0
10
38
@KooKiz
Kevin Gosse
4 years
Number of times I used Type.IsAssignableFrom the wrong way: +1
4
0
38
@KooKiz
Kevin Gosse
4 years
Just blogged: An unconventional way of investigating a NullReferenceException, or how a crash on ARM64 led me to dig into interface dispatch in .NET. #dotnet #debugging
2
11
37
@KooKiz
Kevin Gosse
5 years
By the way, I'll be at @DotNextConf next week in Moscow to talk about -you guessed it- debugging. For those who can't attend, DotNext talks are usually recorded and available a few weeks after the conference. For the others, see you there!
1
6
36