复制时使用的理想内存块大小是多少? [英] What is the ideal memory block size to use when copying?

查看:134
本文介绍了复制时使用的理想内存块大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用每个内存块100 MB来复制大型文件。

I am currently using 100 megabytes per memory block to copy large files.

人们通常使用的好数量是多少?

Is there a "good" amount that people normally use?

编辑

感谢所有伟大的回应。

我对这些概念还是很新的,所以我将尝试理解很多已经说过的(例如回写缓存)。我不断学习新的东西:)

I'm still quite new to these concepts so I'll try to understand a lot of the ones that have been said (e.g. write back cache). I keep learning new things :)

推荐答案

4096和32KB之间的块是典型的选择。使用100MB是反作用的。您正在占用RAM缓冲区,可以更好地用作文件系统回写缓存。

A block between 4096 and 32KB is the typical choice. Using 100MB is counter-productive. You are occupying RAM with the buffer that can be put to much better use as the file system writeback cache.

复制文件非常快该文件完全适合缓存,WriteFile()调用是一个简单的内存到内存的副本。然后缓存管理器会将它写入磁盘。但是当缓存中没有更多的空间时,当WriteFile()必须等待空间可用时,复制速度会下降。现在它以磁盘写入速度。

Copying files is very fast when the file fits completely in the cache, the WriteFile() call is a simple memory-to-memory copy. The cache manager then lazily writes it out to the disk. But when there's no more room in the cache, the copy speed drops off a cliff when WriteFile() has to wait for space to be made available. It now goes at disk write speeds.

这篇关于复制时使用的理想内存块大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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