开发者

How to improve general i/o to be on par with file mapping

File mapping is great, but for comparatively large files on 32-bit system one should forget about it and implement everything with general file i/o. For large random reads and write the system cache works almost as good as file mapping. But for small operations around small file areas the difference is huge, file i/o is ten开发者_如何学Go times slower than the equivalent actions for file-mapping files. The latter mostly because of multiply calls for SetFilePointer, ReadFile, WriteFile even for several small actions.

So I would like to implement or use some kind of cache (or maybe some trick) that should work effectively for small reads/writes but I don't need some complex one since for large operations Windows is doing a great job. Is there some known approach to this?

Thanks

Max


Replying to my own question for other to consider similar approach in the future

Looks like the best is to support multiply buffered mapped views on the file. In this case an array allows fast access to pointers to memory blocks (vies) and if the pointer calculated based on a requested offset is valid, then one should just access the data, if not - then allocate new view optionally keeping total number of views to certain limit. I implemented this comparatively quickly for both reading and writing and the results are very promising

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜