gpt4 book ai didi

fork 的 Redis 延迟

转载 作者:可可西里 更新时间:2023-11-01 11:31:40 26 4
gpt4 key购买 nike

我从这个链接阅读了以下段落:http://redis.io/topics/latency

For instance on a Linux/AMD64 system, the memory is divided in 4 kB pages. To convert virtual addresses to physical addresses, each process stores a page table (actually represented as a tree) containing at least a pointer per page of the address space of the process. So a large 24 GB Redis instance requires a page table of 24 GB / 4 kB * 8 = 48 MB.

When a background save is performed, this instance will have to be forked, which will involve allocating and copying 48 MB of memory. It takes time and CPU, especially on virtual machines where allocation and initialization of a large memory chunk can be expensive.

请帮我解释一下:1、页表计算内存时为什么要乘以8。2.据我所知,当Redis持久化时,它会将内存中的所有数据集保存到磁盘。为什么在这个文档中说,它只是将页表保存到磁盘。

最佳答案

  1. Why do we multiple by 8 when calculate the memory for page table.

正如文档所说,一个页表至少包含一个指针。在 Linux/AMD64 系统上,一个指针占用 8 个字节。所以你需要乘以 8 才能得到页表的大小。

  1. As I know, when Redis is persitent, it will save all dataset in it's memory to disk. Why in this document said, it's only save page table to disk.

文档没有说只保存页表。相反,它告诉你在做后台保存时,Redis 必须做一次 fork,而 fork 操作必须复制页表。

Redis 确实将所有数据保存到磁盘。它不会将页表保存到磁盘。

关于 fork 的 Redis 延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39585639/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com