5 ms·
Using pread would have been more work from the start but provides a more robust solution and doesn't have problems on Windows. I would argue that the incrementa
by ben-schaaf 8y ago
Using pread would have been more work from the start but provides a more robust solution and doesn't have problems on Windows. I would argue that the incrementaly built mmap based solution is strictly worse, thus difficult to justify doing again.
- eeZah7Ux 8y ago"strictly worse" despite no-copy memory access? Again, this needs proof.
- ben-schaaf 8y agoStrictly worse because it requires more work to maintain and write new code, there's no guarantee we haven't missed any access points in our codebase so it is less robust, still locks files while in use on Windows and requires maintaining patches to Breakpad. Performance is not an issue here, the program working correctly is, and doing so in the long run is strictly worse than mmap.
- superlopuh 8y agoDo you have a list of these strictly-better things to do and a plan on when to implement them? Do you let them pile up? Mostly asking about your decision-making process.
- ben-schaaf 8y agoI'm not sure what you mean. The blog post discusses solutions to all the problems I listed. They wouldn't have been problems using pread, which has a straight forward implementation.
- iainmerrick 8y agoThe original post quantifies it. Around 50% better performance for the mmap version. They are saying that if they somehow knew up front what the performance gains would be, and what the cost in bugs and complexity would be, they wouldn’t have used mmap at all.
- eeZah7Ux 8y ago"some quick benchmarks for the way Sublime Merge reads git object files" is in not strong evidence.
- iainmerrick 8y agoI can’t tell what answer you’re looking for here. You said above that “mmap allows reading and writing large data structures without copying, which can be a huge benefit depending on the use case.” Yes, of course that’s true, and the Sublime Text authors are clearly well aware it’s true. That’s why they decided to use mmap in the first place. They agreed with you. This is them reporting, with hindsight, that for their use case mmap introduced a lot of tricky bugs that required complex platform-dependent fixes, and that the performance gains were real but modest. Therefore, in hindsight, it probably wasn’t a good choice. Which part are you arguing with?