avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • Resume
  • Archives
  • Categories
  • Photos
  • Music



{{ date }}

{{ time }}

avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • 主页
  • Resume
  • Archives
  • Categories
  • Photos
  • Music

Inline expansion

  2024-01-01        
字数统计: 340字   |   阅读时长: 2min

9021Everyone is running for time,This happens to be$algorithm$Essence of development。

screenshot2023-10-08 afternoon11.35.38.png

“There is a bunch of functions of code and code without function calls,Which runs faster?”

Let’s talk about conclusions first:The code without function call runs faster。butreadabilityworse,andThe gap between running speed is not large。

We can ask the following questions:

  1. Why does the frequency call of the function cause a decline in performance?
  2. How to solve the decline in this performance?
  3. What is the Internal Union Extension?

Why does the frequency call of the function cause a decline in performance?

Function calls usually involve pressing the parameters into the stack、Jump to function code、Execute function code、Put the return value in the appropriate position、Then jump back to the place where the call function。

How to solve the decline in this performance?

Tailing recursive optimization、Dead code elimination、Constant communication and constant folding、Internal United Development, etc.。This chapter mainly talks about the expansion of the Internal United Nations。

What is the Internal Union Extension

Wikipedia:

Inline expansion is used to eliminate the time overhead (excess time) when a function is called. It is typically used for functions that execute frequently. It also has a space benefit for very small functions, and is an enabling transformation for other optimizations.
Internal expansion is used to eliminate the time overhead of the call function(Excess time)。It is usually used for frequent execution functions。For very small functions,It also has space advantages,And it is a conversion that supports other optimizations。

Frequent calling functions may cause some additional overhead,This overhead is due to the stack operation when the function calls、Factors caused by parameter transmission and return value processing。

To avoid this overhead,The compiler will try to replace the code of the function call to the function body,This process is called the Inner Union Extension(inline expansion)。

ref:
https://www.jstage.jst.go.jp/article/sptj1978/44/3/44_3_206/_pdf

https://www.semanticscholar.org/search?q=Inline%20expansion&sort=relevance

  • Composition principle

扫一扫,分享到微信

微信分享二维码
GOlanguage# GOlanguage可爱捏
math
目录
  1. 1. Why does the frequency call of the function cause a decline in performance?
  2. 2. How to solve the decline in this performance?
  3. 3. What is the Internal Union Extension

150 篇 | 131.7k
次 | 人
这里自动载入天数这里自动载入时分秒
2022-2025 loong loong | 新南威尔士龙龙号