Skip to content

Commit

Permalink
Feature/article read chunk size (#52)
Browse files Browse the repository at this point in the history
* Added ArticleReadChunkSize config option which allows to adjust the buffer size for customization on different platforms, which can lead to increased performance.
  • Loading branch information
dnzbk authored Nov 8, 2023
1 parent 885058f commit 1aa42f2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions daemon/main/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static const char* OPTION_CERTSTORE = "CertStore";
static const char* OPTION_CERTCHECK = "CertCheck";
static const char* OPTION_AUTHORIZEDIP = "AuthorizedIP";
static const char* OPTION_ARTICLETIMEOUT = "ArticleTimeout";
static const char* OPTION_ARTICLEREADCHUNKSIZE = "ArticleReadChunkSize";
static const char* OPTION_URLTIMEOUT = "UrlTimeout";
static const char* OPTION_REMOTETIMEOUT = "RemoteTimeout";
static const char* OPTION_FLUSHQUEUE = "FlushQueue";
Expand Down Expand Up @@ -447,6 +448,7 @@ void Options::InitDefaults()
SetOption(OPTION_CERTCHECK, "no");
SetOption(OPTION_AUTHORIZEDIP, "");
SetOption(OPTION_ARTICLETIMEOUT, "60");
SetOption(OPTION_ARTICLEREADCHUNKSIZE, "4");
SetOption(OPTION_URLTIMEOUT, "60");
SetOption(OPTION_REMOTETIMEOUT, "90");
SetOption(OPTION_FLUSHQUEUE, "yes");
Expand Down Expand Up @@ -694,6 +696,7 @@ void Options::InitOptions()

m_downloadRate = ParseIntValue(OPTION_DOWNLOADRATE, 10) * 1024;
m_articleTimeout = ParseIntValue(OPTION_ARTICLETIMEOUT, 10);
m_articleReadChunkSize = ParseIntValue(OPTION_ARTICLEREADCHUNKSIZE, 10) * 1024;
m_urlTimeout = ParseIntValue(OPTION_URLTIMEOUT, 10);
m_remoteTimeout = ParseIntValue(OPTION_REMOTETIMEOUT, 10);
m_articleRetries = ParseIntValue(OPTION_ARTICLERETRIES, 10);
Expand Down
2 changes: 2 additions & 0 deletions daemon/main/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class Options
EMessageTarget GetDebugTarget() const { return m_debugTarget; }
EMessageTarget GetDetailTarget() const { return m_detailTarget; }
int GetArticleTimeout() { return m_articleTimeout; }
int GetArticleReadChunkSize() { return m_articleReadChunkSize; }
int GetUrlTimeout() { return m_urlTimeout; }
int GetRemoteTimeout() { return m_remoteTimeout; }
bool GetRawArticle() { return m_rawArticle; };
Expand Down Expand Up @@ -345,6 +346,7 @@ class Options
bool m_rawArticle = false;
bool m_nzbLog = false;
int m_articleTimeout = 0;
int m_articleReadChunkSize = 4;
int m_urlTimeout = 0;
int m_remoteTimeout = 0;
bool m_appendCategoryDir = false;
Expand Down
2 changes: 1 addition & 1 deletion daemon/nntp/ArticleDownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ ArticleDownloader::EStatus ArticleDownloader::Download()
m_decoder.SetRawMode(g_Options->GetRawArticle());

status = adRunning;
CharBuffer lineBuf(1024*4);
CharBuffer lineBuf(g_Options->GetArticleReadChunkSize());

while (!IsStopped() && !m_decoder.GetEof())
{
Expand Down
3 changes: 3 additions & 0 deletions nzbget.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,9 @@ ArticleInterval=10
# Connection timeout for article downloading (seconds).
ArticleTimeout=60

# Chunk size when reading data from the news server (kilobytes).
ArticleReadChunkSize=4

# Number of download attempts for URL fetching (0-99).
#
# If fetching of nzb-file via URL or fetching of RSS feed fails another
Expand Down

0 comments on commit 1aa42f2

Please sign in to comment.