<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《图解Go运行时调度器》的评论</title>
	<atom:link href="http://tonybai.com/2020/03/21/illustrated-tales-of-go-runtime-scheduler/feed/" rel="self" type="application/rss+xml" />
	<link>https://tonybai.com/2020/03/21/illustrated-tales-of-go-runtime-scheduler/</link>
	<description>一个程序员的心路历程</description>
	<lastBuildDate>Fri, 17 Apr 2026 15:31:53 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2020/03/21/illustrated-tales-of-go-runtime-scheduler/#comment-7493</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Thu, 10 Sep 2020 06:09:02 +0000</pubDate>
		<guid isPermaLink="false">https://tonybai.com/?p=2875#comment-7493</guid>
		<description>所有goroutine都在等待ffmpeg命令执行完毕才会继续，你top看到的负荷数值都是多个ffmpeg工作时的负荷。</description>
		<content:encoded><![CDATA[<p>所有goroutine都在等待ffmpeg命令执行完毕才会继续，你top看到的负荷数值都是多个ffmpeg工作时的负荷。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：fastfading</title>
		<link>https://tonybai.com/2020/03/21/illustrated-tales-of-go-runtime-scheduler/#comment-7492</link>
		<dc:creator>fastfading</dc:creator>
		<pubDate>Thu, 10 Sep 2020 05:30:09 +0000</pubDate>
		<guid isPermaLink="false">https://tonybai.com/?p=2875#comment-7492</guid>
		<description>package main

import (
	&quot;os/exec&quot;
	&quot;strconv&quot;
	&quot;time&quot;
)

func main() {
	NumEl := 6
	for i := 0; i &lt; NumEl; i++ {
		go callProg(i) // &lt;--- There!
	}

	time.Sleep(12 * time.Hour)
}

func callProg(i int) {
	outstr := &quot;out&quot; + strconv.Itoa(i) + &quot;.mp4&quot;
	cmd := exec.Command(&quot;ffmpeg&quot;, &quot;-i&quot;, &quot;~/Downloads/gctest.mp4&quot;+outstr)
	cmd.Run() 
	
	do_something_else()//goroutine need to do something else after ffmpeg finish
}

func do_something_else() {
	//xxxxxx
}

/*
6个任务,  ps aux 有12个ffmpeg同时运行 ，
16核cpu
load average: 71.50, 77.63, 78.45
%Cpu(s): 48.9 us,  4.3 sy, 31.9 ni, 14.6 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st
load 都有70多了  cpu us使用率却还不高
这个是不是说明 ，  cpu 耗费在ffmpeg 的工作切换上了


上面这段代码会不会导致cpu跑不起来？  因为goroutine里面调用一个可能阻塞的命令 
该如何优化？ 
*/</description>
		<content:encoded><![CDATA[<p>package main</p>
<p>import (<br />
	“os/exec”<br />
	“strconv”<br />
	“time”<br />
)</p>
<p>func main() {<br />
	NumEl := 6<br />
	for i := 0; i &lt; NumEl; i++ {<br />
		go callProg(i) // &lt;&#8212; There!<br />
	}</p>
<p>	time.Sleep(12 * time.Hour)<br />
}</p>
<p>func callProg(i int) {<br />
	outstr := &quot;out&quot; + strconv.Itoa(i) + &quot;.mp4&quot;<br />
	cmd := exec.Command(&quot;ffmpeg&quot;, &quot;-i&quot;, &quot;~/Downloads/gctest.mp4&quot;+outstr)<br />
	cmd.Run() </p>
<p>	do_something_else()//goroutine need to do something else after ffmpeg finish<br />
}</p>
<p>func do_something_else() {<br />
	//xxxxxx<br />
}</p>
<p>/*<br />
6个任务,  ps aux 有12个ffmpeg同时运行 ，<br />
16核cpu<br />
load average: 71.50, 77.63, 78.45<br />
%Cpu(s): 48.9 us,  4.3 sy, 31.9 ni, 14.6 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st<br />
load 都有70多了  cpu us使用率却还不高<br />
这个是不是说明 ，  cpu 耗费在ffmpeg 的工作切换上了</p>
<p>上面这段代码会不会导致cpu跑不起来？  因为goroutine里面调用一个可能阻塞的命令<br />
该如何优化？<br />
*/</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：yixiao</title>
		<link>https://tonybai.com/2020/03/21/illustrated-tales-of-go-runtime-scheduler/#comment-7438</link>
		<dc:creator>yixiao</dc:creator>
		<pubDate>Wed, 15 Apr 2020 06:54:54 +0000</pubDate>
		<guid isPermaLink="false">https://tonybai.com/?p=2875#comment-7438</guid>
		<description>首先，你可以在本地跑一下这个代码，你会发现 输出顺序跟demo不一样，是乱序的，因为你的机器是多核的，也就意味着有多个p，作者或者golang.org里面是单核的只有一个p，在本地代码中添加一个runtime.GOMAXPROCS(1) 你就会的到同样的结果了。
Go每个P有一个next任务节点和一个任务队列.
新的go任务, 会替代老的next任务, 设置到next, 老的任务按照fifo顺序放到P的队列中. 
新go出来的协程内存局部性应该是最好的. 被kick掉的协程, 考虑公平是使用fifo排队.算是内存局部性和公平性之间的一个衡量.
这样能理解 10先出来了吧？</description>
		<content:encoded><![CDATA[<p>首先，你可以在本地跑一下这个代码，你会发现 输出顺序跟demo不一样，是乱序的，因为你的机器是多核的，也就意味着有多个p，作者或者golang.org里面是单核的只有一个p，在本地代码中添加一个runtime.GOMAXPROCS(1) 你就会的到同样的结果了。<br />
Go每个P有一个next任务节点和一个任务队列.<br />
新的go任务, 会替代老的next任务, 设置到next, 老的任务按照fifo顺序放到P的队列中.<br />
新go出来的协程内存局部性应该是最好的. 被kick掉的协程, 考虑公平是使用fifo排队.算是内存局部性和公平性之间的一个衡量.<br />
这样能理解 10先出来了吧？</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：xyz</title>
		<link>https://tonybai.com/2020/03/21/illustrated-tales-of-go-runtime-scheduler/#comment-7437</link>
		<dc:creator>xyz</dc:creator>
		<pubDate>Fri, 10 Apr 2020 17:57:18 +0000</pubDate>
		<guid isPermaLink="false">https://tonybai.com/?p=2875#comment-7437</guid>
		<description>请问为什么10会比1先出来</description>
		<content:encoded><![CDATA[<p>请问为什么10会比1先出来</p>
]]></content:encoded>
	</item>
</channel>
</rss>
