diff -u -r -p mythtv.100/libs/libmythtv/fileringbuffer.cpp mythtv/libs/libmythtv/fileringbuffer.cpp
|
old
|
new
|
FileRingBuffer::~FileRingBuffer()
|
| 100 | 100 | |
| 101 | 101 | if (fd2 >= 0) |
| 102 | 102 | { |
| | 103 | posix_fadvise(fd2, 0, 0, POSIX_FADV_DONTNEED); |
| 103 | 104 | close(fd2); |
| 104 | 105 | fd2 = -1; |
| 105 | 106 | } |
| … |
… |
bool FileRingBuffer::OpenFile(const QStr
|
| 252 | 253 | { |
| 253 | 254 | if (0 == lseek(fd2, 0, SEEK_SET)) |
| 254 | 255 | { |
| 255 | | posix_fadvise(fd2, 0, 0, POSIX_FADV_SEQUENTIAL); |
| 256 | | posix_fadvise(fd2, 0, 1*1024*1024, POSIX_FADV_WILLNEED); |
| | 256 | posix_fadvise(fd2, 0, 0, POSIX_FADV_SEQUENTIAL); |
| 257 | 257 | lasterror = 0; |
| 258 | 258 | break; |
| 259 | 259 | } |
| … |
… |
long long FileRingBuffer::Seek(long long
|
| 601 | 601 | else |
| 602 | 602 | { |
| 603 | 603 | ret = lseek64(fd2, internalreadpos, SEEK_SET); |
| 604 | | posix_fadvise(fd2, 0, |
| 605 | | internalreadpos, POSIX_FADV_DONTNEED); |
| 606 | | posix_fadvise(fd2, internalreadpos, |
| 607 | | 1*1024*1024, POSIX_FADV_WILLNEED); |
| 608 | 604 | } |
| 609 | 605 | VERBOSE(VB_FILE, LOC + |
| 610 | 606 | QString("Seek to %1 from ignore pos %2 returned %3") |
| … |
… |
long long FileRingBuffer::Seek(long long
|
| 687 | 683 | else |
| 688 | 684 | { |
| 689 | 685 | ret = lseek64(fd2, ignorereadpos, SEEK_SET); |
| 690 | | posix_fadvise(fd2, ignorereadpos, 250000, POSIX_FADV_WILLNEED); |
| 691 | 686 | } |
| 692 | 687 | |
| 693 | 688 | if (ret < 0) |
| … |
… |
long long FileRingBuffer::Seek(long long
|
| 752 | 747 | else |
| 753 | 748 | { |
| 754 | 749 | ret = lseek64(fd2, pos, whence); |
| 755 | | if (ret >= 0) |
| 756 | | { |
| 757 | | posix_fadvise(fd2, 0, ret, POSIX_FADV_DONTNEED); |
| 758 | | posix_fadvise(fd2, ret, 1*1024*1024, POSIX_FADV_WILLNEED); |
| 759 | | } |
| 760 | 750 | } |
| 761 | 751 | |
| 762 | 752 | if (ret >= 0) |
| 763 | 753 | { |
| 764 | 754 | readpos = ret; |
| 765 | | |
| | 755 | |
| 766 | 756 | ignorereadpos = -1; |
| 767 | 757 | |
| 768 | 758 | if (readaheadrunning) |
diff -u -r -p mythtv.100/libs/libmythtv/ringbuffer.cpp mythtv/libs/libmythtv/ringbuffer.cpp
|
old
|
new
|
void RingBuffer::run(void)
|
| 783 | 783 | { |
| 784 | 784 | poslock.lockForWrite(); |
| 785 | 785 | rbwlock.lockForWrite(); |
| | 786 | off_t read_position = internalreadpos; |
| 786 | 787 | internalreadpos += read_return; |
| 787 | | off_t donotneed = internalreadpos; |
| 788 | 788 | rbwpos = (rbwpos + read_return) % kBufferSize; |
| 789 | 789 | VERBOSE(VB_FILE|VB_EXTRA, |
| 790 | 790 | LOC + QString("rbwpos += %1K requested %2K in read") |
| … |
… |
void RingBuffer::run(void)
|
| 792 | 792 | rbwlock.unlock(); |
| 793 | 793 | poslock.unlock(); |
| 794 | 794 | |
| 795 | | if (fd2 >=0 && donotneed > 0) |
| 796 | | posix_fadvise(fd2, 0, donotneed, POSIX_FADV_DONTNEED); |
| | 795 | if (fd2 >=0) |
| | 796 | { |
| | 797 | posix_fadvise(fd2, read_position, read_return, POSIX_FADV_DONTNEED); |
| | 798 | } |
| 797 | 799 | } |
| 798 | 800 | |
| 799 | 801 | int used = kBufferSize - ReadBufFree(); |
| … |
… |
int RingBuffer::ReadDirect(void *buf, in
|
| 1017 | 1019 | else |
| 1018 | 1020 | { |
| 1019 | 1021 | lseek64(fd2, old_pos, SEEK_SET); |
| 1020 | | posix_fadvise(fd2, old_pos, 1*1024*1024, POSIX_FADV_WILLNEED); |
| 1021 | 1022 | } |
| 1022 | 1023 | } |
| 1023 | 1024 | else |
| … |
… |
int RingBuffer::ReadPriv(void *buf, int
|
| 1106 | 1107 | VERBOSE(VB_FILE|VB_EXTRA, LOC + loc_desc + |
| 1107 | 1108 | QString(": ReadDirect checksum %1") |
| 1108 | 1109 | .arg(qChecksum((char*)buf,count))); |
| | 1110 | |
| | 1111 | if (fd2 >=0 && ret > 0) |
| | 1112 | { |
| | 1113 | posix_fadvise(fd2, rbrpos, ret, POSIX_FADV_DONTNEED); |
| | 1114 | } |
| | 1115 | |
| 1109 | 1116 | rwlock.unlock(); |
| 1110 | 1117 | return ret; |
| 1111 | 1118 | } |
diff -u -r -p mythtv.100/libs/libmythtv/ThreadedFileWriter.cpp mythtv/libs/libmythtv/ThreadedFileWriter.cpp
|
old
|
new
|
ThreadedFileWriter::~ThreadedFileWriter(
|
| 217 | 217 | Flush(); |
| 218 | 218 | in_dtor = true; /* tells child thread to exit */ |
| 219 | 219 | |
| | 220 | bufferHasData.wakeAll(); |
| | 221 | pthread_join(writer, NULL); |
| | 222 | |
| 220 | 223 | bufferSyncWait.wakeAll(); |
| 221 | 224 | pthread_join(syncer, NULL); |
| 222 | 225 | |
| 223 | | bufferHasData.wakeAll(); |
| 224 | | pthread_join(writer, NULL); |
| 225 | 226 | close(fd); |
| 226 | 227 | fd = -1; |
| 227 | 228 | } |
| … |
… |
void ThreadedFileWriter::Sync(void)
|
| 385 | 386 | { |
| 386 | 387 | if (fd >= 0) |
| 387 | 388 | { |
| 388 | | /// Toss any data the kernel wrote to disk on it's own from |
| 389 | | /// the cache, so we don't get penalized for preserving it |
| 390 | | /// during the sync. |
| 391 | | (void) posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); |
| 392 | | |
| 393 | 389 | #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0 |
| 394 | 390 | // fdatasync tries to avoid updating metadata, but will in |
| 395 | 391 | // practice always update metadata if any data is written |
| … |
… |
void ThreadedFileWriter::Sync(void)
|
| 398 | 394 | #else |
| 399 | 395 | fsync(fd); |
| 400 | 396 | #endif |
| | 397 | // Toss writen data from the page cache |
| | 398 | buflock.lock(); |
| | 399 | off_t write_position = m_file_wpos; |
| | 400 | buflock.unlock(); |
| 401 | 401 | |
| 402 | | // Toss any data we just synced from cache, so we don't |
| 403 | | // get penalized for it between now and the next sync. |
| 404 | | (void) posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); |
| | 402 | posix_fadvise(fd, m_file_sync, write_position - m_file_sync, |
| | 403 | POSIX_FADV_DONTNEED); |
| | 404 | m_file_sync = write_position; |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |