2018 年,Google 的一位技术主管表示,他们正在努力 "support buffers way beyond 4GiB" 在 64 位系统上使用 V8。那件事发生了吗?
In 2018 a Tech Lead at Google said they were working to "support buffers way beyond 4GiB" in V8 on 64 bit systems. Did that happen?
2018 年a Tech Lead at Google said they were working to "support buffers way beyond 4GiB" in V8 on 64 bit systems。那件事发生了吗?
正在尝试将大文件加载到缓冲区中,例如:
const fileBuffer = fs.readFileSync(csvPath);
在 Node v12.16.1 中出现错误:
RangeError [ERR_FS_FILE_TOO_LARGE]: File size (3461193224) is greater than possible Buffer: 2147483647 bytes.
在 Node v14.12.0(最新)中出现错误:
RangeError [ERR_FS_FILE_TOO_LARGE]: File size (3461193224) is greater than 2 GB
在我看来这是一个限制集,因为 32 位整数用于缓冲区寻址。但我不明白为什么这会成为 64 位系统的限制......是的我意识到我可以使用流或从特定地址的文件中读取,但我有大量的内存,而且我是限制为 2147483647 字节,因为 Node 被限制在 32 位寻址?
当然,将高频随机访问数据集的缓冲区完全加载到缓冲区而不是流式传输具有性能优势。将请求从多缓冲区替代结构中提取出来所涉及的代码将花费一些成本,无论多小...
我可以使用 --max-old-space-size=16000
标志来增加 Node 使用的最大内存,但我怀疑这是基于 V8 架构的硬限制。但是我仍然要问,因为 Google 的技术负责人确实声称他们将最大缓冲区大小增加到 4GiB 以上:2020 年是否有任何方法可以在 [=36] 中拥有超过 2147483647 字节的缓冲区=]?
通过 Google 编辑有关主题的相关跟踪器,其中 apparently they were working on fixing this since at least last year: https://bugs.chromium.org/p/v8/issues/detail?id=4153
Did that happen?
是的,现在 V8 支持非常大(许多 GB)的 ArrayBuffers。
Is there any way to have a buffer beyond 2147483647 bytes in Node.js?
是:
$ node
Welcome to Node.js v14.12.0.
Type ".help" for more information.
> let b = Buffer.alloc(3461193224)
undefined
> b.length
3461193224
也就是说,fs.readFileAsync
似乎有其自身的限制:https://github.com/nodejs/node/blob/master/lib/internal/fs/promises.js#L5
我不知道解除它需要什么。我建议您在 Node 的错误跟踪器上提交问题。
FWIW,Buffer
还有一个限制:
> let buffer = require("buffer")
undefined
> buffer.kMaxLength
4294967295
再次重申,这是 Node 的决定,而不是 V8 的决定。
2018 年a Tech Lead at Google said they were working to "support buffers way beyond 4GiB" in V8 on 64 bit systems。那件事发生了吗?
正在尝试将大文件加载到缓冲区中,例如:
const fileBuffer = fs.readFileSync(csvPath);
在 Node v12.16.1 中出现错误:
RangeError [ERR_FS_FILE_TOO_LARGE]: File size (3461193224) is greater than possible Buffer: 2147483647 bytes.
在 Node v14.12.0(最新)中出现错误:
RangeError [ERR_FS_FILE_TOO_LARGE]: File size (3461193224) is greater than 2 GB
在我看来这是一个限制集,因为 32 位整数用于缓冲区寻址。但我不明白为什么这会成为 64 位系统的限制......是的我意识到我可以使用流或从特定地址的文件中读取,但我有大量的内存,而且我是限制为 2147483647 字节,因为 Node 被限制在 32 位寻址?
当然,将高频随机访问数据集的缓冲区完全加载到缓冲区而不是流式传输具有性能优势。将请求从多缓冲区替代结构中提取出来所涉及的代码将花费一些成本,无论多小...
我可以使用 --max-old-space-size=16000
标志来增加 Node 使用的最大内存,但我怀疑这是基于 V8 架构的硬限制。但是我仍然要问,因为 Google 的技术负责人确实声称他们将最大缓冲区大小增加到 4GiB 以上:2020 年是否有任何方法可以在 [=36] 中拥有超过 2147483647 字节的缓冲区=]?
通过 Google 编辑有关主题的相关跟踪器,其中 apparently they were working on fixing this since at least last year: https://bugs.chromium.org/p/v8/issues/detail?id=4153
Did that happen?
是的,现在 V8 支持非常大(许多 GB)的 ArrayBuffers。
Is there any way to have a buffer beyond 2147483647 bytes in Node.js?
是:
$ node
Welcome to Node.js v14.12.0.
Type ".help" for more information.
> let b = Buffer.alloc(3461193224)
undefined
> b.length
3461193224
也就是说,fs.readFileAsync
似乎有其自身的限制:https://github.com/nodejs/node/blob/master/lib/internal/fs/promises.js#L5
我不知道解除它需要什么。我建议您在 Node 的错误跟踪器上提交问题。
FWIW,Buffer
还有一个限制:
> let buffer = require("buffer")
undefined
> buffer.kMaxLength
4294967295
再次重申,这是 Node 的决定,而不是 V8 的决定。