Adam Furmanek

Information & Communications Technology

C# .NET .NET Backend .net framework .net core .NET 5 .NET (Core) development .NET Standard C#.Net ASP.NET java software architecture compilers programming languages kotlin java JVM ILP Mathematics cloud Cloud Computing Cloud Computing on the Azure Platform Cloud Containers and Infrastructure Cloud Architecture JVM Languages JavaScript Core Java / Java SE Distributed distributed computing Distributed Databases distributed systems Media & Information information theory Informatics information architecture Information Design Information Management Information Systems Information Technology

Seattle, Washington, United States

Adam Furmanek

Software Developer at Amazon, Seattle

I am Adam Furmanek and I am a professional software engineer for almost a decade. Right now I am at Amazon working with Big Data, Spark, and Machine Learning. I am always interested in digging deeper, exploring machine code and going through implementation details to better understand internals of the technologies I use every day. That's why I like debugging, decompiling and disassembling the code to understand memory models, concurrency problems and other details hidden deeply inside. In my free time I play ping-pong, watch Woody Allen's movies and blog stuff at http://blog.adamfurmanek.pl

Current sessions

Understanding Windows and .NET through debugging

Debugging is hard to do and hard to learn. Each bug is different, and there is no single path to learn how to tackle memory leaks or concurrency issues. It also requires an understanding of multiple software layers, starting with C#, through intermediate language, down to the operating system, and the machine code level. In this workshop, we'll see .NET under the hood. We will use debuggers to understand type safety, memory management, or concurrency primitives. We will learn how to debug the platform when something goes wrong.

Objectives:
* Understanding of Windows and x86 CPU architecture, how they work together and how they are used by .NET platform.
* Understanding of various .NET mechanisms, memory structures, exception handling, asynchronous programming.
* Common debugging scenarios with WinDBG, including memory management, concurrency, garbage collection.
* Tools helpful for post-mortem debugging and investigation.

Requirements:
* Windows 10 running on x86_64 architecture
* Visual Studio 2019
* .NET Core 3.1.101
* .NET Framework 4.8
* dnSpy
* WinDBG + configured symbols + configured SOS for all .NET environments
* git


Understanding async machinery down to a single detail

We all use asynchronous code and we have some understanding of the machinery behind it. It's time to see how it works and learn why it's hard to synchronously wait for asynchronous code, how to wait for async void methods, or how to debug deadlocks. We will see the code generated by the compiler, understand synchronization contexts and integration with TPL library, reimplement part of the mechanism to fix deadlocks, or just play with internals to understand them better.

Objectives:
* Understanding async state machine
* Learning about synchronization contexts and how they differ between console, ASP .NET, ASP .NET Core, or desktop applications
* Implementing custom primitives for better code control
* Awaiting async void methods
* Capturing all out-of-band exceptions
* Implementing custom tasks or synchronization contexts

Requirements:
* Windows 10 running on x86_64 architecture
* Visual Studio 2019
* .NET Core 3.1.101
* .NET Framework 4.8
* dnSpy
* WinDBG + configured symbols + configured SOS for all .NET environments
* git


Ordering the chaos - cleaning logs and ordering events in microservices

No more monoliths! Let's use microservices and asynchronous invocations everywhere! But how to track logs when multiple calls are in place, clocks are skewed, network is faulty and something goes wrong? How to figure out what happened first? And how to debug this single request which caused so many troubles?

In this talk I explain problems with synchronizing clocks and why relying on timestamps doesn't work in the world of microservices. We will see happened-before relation, vector clocks, correlation ids and other patterns used to introduce some meaningful order. We will understand why common understanding of "time" is misleading in distributed systems and what to use to mitigate that.

Examples will be in .NET. Level 200, moderately intense session.


MOV, async/await, DSL, Lambda Calculus, DDD - are they connected?

MOV is an assignment instruction in the assembly language. C# supports async and await pattern by rewriting method into a state machine. Domain specific languages give us languages tuned for some domain problems. Lambda Calculus shows how to calculate things using functions only. These things are completely different! Or are they?

In this talk we will go through abstraction and why it is important to extract common patterns into specific solutions. We will understand why we need multiple programming languages and cannot just have "one language to suit everyone". We will see basics of async/await, Lambda Calculus and DSL. We will then discuss some ideas behind theory of computations to see why we don't need to have anything beside MOV. Finally, we will see why we build tools and abstractions to deliver customer value.


Internals of Exceptions

You know how to throw and catch exception. But do you know how are they implemented internally? Do you know what is SEH, VEH and VCH in Windows? Or do you know why C# introduced exceptions filters or how to catch everything, even StackOverflowException?

In this presentation I show internal mechanisms used by Windows for handling exceptions. We will see constructs used by C++ and C# languages, CLR instructions and machine code details of those. There will be some live debugging and low to high level code.

Preferred duration: around 50 minutes.
Target audience: Windows and .NET developers. No prior knowledge is required.


Manual memory management in .NET Framework

Value types are on a stack and reference types are on a heap - this is a typical answer when one is asked about placement of values in memory. However, is it really defined that way in the .NET Framework specification? Or can we bend the rules and manage memory differently?

During the session I will show how to allocate memory directly by hand using TypedReferences. We will see that it is possible to allocate reference type on a stack, how to implement generic List faster than the default implementation provided by .NET Framework, how to implement custom memory allocator (with any fragmentation strategy we like), and finally, how to hack new keyword provided by the platform to use different allocator. We will examine memory dumps with WinDBG, emit IL code dynamically, and generate machine code for x86 directly in runtime.

Level 400, moderately intense session.


Integer Linear Programming introduction - let computer find solutions

You are probably used to telling the computer how to solve a problem but do you know that you could as well just explain what the solution looks like and let computer do the job? In this presentation I show Integer Linear Programming - a declarative way of solving problems.

Integer Linear Programming is a branch of mathematics focusing on solving optimization problems. You don't need to think about the algorithms anymore, just explain what needs to be done and give computer a chance to figure out how to do it.


Implementing async with coroutines and fibers - project Loom in C#

Async has multiple problems. It requires specific return type, can switch thread any time, causes deadlocks, uses global state. Can we do better? Can we do async/await without all its mess?

In this talk we will learn how async is implemented, see what problems it creates, and explore other possible approaches. We will reimplement some of its features with monads, coroutines, and fibers to see how it could look like in an alternative world. We'll see if we can do better than the thread-pool based approach.

This is loosely related to project Loom in JVM world which explores fibers to improve threading.

Level 300.


Hacking C# from the inside - how to do anything in .NET

C# is compiled to intermediate language, strongly typed, and garbage collected language. Let's abuse all these elements — we will emit machine code directly, abuse type system, override sealed types, hide objects from GC, all of that directly in the C# language without using external tools.

We'll see real life scenarios where these things are used and that sometimes "one hacky line" saves us hours of debugging. Based on multiple examples, some are level 200, some are level 400, all of them are worth knowing about.


From bulb to C# — how does computer work?

Computers — we use them every day for work, entertainment, discoveries or even house management. Our watches are more powerful than computers used by NASA to put a man on the Moon. But do we really know how they work? What is von Neumann architecture, microcode, x86 and other magical terms? How is it possible that this little thing performs more calculations than we could ever do in our lives?

In this talk we will see how it works. We will start with few bulbs emitting light and finish with computer capable of running the CLR. We will understand the magic behind it and what is actually going on "under the hood".


Generics everywhere - but they are not the same

.NET as other platforms supports generics. They allow us to write strongly typed code just once and reuse it for multiple types. Even though this sounds easy, generics are actually quite complicated under the hood and each platform implements them differently.

We will see different approaches for implementing generics. We will compare reification in .NET, type erasure in JVM and templates in C++. We will see why stronger type system sometimes is less powerful and why casting everything to object can be better than storing a concrete type. We will see what had to be done to support generics in .NET and why they were not available since the very beginning.

Level 200. Moderately intense session.


DLL Injection in Windows

DLL Injection sounds like some black magic used only by hackers. However, it is used widely in the Windows ecosystem by multiple antiviruses and system utilities. During the presentation I show how we can use it to change 3rd party applications and how to write simple keylogger in 20 lines of code.


Exploring memory in .NET applications

.NET provides a safe type system which saves us from most memory problems we had in native applications. However, it still exposes API to manipulate the memory directly which we can use to increase performance in some scenarios where speed is critical. In this workshop we will understand memory structure and what can be done beyond reference and value types. We will see how to allocate reference type on the stack, how to implement list faster than the provided List of T, how to serialize objects by reading their bytes directly, or how to hide them from GC.

Objectives:
* Understanding of Windows and x86 CPU architecture, how they work together and how they are used by .NET platform.
* Understanding .NET memory structures
* Manual memory management
* Hiding objects from GC

Requirements:
* Windows 10 running on x86_64 architecture
* Visual Studio 2019
* .NET Core 3.1.101
* .NET Framework 4.8
* dnSpy
* WinDBG + configured symbols + configured SOS for all .NET environments
* git


Async internals in .NET

Async and await are now common elements of .NET ecosystem. Do you know how they work? Do you know what is synchronization context, how to wait for async void methods or how to implement custom task scheduler?

In this talk I show internals of async and await. I present state machine created by the compiler, consider allocation issues and show typical deadlock scenarios. We will see how to call async methods from synchronous code, how to wait for async void, how to implement custom synchronization context or task scheduler to handle exceptions, and how to run task without allocation at all.


async – biggest mistake in C#?

We use async and await a lot nowadays and every library must support it. But is it a good idea? Is the whole pattern implemented well? What are the problems and why using async may not be a good idea?

In this talk I show why async is far from being perfect. I cover problems with global state, exception handling, deadlocks and garbage collection. I explain why crucial programming principles were ignored when designing the mechanism and how broken it is.

Level 200, basic understanding of async/await is required.


Bridging the world together - case study of a multicommunicator supporting 20+ networks

Messenger rules the world. Or does it? What about WhatsApp, Slack, Signal, Skype, Viber, QQ and dozens of others? How to talk to friends who use different IM network and still keep everything in one place?

With this question in mind I started building my own communicator in 2017. Now, it support 20+ different protocols, can communicate with no internet connection, uses custom NoSQL database, synchronization primitives, queuing system, and works reliably even in face of catastrophic failures. Come and see how a home-grown project evolved and allowed me to get tons of experience.