在 V8 中,执行函数的确切数量是多少? [英] After what exact number of execution function gets hot in V8?

查看:23
本文介绍了在 V8 中,执行函数的确切数量是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在学习 V8 的内部工作原理时发现有 JIT 编译器,它可以使用内联缓存技术动态优化热门函数.我只有两个问题,第一,函数只要反复执行几次就算热函数吗?其次,在 V8 中重复执行函数的确切次数是多少?

I was learning the inner workings of V8 and found out that there is JIT compiler which, on the fly, optimizes the hot functions with inline caching technique. I have only two questions, firstly, is function considered as hot function as long as it is executed repeatedly one after another several times? Secondly, after what exact number of repeated execution function gets hot in V8?

推荐答案

V8 开发人员在这里.函数热度"不仅仅是由调用它的次数决定的.相反,V8 试图通过估计执行该函数的未优化版本所花费的时间来预测优化给定函数的有用程度.其工作原理的确切启发式、考虑了哪些其他因素(例如类型反馈的完整性/稳定性)以及触发优化编译时的阈值可以并且确实会随着时间而改变.

V8 developer here. Function "hotness" is not simply determined by the number of calls to it. Instead, V8 tries to predict how useful it would be to optimize a given function by estimating the amount of time spent executing the unoptimized version of that function. The exact heuristics of how this works, which other factors are taken into account (e.g. completeness/stability of type feedback), and the threshold when optimized compilation is triggered can and do change over time.

原因是优化编译相当昂贵,因此您只希望在可能获得回报的情况下进行.(可能"是因为它特别取决于函数在未来会做多少工作,而准确预测未来当然是不可能的,所以总会涉及到一些猜测和启发.)

The reason is that optimized compilation is fairly expensive, so you'd only want to do it when it's likely to pay off. ("likely" because it depends in particular on how much work the function will do in the future, and predicting the future accurately is of course impossible, so there's always some amount of guesswork and heuristics involved.)

这篇关于在 V8 中,执行函数的确切数量是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆