❎This document outlines best practices for writing high-performance Go code.
❎مقالهای در مورد بهترین کارها برای نوشتن یک کد با performance بالا برای زبان برنامهنویسی Go
#golang #go #performance #optimization
https://github.com/dgryski/go-perfbook
☄ @gopher_academy
❎مقالهای در مورد بهترین کارها برای نوشتن یک کد با performance بالا برای زبان برنامهنویسی Go
#golang #go #performance #optimization
https://github.com/dgryski/go-perfbook
☄ @gopher_academy
GitHub
GitHub - dgryski/go-perfbook: Thoughts on Go performance optimization
Thoughts on Go performance optimization. Contribute to dgryski/go-perfbook development by creating an account on GitHub.
🔵Using regexp.Match or related in a loop
🔴 #Performance
🟢Compile parses a regular expression and returns, if successful, a Regexp object that can be used to match against text.
When matching in a loop, use regexp.Compile instead.
➖➖➖➖➖➖➖➖➖
🕊 @gopher_academy
🔴 #Performance
🟢Compile parses a regular expression and returns, if successful, a Regexp object that can be used to match against text.
When matching in a loop, use regexp.Compile instead.
➖➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍5
🔵Function params involve heavy amount of copying
🟢When a param big in size (more than 80 bytes) is passed to another function, it is better to pass a pointer to the value around, rather than the value itself.
#Performance
➖➖➖➖➖➖➖➖➖
🕊 @gopher_academy
🟢When a param big in size (more than 80 bytes) is passed to another function, it is better to pass a pointer to the value around, rather than the value itself.
#Performance
➖➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍9❤1🔥1
🔵Multiple append can be combined into a single call
🟢Multiple calls for append could be combined into a single call for append.
The append built-in function appends elements to the end of a slice. If it has sufficient capacity, the destination is resliced to accommodate the new elements, but if capacity is not enough, then append will allocate a new underlying array and return the updated slice. Therefore, it is necessary to store the result of append, often in the variable holding the slice itself. Appending calls in a single call of append allocates memory just once to accommodate all the elements to be appended. Whereas multiple calls to append introduce many overheads, most notably being the possibility of more calls for memory allocation because the total number of elements to be appended over multiple calls of append is unknown beforehand, resulting in inaccurate preallocation.
🔴 https://go.dev/blog/slices#TOC_9.
#Performance
➖➖➖➖➖➖➖➖➖
🕊 @gopher_academy
🟢Multiple calls for append could be combined into a single call for append.
The append built-in function appends elements to the end of a slice. If it has sufficient capacity, the destination is resliced to accommodate the new elements, but if capacity is not enough, then append will allocate a new underlying array and return the updated slice. Therefore, it is necessary to store the result of append, often in the variable holding the slice itself. Appending calls in a single call of append allocates memory just once to accommodate all the elements to be appended. Whereas multiple calls to append introduce many overheads, most notably being the possibility of more calls for memory allocation because the total number of elements to be appended over multiple calls of append is unknown beforehand, resulting in inaccurate preallocation.
🔴 https://go.dev/blog/slices#TOC_9.
#Performance
➖➖➖➖➖➖➖➖➖
🕊 @gopher_academy
👍9❤1🔥1
نکته خیلی جالبش شاید استفاده از GOMEMLIMIT بصورت dynamic هست که در runtime ست میشه..
Go Beyond: Building Performant and Reliable Golang Applications
https://blog.zomato.com/go-beyond-building-performant-and-reliable-golang-applications
✍️حسین نظری
#performance
#golang
#گولنگ
➖➖➖➖➖➖➖➖
👑 @gopher_academy
Go Beyond: Building Performant and Reliable Golang Applications
https://blog.zomato.com/go-beyond-building-performant-and-reliable-golang-applications
✍️حسین نظری
#performance
#golang
#گولنگ
➖➖➖➖➖➖➖➖
👑 @gopher_academy
💋1