News for hackers. Stuff that matters.
Re:fatcache - Memcache on SSD by peter_l_downs on Monday February 11, 2013 @03:53PM (#5203134)
Just to further illustrate your point, the relevant section from the readme file:

    There have been attempts to use an SSD as a swap layer to implement SSD-backed
    memory. This method degrades write performance and SSD lifetime with many small,
    random writes. Similar issues occur when an SSD is simply mmaped.
    
    To minimize the number of small, random writes, fatcache treats the SSD as a
    log-structured object store. All writes are aggregated in memory and written to
    the end of the circular log in batches - usually multiples of 1 MB.
Re:fatcache - Memcache on SSD by sigil on Monday February 11, 2013 @04:06PM (#5203227)
It would be trivial to batch writes to the mmap'ed region. Reads would still benefit from OS caching.
Re:fatcache - Memcache on SSD by riobard on Monday February 11, 2013 @04:16PM (#5203295)
How do you batch writes to mmap-ed region?
Re:fatcache - Memcache on SSD by hosay123 on Monday February 11, 2013 @04:18PM (#5203308)

    ptr = mmap(..., len, ..)
    /* do stuff with ptr */
    msync(ptr, len)
No sane OS will pay attention to an mmapped region while it isn't under memory pressure, so dirty pages are effectively buffered until you explicitly tell the OS to start writeback.
Re:fatcache - Memcache on SSD by otterley on Monday February 11, 2013 @05:22PM (#5203735)
Linux flushes dirty pages in mmapped regions to disk every 30 seconds by default whether you like it or not (see vm.dirty_expire_centisecs). Unlike FreeBSD, Linux doesn't yet have support for the MAP_NOSYNC flag to mmap(2).
Re:fatcache - Memcache on SSD by hosay123 on Monday February 11, 2013 @05:32PM (#5203805)
Good point, though I think for a machine averaging even 40mb/sec this only amounts to one 'batch' every 1.2gb receiving an extra sync. Linux recently changed so that pdflush doesn't exist at all, when the dirty list fills, a per-device thread is created that sleeps for 5 seconds before starting work, so maybe it's a bit less than 1.2gb.
Re:fatcache - Memcache on SSD by riobard on Monday February 11, 2013 @11:29PM (#5205184)
Does this mean that I have to msync multiple mmap'ed chunks in order to batch write? For example

    msync(ptr1, len1)
    msync(ptr2, len2)
    msync(ptr3, len3)
Where [ptr1, ptr1+len1], [ptr2, ptr2+len2], ... are the chunks within a big mmap'ed region where changes occur and need to be written to disk for persistence.

Or do I just msync the whole region then hope and pray that the OS will do the right thing?