我们构建了一个系统,其中视频存储在mongodb中。这些视频每个都有几百兆字节大小。该系统使用mongoengine在python3中构建。 pymongo和bson的c扩展已安装。Windows上的性能问题mongo
的mongoengine文件的定义是:
class VideoStore(Document, GeneralMixin):
video = EmbeddedDocumentListField(SingleFrame)
mutdat = DateTimeField()
_collection = 'VideoStore'
def gen_video(self):
for one_frame in self.video:
yield self._get_single_frame(one_frame)
def _get_single_frame(self, one_frame):
if one_frame.frame.tell() != 0:
one_frame.frame.seek(0)
return pickle.loads(one_frame.frame.read())
class SingleFrame(EmbeddedDocument):
frame = FileField()
阅读在Linux中的视频大约需要3到4秒。但是,在Windows中运行相同的代码需要13到17秒。
有没有人有任何有关这个问题和任何解决方案的经验?
我已经想到和测试(没有用):
- 增加CHUNKSIZE
- 读取视频作为单个斑点,而不使用收率
- 文件存储为单个斑点(所以不存储单独的帧)
这是作为Windows服务运行?你是否在Windows服务器或工作站上运行此代码?是否启用NUMA? – profesor79
两台机器上的硬件是否比较相同? Windows版本和磁盘格式类型? NTFS? – Saleem
我已经在笔记本电脑(具有普通硬盘的Windows 7 Core i7)和具有SSD的虚拟机(virtualbox Windows 10)上测试过这种行为。我不知道NUMA,我一定会试一试。 –