Changeset 7801


Ignore:
Timestamp:
Jan 26, 2009, 12:36:34 AM (12 years ago)
Author:
charles
Message:

(trunk libT) fsync busy files every 15 seconds or so. On linux, use posix_fadvise() to tell the system no to cache torrent blocks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r7800 r7801  
    8080    NOFILE_BUFFER = 512, /* the process' number of open files is
    8181                            globalMaxPeers + NOFILE_BUFFER */
     82
     83    SYNC_INTERVAL = 15   /* (arbitrary number) how many seconds to go
     84                            between fsync calls for files in heavy use */
    8285};
    8386
     
    9093    int        fd;
    9194    uint64_t   date;
     95    time_t     syncAt;
    9296};
    9397
     
    388392        else
    389393        {
    390             dbgmsg(
    391                 "everything's full!  waiting for someone else to finish something" );
     394            dbgmsg( "everything's full!  waiting for someone else to finish something" );
    392395            tr_lockUnlock( gFd->lock );
    393396            tr_wait( 200 );
     
    411414        tr_strlcpy( o->filename, filename, sizeof( o->filename ) );
    412415        o->isWritable = doWrite;
     416        o->syncAt = time( NULL ) + SYNC_INTERVAL;
    413417    }
    414418
     
    438442        if( o->closeWhenDone )
    439443            TrCloseFile( i );
     444        else if( o->syncAt <= time( NULL ) ) {
     445            dbgmsg( "fsync()ing file '%s' in slot #%d", o->filename, i );
     446            fsync( o->fd );
     447#ifdef HAVE_POSIX_FADVISE
     448            /* TODO: test performance with and without this */
     449            posix_fadvise( o->fd, 0, 0, POSIX_FADV_DONTNEED );
     450#endif
     451            o->syncAt = time( NULL ) + SYNC_INTERVAL;
     452        }
    440453
    441454        break;
Note: See TracChangeset for help on using the changeset viewer.