mergerfs/src/config_qos.hpp
Grioghar 5f6275baea qos: match on cmdline, and never throttle critical dependencies
Two gaps found while using this against a real media server.

Some programs do very different jobs under one name. Plex runs credits
detection with the same 'Plex Transcoder' binary that serves playback,
reading the same file, so neither comm nor path separates them. Adds a
cmdline match field, and quoting so a pattern can contain spaces --
without which 'Plex Transcoder' cannot be written down at all.

Adds a 'critical' class flag for services playback synchronously waits
on. Plex's EasyAudioEncoder is the case: a transcode of EAC3 audio
writes to EAE and blocks. Such a helper looks like background work, so
a governor protecting playback will throttle or suspend it and hang the
stream waiting behind it. A critical class is never delayed.

Also fixes qos.max-sleepers auto-sizing, which read the requested
thread count rather than the resolved one and so capped at 1.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 17:21:57 -05:00

96 lines
2.4 KiB
C++

/*
ISC License
Copyright (c) 2026, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "tofrom_string.hpp"
// qos=<bool>
class QoS : public ToFromString
{
public:
QoS(const bool);
public:
std::string to_string(void) const final;
int from_string(const std::string_view) final;
};
// qos.rules=<filepath>
//
// Assigning a path loads it. Assigning the same path again is how a
// ruleset is reloaded at runtime. A file that fails to parse leaves
// the running ruleset in place.
class QoSRules : public ToFromString
{
public:
std::string to_string(void) const final;
int from_string(const std::string_view) final;
};
// qos.ruleset -- read only, the ruleset as parsed.
class QoSRuleSet : public ToFromString
{
public:
QoSRuleSet();
public:
std::string to_string(void) const final;
int from_string(const std::string_view) final;
};
// qos.stats -- counters. Assigning "reset" zeroes them.
class QoSStats : public ToFromString
{
public:
std::string to_string(void) const final;
int from_string(const std::string_view) final;
};
// qos.max-sleepers=<int>
class QoSMaxSleepers : public ToFromString
{
public:
std::string to_string(void) const final;
int from_string(const std::string_view) final;
};
// qos.distress-ms=<int>
class QoSDistressMS : public ToFromString
{
public:
std::string to_string(void) const final;
int from_string(const std::string_view) final;
};
// qos.distress-factor=<float>
class QoSDistressFactor : public ToFromString
{
public:
std::string to_string(void) const final;
int from_string(const std::string_view) final;
};
// qos.max-sleep-ms=<int>
class QoSMaxSleepMS : public ToFromString
{
public:
std::string to_string(void) const final;
int from_string(const std::string_view) final;
};