background picture of the home page

当go程序启动时会启动哪些协程 --runtime.main剖析

一句话:go启动时会启动调度器协程,通过init函数启动forcegchelper ,即GC协程,从main函数中启动了sysmon线程(以一个不受P调度的M的形式存在),启动了bgscavenge和bgsweep 协程用于清理内存。 这是runtime.main的代码剖析,但是也带着我的一些疑问。

thumbnail of the cover of the post

一些零碎的脚本

1panel更新 国内 # bash <(wget -qO- --no-check-certificate https://fastly.jsdelivr.net/gh/okxlin/ToolScript@main/1Panel/1panel-upgrade/1panel-upgrade.sh) #

thumbnail of the cover of the post

go中的开放编码方式defer与panic open-coded defers and panic

它是什么? 一句话:一个在编译时优化defer的方式。 Go1.14引入了开放编码方式实现defer,实现了近乎零成本的 defer 调用,当没有设置-N禁用内联、 defer 函数个数和返回值个数乘积不超过 15 个、defer 函数个数不超过 8 个、且defer没有出现在循环语句中时,会使用此

thumbnail of the cover of the post