结构化存储

发布于 2024-09-01 18:16:41 字数 117 浏览 11 评论 0原文

我有一个结构化存储格式的文件。 我想知道这种格式是否可以由线程同时访问。

意思是让多个线程读取不同的流同时处理它。目的是更快地加载文件。

当我引用文件时,我指的是代表 CAD 信息的文件。

I have a file that is in structured storage format.
I was wondering if this format be accessed concurrently by threads.

Meaning have multiple threads read the different streams process it at once. The objective is to load the file faster.

When i refer to a file i refer one that represents CAD information.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟花肆意 2024-09-08 18:16:41

线程的问题总是归结为共享资源。定义将共享哪些资源,然后确定是否可以以并行进行大块处理的方式共享这些资源。

如果您要从文件开头的目录构建许多小型独立数据结构,则它可能会受益于线程。每个线程都知道要读取文件的哪一部分以及如何处理所读取的数据,而与其他线程无关,而无需与其他线程交互。

如果您正在构建相关数据结构的大型树或层次结构,或者如果下一位数据的位置取决于前一位数据,则​​可能会有多个线程相互绑定等待。您仍然可能受益于一个线程读取数据块并将其排队以供另一个线程处理。

您很可能会在上述示例之间取得一些平衡。您可能有一个文件读取器线程和一小组处理线程。处理线程可能会将结果排队以供单个组装线程组织成任何层次结构或关系。

如果您有相互等待的线程,那么您就不需要线程。如果您有可以自动添加到队列中进行处理的独立数据块,那么线程就会大放异彩。

根据外部性,线程可能会以微妙的方式相互干扰。例如,多个读取线程可能会导致硬盘驱动器的寻道时间增加,从而导致净性能损失。

The question with threads always boils down to sharing resources. Define what resources will be shared, and then figure out if they can be shared in such a way that big chunks of processing can happen in parallel.

If you are building a lot of small independent data structures from a table of contents at the beginning of the file, it could benefit from threads. Each thread would know, independent of the other threads, what part of the file to read and what to do with the data it read, without interacting with other threads.

If you are building a large tree or hierarchy of related data structures, or if the location of the next bit of data depends on the previous bit of data, then more than a few threads could get bound up waiting for each other. You still might benefit from one thread that reads and queues up chunks of data for another thread to process.

Most likely you will have some balance between the above examples. You might have one file reader thread and a small pool of processing threads. The processing threads might queue up results for a single assembling thread to organize into whatever hierarchy or relationships there are.

If you have threads waiting for each other, then you did not need a thread. If you have independent chunks of data that can be atomically added to queues for processing, then threads get to shine.

Depending on externalities, threads can interfere with each other in subtle ways. For example, multiple read threads can cause more seek time for hard drives, resulting in a net performance loss.

我一向站在原地 2024-09-08 18:16:41

简单的答案是肯定的。

更长的答案是结构化存储是 COM 的一部分,COM 线程模型(有时称为单元模型)与 Win32 线程模型不同,并且有自己的规则和 API 用于跨单元编组数据。

在开始之前,问问自己您的存储机制是否真的必须是结构化存储...在我看来,除了一个痛苦的世界(线程方面)之外,它并没有给您带来太多超过标准 IO 的东西。

实际的结构化部分非常基本,并且可以是任何 XML文件更加结构化。

The simple answer is yes.

The longer answer is Structured Storage is part of COM and the COM threading model (sometimes called the Apartment model) is different to the Win32 threading model and has its own rules and API for marshalling data across apartments.

Before you embark on this, ask yourself if your storage mechanism really has to be structured storage...IMO it does not give you much over standard IO except a world of hurt (threading wise)

The actual structured part is pretty basic and any XML file is far more structured.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文