From: Eleanor McHugh Date: 2009-11-09T22:06:19+09:00 Subject: Re: FileString - request for comments On 9 Nov 2009, at 13:54, apeiros@gmx.net wrote: > Hi Joel > >> What would the advantage over mmap[1] be? FileString is pure ruby >> (right?) and hence more portable, but probably mmap is much more >> efficient? Any other tradeoffs? > > Interesting, I was looking if a solution existed already and didn't > find mmap. Yes, FileString is pure ruby and should therefore run on > all ruby implementations. And yes, I'd expect mmap to be more > efficient on the other hand. It'd be interesting to combine the two > (if that's at all possible). > In a quick test it seems FileString is more complete too, e.g. Mmap > doesn't have #replace (should be trivial to add). But Mmap has the > feature to only tie a part of the file. It would probably be fairly trivial for you to directly support mmap at the OS level using Ruby/DL, Ruby-FFI or even syscall (although that's ugly and fragile). Take a look at some of my Plumber's Guide presentations at the link in my signature and also at http://kenai.com/projects/ruby-ffi for details of how to wrap these kinds of system calls such that they'll run identically on JRuby, Rubinius and MRI. Ellie Eleanor McHugh Games With Brains http://slides.games-with-brains.net ---- raise ArgumentError unless @reality.responds_to? :reason