Summary of GopherCon 2020: Dan Scales - Implementing Faster Defers

This is an AI generated summary. There may be inaccuracies.
Summarize another video · Purchase summarize.tech Premium

00:00:00 - 00:20:00

In this video, Dan Scales discusses how the defer keyword is used in Go programming language and how it is implemented. He also discusses how the overhead associated with defer is reduced in Go 114 and how future optimizations may be made.

  • 00:00:00 In this video, Dan Scale explains how the defer keyword is used in Go programming language and how it is implemented. He also discusses how the overhead associated with defer is reduced in Go 114 and how future optimizations may be made.
  • 00:05:00 Dan Scales discusses the benefits of implementing faster defers in different languages. He notes that defer is a more maintainable and clarity-oriented approach than try/finally, and also has enhanced robustness to bugs or unusual cases. He also explains that defer is implemented with the help of the runtime, and that it can be expensive to handle in the common simple cases.
  • 00:10:00 In this video, Brock describes how Go defines deferred calls. Deferred calls are implemented in Go by allocating a stack slot for the function pointer and arguments and storing the values into that stack slot. When the deferred call is executed, the compiler determines which deferrer was activated at the time of the call and makes the appropriate deferred call. In addition, the compiler generates code to test each of the relevant bits of the defer bits flag in reverse order and make the appropriate deferred call.
  • 00:15:00 The video discusses the implementation of faster defers in Go. Open coded defers are implemented by storing the arguments and the function pointer in the stack frame group, and reading the function data at runtime. If a panic occurs during a deferred call, the runtime scans the stack for deferred frames and inserts a record for the frame in the go runtimes defer chain. The runtime then iterates through the deferred chain in the usual last in first out order and handles records for non-open code defers in the same way as before.
  • 00:20:00 In this talk, Dan Scales discusses how implementing faster defers can improve the maintainability and performance of code. He points out that the overhead of deferred calls has decreased in recent years, making them a more viable option for cases where the cost of the call itself is low.

Copyright © 2024 Summarize, LLC. All rights reserved. · Terms of Service · Privacy Policy · As an Amazon Associate, summarize.tech earns from qualifying purchases.