summaryrefslogtreecommitdiff
path: root/wsd
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2020-05-02 19:13:14 +0100
committerMichael Meeks <michael.meeks@collabora.com>2020-05-02 22:03:36 +0200
commit92eff552a5fcef89a6bd0abadf19570c2f5457b8 (patch)
tree13190700447c6d8462e2bb1fbad9a01ec01f3f75 /wsd
parentfdd4b4f63ddd16679a5a7035aa14d6e02fd57fdd (diff)
Lower convert-to process priorities by default.
Interactive / editing processes should take precedence over batch thumbnailing processes to keep responsiveness good. Change-Id: Ib100409e312cb2ca545586a734711a31a92f110c Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93323 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'wsd')
-rw-r--r--wsd/DocumentBroker.cpp19
-rw-r--r--wsd/DocumentBroker.hpp13
-rw-r--r--wsd/LOOLWSD.cpp9
3 files changed, 35 insertions, 6 deletions
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 801343c63..f0e4a99df 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -172,11 +172,13 @@ public:
std::atomic<unsigned> DocumentBroker::DocBrokerId(1);
-DocumentBroker::DocumentBroker(const std::string& uri,
+DocumentBroker::DocumentBroker(ChildType type,
+ const std::string& uri,
const Poco::URI& uriPublic,
const std::string& docKey) :
_limitLifeSeconds(0),
_uriOrig(uri),
+ _type(type),
_uriPublic(uriPublic),
_docKey(docKey),
_docId(Util::encodeId(DocBrokerId++, 3)),
@@ -206,6 +208,17 @@ DocumentBroker::DocumentBroker(const std::string& uri,
"] created with docKey [" << _docKey << "]");
}
+void DocumentBroker::setupPriorities()
+{
+#if !MOBILEAPP
+ if (_type == ChildType::Batch)
+ {
+ int prio = LOOLWSD::getConfigValue<int>("per_document.batch_priority", 5);
+ Util::setProcessAndThreadPriorities(_childProcess->getPid(), prio);
+ }
+#endif // !MOBILE
+}
+
void DocumentBroker::startThread()
{
_poll->startThread();
@@ -271,6 +284,8 @@ void DocumentBroker::pollThread()
_childProcess->setDocumentBroker(shared_from_this());
LOG_INF("Doc [" << _docKey << "] attached to child [" << _childProcess->getPid() << "].");
+ setupPriorities();
+
static const bool AutoSaveEnabled = !std::getenv("LOOL_NO_AUTOSAVE");
#if !MOBILEAPP
@@ -2226,7 +2241,7 @@ ConvertToBroker::ConvertToBroker(const std::string& uri,
const std::string& docKey,
const std::string& format,
const std::string& sOptions) :
- DocumentBroker(uri, uriPublic, docKey),
+ DocumentBroker(ChildType::Batch, uri, uriPublic, docKey),
_format(format),
_sOptions(sOptions)
{
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 61f74f5a7..40784b204 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -109,7 +109,15 @@ class ClientSession;
class DocumentBroker : public std::enable_shared_from_this<DocumentBroker>
{
class DocumentBrokerPoll;
+
+ void setupPriorities();
+
public:
+ /// How to prioritize this document.
+ enum class ChildType {
+ Interactive, Batch
+ };
+
static Poco::URI sanitizeURI(const std::string& uri);
/// Returns a document-specific key based
@@ -120,7 +128,8 @@ public:
DocumentBroker();
/// Construct DocumentBroker with URI, docKey, and root path.
- DocumentBroker(const std::string& uri,
+ DocumentBroker(ChildType type,
+ const std::string& uri,
const Poco::URI& uriPublic,
const std::string& docKey);
@@ -361,6 +370,8 @@ protected:
/// Seconds to live for, or 0 forever
int64_t _limitLifeSeconds;
std::string _uriOrig;
+ /// What type are we: affects priority.
+ ChildType _type;
private:
const Poco::URI _uriPublic;
/// URL-based key. May be repeated during the lifetime of WSD.
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index dbe119067..60d3c0376 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -914,6 +914,7 @@ void LOOLWSD::initialize(Application& self)
{ "per_document.limit_stack_mem_kb", "8000" },
{ "per_document.limit_virt_mem_mb", "0" },
{ "per_document.max_concurrency", "4" },
+ { "per_document.batch_priority", "5" },
{ "per_document.redlining_as_comments", "false" },
{ "per_view.idle_timeout_secs", "900" },
{ "per_view.out_of_focus_timeout_secs", "120" },
@@ -1816,6 +1817,7 @@ std::mutex Connection::Mutex;
/// After returning a valid instance DocBrokers must be cleaned up after exceptions.
static std::shared_ptr<DocumentBroker>
findOrCreateDocBroker(const std::shared_ptr<ProtocolHandlerInterface>& proto,
+ DocumentBroker::ChildType type,
const std::string& uri,
const std::string& docKey,
const std::string& id,
@@ -1891,7 +1893,7 @@ static std::shared_ptr<DocumentBroker>
// Set the one we just created.
LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
- docBroker = std::make_shared<DocumentBroker>(uri, uriPublic, docKey);
+ docBroker = std::make_shared<DocumentBroker>(type, uri, uriPublic, docKey);
DocBrokers.emplace(docKey, docBroker);
LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after inserting [" << docKey << "].");
}
@@ -2962,7 +2964,7 @@ private:
std::shared_ptr<ProtocolHandlerInterface> none;
// Request a kit process for this doc.
std::shared_ptr<DocumentBroker> docBroker = findOrCreateDocBroker(
- none, url, docKey, _id, uriPublic);
+ none, DocumentBroker::ChildType::Interactive, url, docKey, _id, uriPublic);
std::string fullURL = request.getURI();
std::string ending = "/ws/wait";
@@ -3078,7 +3080,8 @@ private:
// Request a kit process for this doc.
std::shared_ptr<DocumentBroker> docBroker = findOrCreateDocBroker(
- std::static_pointer_cast<ProtocolHandlerInterface>(ws), url, docKey, _id, uriPublic);
+ std::static_pointer_cast<ProtocolHandlerInterface>(ws),
+ DocumentBroker::ChildType::Interactive, url, docKey, _id, uriPublic);
if (docBroker)
{
#if MOBILEAPP