关于Reduction 论文 Characterizing the Scalability of Erlang. VM on Many-core Processors 的一段解释:
Erlang schedulers are based on reduction counting as a method for measuring execution time. A reduction is roughly equivalent to a function call. Since each function call may take a different amount of time, the actual periods are not the same between different reductions. When a process is scheduled to run, it is assigned a number of reductions that it is allowed to execute (by default 2000 reductions in R13B04). The process can execute until it consumes all its reduction quantum or pauses to wait for a message. A process waiting for a message is rescheduled when a new message comes or a timer expires. Rescheduled or new processes are put to the end of corresponding run queues.Suspended (blocked) processes are not stored in the run queues.!
不过上面"A reduction is roughly equivalent to a function call."这个还是不太明确,请教了一下霸爷:
Q: Erlang的Trap机制会保证调度的公平,我有个疑问:Reduction是对应一次完整的函数调用完成么?比如 一个耗时的操作,执行过程中让出CPU时间片之后再次被调度执行Reduciton会变化么?
A:- 霸爷的回复:
公平调度实际上有3部分:
- erlang函数调用,由于erlang的代码翻译成opcode,由虚拟机执行,所以一次完整的函数调用为一个reduction. 因为erlang的函数通常都是递归执行的,所以函数体一般很小。
- bif的trap机制。简单的说就是bif会执行到大概几个reduction这样的时间片后放弃执行,把当前的执行情况记录下来,然后退出。等下次调度再执行的时候,会继续之前的位置往下。
- IO的调度。 IO也是公平调度的,把IO的处理量换算成reduction,算在宿主进程的时间片里面。
更多参考:
Erlang ERTS的Trap机制的设计及其用途 http://mryufeng.iteye.com/blog/334744
最后小图一张 这个软件现在已经停止服务了,当时的一个截图:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
2007-01-08 说唱 -- 再见大四
2007-01-08 时间过的太快了