Skip to content

Commit

Permalink
[nfs] - add readahead support - use advanced settings nfsreadaheadthr…
Browse files Browse the repository at this point in the history
…eshold (default files > 50mb get readahead) and nfsreadaheadbytes (default 1MB readahead) - has to go into network section of advancedsettings.xml
  • Loading branch information
Memphiz committed Feb 4, 2015
1 parent ee2bae8 commit c9841fb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xbmc/filesystem/DllLibNfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class DllLibNfsInterface
virtual int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf)=0;
virtual int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf)=0;
virtual int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, int whence, uint64_t *current_offset)=0;
virtual void nfs_set_readahead(struct nfs_context *nfs, uint32_t v)=0;
};

class DllLibNfs : public DllDynamic, DllLibNfsInterface
Expand All @@ -105,7 +106,8 @@ class DllLibNfs : public DllDynamic, DllLibNfsInterface
DEFINE_METHOD2(int, nfs_rmdir, (struct nfs_context *p1, const char *p2))
DEFINE_METHOD2(int, nfs_unlink, (struct nfs_context *p1, const char *p2))
DEFINE_METHOD2(void,nfs_closedir, (struct nfs_context *p1, struct nfsdir *p2))
DEFINE_METHOD2(int, nfs_close, (struct nfs_context *p1, struct nfsfh *p2))
DEFINE_METHOD2(int, nfs_close, (struct nfs_context *p1, struct nfsfh *p2))
DEFINE_METHOD2(void, nfs_set_readahead, (struct nfs_context *p1, uint32_t p2))
DEFINE_METHOD3(int, nfs_mount, (struct nfs_context *p1, const char *p2, const char *p3))
DEFINE_METHOD3(int, nfs_stat, (struct nfs_context *p1, const char *p2, NFSSTAT *p3))
DEFINE_METHOD3(int, nfs_fstat, (struct nfs_context *p1, struct nfsfh *p2, NFSSTAT *p3))
Expand Down Expand Up @@ -175,7 +177,8 @@ class DllLibNfs : public DllDynamic, DllLibNfsInterface
RESOLVE_METHOD_RENAME(nfs_access, nfs_access)
RESOLVE_METHOD_RENAME(nfs_symlink, nfs_symlink)
RESOLVE_METHOD_RENAME(nfs_rename, nfs_rename)
RESOLVE_METHOD_RENAME(nfs_link, nfs_link)
RESOLVE_METHOD_RENAME(nfs_link, nfs_link)
RESOLVE_METHOD_RENAME(nfs_set_readahead, nfs_set_readahead)
END_METHOD_RESOLVE()
};

5 changes: 5 additions & 0 deletions xbmc/filesystem/NFSFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "utils/StringUtils.h"
#include "network/DNSNameCache.h"
#include "threads/SystemClock.h"
#include "settings/AdvancedSettings.h"

#include <nfsc/libnfs-raw-mount.h>

Expand Down Expand Up @@ -572,6 +573,10 @@ bool CNFSFile::Open(const CURL& url)
}

m_fileSize = tmpBuffer.st_size;//cache the size of this file
if (m_fileSize > g_advancedSettings.m_nfsReadAheadThreshold)// files bigger then threshold will enable readahead
{
gNfsConnection.GetImpl()->nfs_set_readahead(m_pNfsContext, g_advancedSettings.m_nfsReadAheadBytes);
}
// We've successfully opened the file!
return true;
}
Expand Down
4 changes: 4 additions & 0 deletions xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ void CAdvancedSettings::Initialize()
// the following setting determines the readRate of a player data
// as multiply of the default data read rate
m_readBufferFactor = 1.0f;
m_nfsReadAheadThreshold = 52428800;//50MB
m_nfsReadAheadBytes = 1048576;//1MB
m_addonPackageFolderSize = 200;

m_jsonOutputCompact = true;
Expand Down Expand Up @@ -803,6 +805,8 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
XMLUtils::GetUInt(pElement, "cachemembuffersize", m_cacheMemBufferSize);
XMLUtils::GetUInt(pElement, "buffermode", m_networkBufferMode, 0, 3);
XMLUtils::GetFloat(pElement, "readbufferfactor", m_readBufferFactor);
XMLUtils::GetLong(pElement, "nfsreadaheadthreshold", m_nfsReadAheadThreshold);
XMLUtils::GetLong(pElement, "nfsreadaheadbytes", m_nfsReadAheadBytes);
}

pElement = pRootElement->FirstChildElement("jsonrpc");
Expand Down
2 changes: 2 additions & 0 deletions xbmc/settings/AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
unsigned int m_cacheMemBufferSize;
unsigned int m_networkBufferMode;
float m_readBufferFactor;
long m_nfsReadAheadThreshold;
long m_nfsReadAheadBytes;

bool m_jsonOutputCompact;
unsigned int m_jsonTcpPort;
Expand Down

0 comments on commit c9841fb

Please sign in to comment.