From 1aa42f2df9a9148d3a79e17694381de873557fce Mon Sep 17 00:00:00 2001 From: Denis <146707790+dnzbk@users.noreply.github.com> Date: Wed, 8 Nov 2023 09:39:27 +0000 Subject: [PATCH] Feature/article read chunk size (#52) * Added ArticleReadChunkSize config option which allows to adjust the buffer size for customization on different platforms, which can lead to increased performance. --- daemon/main/Options.cpp | 3 +++ daemon/main/Options.h | 2 ++ daemon/nntp/ArticleDownloader.cpp | 2 +- nzbget.conf | 3 +++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/daemon/main/Options.cpp b/daemon/main/Options.cpp index 5fc8c7fc8..38870473f 100644 --- a/daemon/main/Options.cpp +++ b/daemon/main/Options.cpp @@ -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"; @@ -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"); @@ -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); diff --git a/daemon/main/Options.h b/daemon/main/Options.h index ad7fbc214..b59c69cd5 100644 --- a/daemon/main/Options.h +++ b/daemon/main/Options.h @@ -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; }; @@ -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; diff --git a/daemon/nntp/ArticleDownloader.cpp b/daemon/nntp/ArticleDownloader.cpp index 1efbeaa3a..67bd79fa0 100644 --- a/daemon/nntp/ArticleDownloader.cpp +++ b/daemon/nntp/ArticleDownloader.cpp @@ -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()) { diff --git a/nzbget.conf b/nzbget.conf index f870420e8..3c86a4a3f 100644 --- a/nzbget.conf +++ b/nzbget.conf @@ -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