filmov
tv
GopherCon Europe 2024: Diana Shevchenko - Memory Optimization through Structure Packaging
Показать описание
About the talk: Pack Your Bytes, We're Building: Memory Optimization Through Structure Packing
Overall, the talk is about optimizing code in applications where every byte matters. I will start with a quick introduction to memory layout in Go with a small example in a few slides. This will be to revise how Go structures occupy memory, explaining concepts like padding and hardware sympathy, followed by an explanation of what simple structure layout manipulation can do to improve performance, how Go memory allocator uses different memory blocks (mspans) to store variables of different size. This will be accompanied by a simple real-life analogy to better understand the utility of optimisation for beginners.
Next, we will take a look at a real-life demo (pre-recorded to be safe). In the demo, we will run benchmarks on the code that uses identical structs with different layouts. The demo along with the explanation should take around 5 minutes. After that, we will take a look at the utility and use cases of such code optimisation—when it is needed and when it's best to avoid it. We will take a look at how the compiler can do a similar optimisation for us and why sometimes it doesn't.
This will lead us to the concept of mechanical sympathy, which will be briefly mentioned. And last but not least, we will review a use case from researching this optimisation on the scale of a Go observability library. With this example, we will see a 5–40% improvement in the memory usage of certain "heavy" structures that are created or stored millions of times per minute, and the subsequent performance wins.
About the speaker: Diana Shevchenko
Diana is a Software Engineer 2 at Datadog in the Application Performance Monitoring department. Passionate about computer science. Always eager to learn new things and share knowledge. She has been working with Go for the last few years.
#gopherconEU #golang
Overall, the talk is about optimizing code in applications where every byte matters. I will start with a quick introduction to memory layout in Go with a small example in a few slides. This will be to revise how Go structures occupy memory, explaining concepts like padding and hardware sympathy, followed by an explanation of what simple structure layout manipulation can do to improve performance, how Go memory allocator uses different memory blocks (mspans) to store variables of different size. This will be accompanied by a simple real-life analogy to better understand the utility of optimisation for beginners.
Next, we will take a look at a real-life demo (pre-recorded to be safe). In the demo, we will run benchmarks on the code that uses identical structs with different layouts. The demo along with the explanation should take around 5 minutes. After that, we will take a look at the utility and use cases of such code optimisation—when it is needed and when it's best to avoid it. We will take a look at how the compiler can do a similar optimisation for us and why sometimes it doesn't.
This will lead us to the concept of mechanical sympathy, which will be briefly mentioned. And last but not least, we will review a use case from researching this optimisation on the scale of a Go observability library. With this example, we will see a 5–40% improvement in the memory usage of certain "heavy" structures that are created or stored millions of times per minute, and the subsequent performance wins.
About the speaker: Diana Shevchenko
Diana is a Software Engineer 2 at Datadog in the Application Performance Monitoring department. Passionate about computer science. Always eager to learn new things and share knowledge. She has been working with Go for the last few years.
#gopherconEU #golang