标签: V8引擎

7 个内容

笔记(6)

Node.js中动态正则匹配通过`RegExp`构造函数实现,需注意转义和性能。优化策略包括缓存、防ReDoS攻击。可用于动态路由、模式组合。最佳实践包括输入验证、性能监控。V8引擎优化和WebAssembly是前沿趋势。需警惕回溯失控,注意Unicode和多行匹配。

Elliot Yang·
109 浏览

Node.js内存管理涉及V8引擎的分代垃圾回收机制,包括新生代Scavenge算法和老生代Mark-Sweep-Compact算法。手动GC应谨慎,生产环境依赖自动回收。内存泄漏需用Chrome DevTools等工具诊断,WeakRef可辅助管理。优化包括对象池、调整V8参数和利用并行/增量/并发标记。监控heap_used等指标,压力测试并拆分微服务,减少内存分配是最佳实践。未来趋势包括ML驱动的GC和异构计算内存管理。

Elliot Yang·
156 浏览

尾调用优化(TCO)通过复用栈帧避免栈溢出,但需严格模式和特定表达式/语句上下文。Safari支持完整TCO,V8因调试等问题未实现。实践中可用循环、Trampoline或Babel替代。TCO存在调试难、性能不确定等争议,需谨慎使用。

Elliot Yang·
124 浏览

本文深入解析JavaScript核心特性与最佳实践,涵盖数学运算精度、数组操作进阶、Map与Object对比、对象属性、函数式编程、迭代器与内存管理、ES新特性、调试技巧及最佳实践,旨在提升代码质量与性能。

Elliot Yang·
109 浏览

JavaScript 类型系统区分值类型和引用类型,影响内存存储和操作。通过 `typeof` 和 `instanceof` 进行类型判断,需注意其局限性。V8引擎使用隐藏类和指针标记优化类型处理。理解类型底层机制、内存管理及关注新提案,能编写更高效的 JavaScript 代码。

Elliot Yang·
93 浏览

Node.js文件读取性能分析揭示了readFileSync和readFile的性能差异。小文件同步读取利用缓存,但异步读取在高并发下存在调度延迟和GC压力。io_uring有望提升异步I/O性能。最佳策略是混合模式,并需关注未来技术发展,如V8指针压缩和PMEM。性能优化需根据具体场景选择。

Elliot Yang·
126 浏览

动态(1)

E
Elliot Yang
公开

The queueMicrotask() method, which is exposed on the Window or Worker interface, queues a microtask to be executed at a safe time prior to control returning to the browser's event loop.
First, nextTick queue is checked to get tasks for its execution, once it is exhausted, the microTasks queue is checked. After finishing the tasks in the microtask queue the process of checking nextTick and microTasks queues are repeated until the queues have been emptied.
They have different queues. The nextTick's queue is managed by node and the microtask one is managed by v8.
The nextTick queue is checked first after the current function/script execution, and then the microTask one.

浏览:142点赞:0