Microsoft`s Open Source Subsidiary Releases First Deliverable (Redis)
eweek.com
eweek.com
The memory-mapped file APIs on Windows are seriously lacking. Last time I dealt with them, there was no documented way to write to a constantly-growing mmaped file (unless you knew its size already). All the workarounds I tried ended in segfaults :/. Curious if anyone here has had success with that.
Don't you have to set the size when you map the file?
You can see an example of the technique here: http://www.gnu.org/software/libc/manual/html_node/File-Size.... (scroll to the bottom).
How do you do this technically? mremap(), I assume?
You can do something very similar on windows, by VirtualAlloc()ing at the end of the previous allocation, and if that fails, be committing, VirtualFreeing and remapping at a different address.
Yes, I agree mremap() is much cleaner. I am mostly a Linux guy myself. What I'm missing in Linux is "mremap2()", which would map an existing block of memory onto a file (whereas mmap maps an existing file onto a block of memory ). redis achieves similar functionality (and more) by fork()ing and write()ing instead, but it would be nicer if it could be done with one call and no fork()ing. a "copy this file from here to here" could then be done by mmap()ing the source into memory, mremap2()ing the memory into the destination file, and forgetting about it.
added: This would also allow btrfs/zfs to have O(1) file copy, even between independent media if possible (i.e. source file already exists on target media, even if in a different directory) - without any consideration from the cp implementation.
Yes, with ftruncate(), see the link above. The problem is Windows doesn't have an ftruncate() that works while the file is open and being written to. (Note: my memory is a little fuzzy here, it might be that there was no implementation that took a file descriptor instead of a filename, either way I couldn't pull it off). As for your 'zero-copy dump memory into a file after-the-fact' idea, I'm sure it's done somewhere. My brain is too frizzled right now to scrounge up how though :).
However, if there is a way to achieve that without forking, I would be very happy to hear.
I wonder why they hosted on Github vs Codeplex. Codeplex supports Mercurial, Team Foundation Server or Subversion and Git.
Microsoft recently posted the source for _parts_ of ASP.NET (minus web forms) on codeplex.
(just curious, not trying to troll.)
[1] here's a preview of the new look they are moving to: http://blogs.msdn.com/b/codeplex/archive/2012/03/30/new-code...