【发布时间】:2019-03-06 14:53:00
【问题描述】:
我有一个顺序写入能力为 1572 Mb/秒的磁盘
我有 4 个 60 fps 的摄像机。每帧没有编码,是 3.7 Mb(比方说 4 Mb)的图像。 我需要的写入速度是 4*4*60 = 960 Mb/s。
PointGrey 提供示例代码:
for (unsigned int uiCamera = 0; uiCamera < numCameras; uiCamera++)
{
error = retrieveImage(ppCameras[uiCamera], &image);
// error = ppCameras[uiCamera]->RetrieveBuffer(&image);
if (error != PGRERROR_OK)
{
PrintError(error);
cout << "Press Enter to exit." << endl;
cin.ignore();
return -1;
}
// Get the size of the buffer associated with the image, in bytes.
// Returns the size of the buffer in bytes.
iImageSize = image.GetDataSize();
// Write to the file
ardwBytesWritten[uiCamera] = writeFrameToFile(m_ALLCAMS, image);
};
在哪里:
size_t writeFrameToFile(FILE* f, Image image)
{
return fwrite(image.GetData(),
1,
image.GetCols() * image.GetRows(),
f);
}
不幸的是,我在发布模式下只能获得大约 370 - 500 Mb/s 的写入速度(根据 windows profiler)。
writeFrameToFile 是最慢的操作,在调试模式下需要 12-13 毫秒。
并行文件写入是否有意义,或者 ssd 不能在并行线程中写入?我应该使用多个 SSD 吗? 谢谢你。
【问题讨论】:
-
由于您不是直接访问 SSD 而是通过操作系统,因此您不能依赖额定的顺序写入速度。您的操作系统会将每个文件块写入 SSD 上它感到有这样做的冲动的任何块。它可能是顺序的,也可能不是顺序的,并且同时写入多个文件,写入将无处不在。
-
你能把每个相机都写到它自己的文件里吗?
-
你的操作系统是什么?
-
拍摄多长时间,用例是什么?如果它必须长时间连续,您可以考虑通过网络将文件发送到专用机器,其唯一的工作就是将它们写入磁盘。如果您的数据是突发的,您也许可以写入其中的一部分并将其余部分保存在 RAM 中。
-
@SamVarshavchik,Os 是 windows,但如果需要,我可以切换到 linux。如何通过跳过 OS SSD 管理直接录制?
标签: c++ file storage fwrite hard-drive