* refactor(tuning): prune dormant runtime knobs Remove unused tuning controls and adaptive search budget state. Extract testable ONNX slot reconciliation and search telemetry hydration seams, and correct the Apple Silicon sysctl value width. * refactor(vector): retire dormant backends Remove unused FAISS, model-infrastructure, VectorIndexManager, and TurboQuant paths while keeping Simeon PQ and float-vector storage. Migrate unused V2.2 quantized schemas transactionally to V2.3. Databases containing non-default quantized formats or packed-code blobs fail closed with recovery guidance and no mutation. * refactor(plugins): remove legacy SDK tooling Remove the Ghidra and SDK submodules, their bespoke tests, and stale scan exclusions. Retain generic PluginProcess coverage against the repository mock fixture. * build(vector): remove stale FAISS overrides * refactor(ipc): remove dormant FSM snapshots * refactor(ingest): unify bounded KG enqueue * fix(plugins): harden allocation contracts Keep ABI outputs null or fully initialized when allocations fail, and represent empty object payloads without relying on malloc(0). * fix(storage): define empty object reads Return a null buffer with zero length for successful empty-object reads instead of treating malloc(0) as an allocation contract. * refactor(storage): trim through string views * test: prune dormant harness helpers Remove unused readiness and fixture helpers, and keep benchmark client-count doubling in a wide integer domain. * chore(cpp): initialize analyzer-facing locals * build(simeon): advance analyzer cleanup * refactor(config): drop dead daemon client keys * refactor(ipc): inject daemon client transport Socket and in-process execution now share DaemonClient request dispatch, so CLI fallbacks do not need alternate service paths. * refactor(retrieval): route CLI through daemon Search and grep now use the same daemon handlers over socket or in-process transport. Live grep remains an explicit freshness inspection. * refactor(graph): move CLI scope into daemon Graph CLI requests now share daemon handlers across socket and in-process transports. CWD filtering occurs before pagination so scoped totals and pages stay correct. * build: isolate test-only runtime controls * refactor(metadata): decouple lock telemetry * fix(services): return on request timeout * fix(retrieval): enforce workspace scope * fix(graph): scope nodes before pagination * fix(grep): drop binary result lines * fix(daemon): bound checkpoint wait * fix(repair): use KG health checks * fix(storage): always verify compressed CRC * perf(vector): skip unchanged PQ snapshots * build(zyp): exclude bench from default build * build: protect Meson files from formatter * refactor: remove unreachable production APIs * refactor(daemon): remove dormant runtime state * fix(vector): harden daemon provider calls Timed-out coroutines must own their client and requests. Provider discovery must also fail instead of returning synthetic embeddings in production. * refactor(storage): remove unusable adapters * fix(cli): unify in-process add requests * fix(tsan): preserve async worker progress * test(cli): isolate daemon-dependent suites * fix(repair): expose queue backoff progress
142 lines
5 KiB
C++
142 lines
5 KiB
C++
#include <catch2/catch_test_macros.hpp>
|
|
|
|
#include <chrono>
|
|
#include <filesystem>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
#include <yams/compat/unistd.h>
|
|
#include <yams/daemon/components/InternalEventBus.h>
|
|
#include <yams/daemon/components/TuneAdvisor.h>
|
|
#include <yams/daemon/components/TuningManager.h>
|
|
#include <yams/daemon/components/TuningSnapshot.h>
|
|
#include <yams/daemon/daemon.h>
|
|
|
|
namespace fs = std::filesystem;
|
|
using namespace std::chrono_literals;
|
|
|
|
namespace {
|
|
|
|
bool isSocketPermissionDenied(const yams::Error& error) {
|
|
const std::string_view message{error.message};
|
|
return message.find("Operation not permitted") != std::string_view::npos ||
|
|
message.find("Permission denied") != std::string_view::npos;
|
|
}
|
|
|
|
bool waitFor(const std::function<bool()>& predicate, std::chrono::milliseconds timeout,
|
|
std::chrono::milliseconds step = 25ms) {
|
|
const auto deadline = std::chrono::steady_clock::now() + timeout;
|
|
while (std::chrono::steady_clock::now() < deadline) {
|
|
if (predicate()) {
|
|
return true;
|
|
}
|
|
std::this_thread::sleep_for(step);
|
|
}
|
|
return predicate();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("DaemonBench: idle control wakeup remains responsive", "[daemon][.bench][.slow]") {
|
|
const char* enable = ::getenv("YAMS_ENABLE_DAEMON_IDLE_BENCH");
|
|
if (!enable || std::string_view(enable) != "1") {
|
|
SKIP("Bench disabled (set YAMS_ENABLE_DAEMON_IDLE_BENCH=1 to run)");
|
|
}
|
|
|
|
fs::path runtimeRoot =
|
|
fs::temp_directory_path() / ("ydidle_" + std::to_string(::getpid()) + "_" +
|
|
std::to_string(static_cast<unsigned long>(
|
|
reinterpret_cast<uintptr_t>(&runtimeRoot) & 0xffff)));
|
|
|
|
yams::daemon::DaemonConfig cfg;
|
|
cfg.dataDir = runtimeRoot / "data";
|
|
cfg.socketPath = runtimeRoot / "sock";
|
|
cfg.pidFile = runtimeRoot / "daemon.pid";
|
|
cfg.logFile = runtimeRoot / "daemon.log";
|
|
cfg.enableModelProvider = false;
|
|
cfg.autoLoadPlugins = false;
|
|
|
|
::setenv("YAMS_DB_OPEN_TIMEOUT_MS", "1000", 1);
|
|
::setenv("YAMS_DB_MIGRATE_TIMEOUT_MS", "1500", 1);
|
|
::setenv("YAMS_SEARCH_BUILD_TIMEOUT_MS", "1000", 1);
|
|
::setenv("YAMS_DISABLE_VECTORS", "1", 1);
|
|
|
|
std::error_code se;
|
|
fs::create_directories(cfg.dataDir, se);
|
|
|
|
std::unique_ptr<yams::daemon::YamsDaemon> daemon =
|
|
std::make_unique<yams::daemon::YamsDaemon>(cfg);
|
|
auto start = daemon->start();
|
|
if (!start) {
|
|
if (isSocketPermissionDenied(start.error())) {
|
|
SKIP("UNIX domain sockets not permitted: " + start.error().message);
|
|
}
|
|
FAIL("Failed to start daemon: " + start.error().message);
|
|
}
|
|
|
|
const bool metadataReady =
|
|
waitFor([&]() { return daemon->getState().readiness.metadataRepoReady.load(); }, 20s, 50ms);
|
|
if (!metadataReady) {
|
|
daemon->stop();
|
|
SKIP("Daemon did not reach metadata-ready state within benchmark window");
|
|
}
|
|
|
|
const bool reachedIdle = waitFor(
|
|
[]() {
|
|
auto snap = yams::daemon::TuningSnapshotRegistry::instance().get();
|
|
return snap && snap->daemonIdle;
|
|
},
|
|
20s, 50ms);
|
|
if (!reachedIdle) {
|
|
daemon->stop();
|
|
SKIP("Daemon did not reach idle state within benchmark window");
|
|
}
|
|
|
|
auto channel =
|
|
yams::daemon::InternalEventBus::instance()
|
|
.get_or_create_channel<yams::daemon::InternalEventBus::StoreDocumentTask>(
|
|
"store_document_tasks", yams::daemon::TuneAdvisor::storeDocumentChannelCapacity());
|
|
|
|
yams::daemon::InternalEventBus::StoreDocumentTask task;
|
|
task.request.name = "idle-control-bench.txt";
|
|
task.request.content = "idle wake benchmark\n";
|
|
task.request.noEmbeddings = true;
|
|
REQUIRE(channel->try_push(std::move(task)));
|
|
|
|
const auto wakeStart = std::chrono::steady_clock::now();
|
|
yams::daemon::TuningManager::notifyWakeup();
|
|
const bool wokeActive = waitFor(
|
|
[]() {
|
|
auto snap = yams::daemon::TuningSnapshotRegistry::instance().get();
|
|
return snap && !snap->daemonIdle;
|
|
},
|
|
2s, 5ms);
|
|
REQUIRE(wokeActive);
|
|
|
|
const auto wakeMs = std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
std::chrono::steady_clock::now() - wakeStart)
|
|
.count();
|
|
INFO("Controller wake latency: " << wakeMs << "ms");
|
|
REQUIRE(wakeMs < 500);
|
|
|
|
const auto drainStart = std::chrono::steady_clock::now();
|
|
const bool returnedIdle = waitFor(
|
|
[]() {
|
|
auto snap = yams::daemon::TuningSnapshotRegistry::instance().get();
|
|
return snap && snap->daemonIdle;
|
|
},
|
|
15s);
|
|
REQUIRE(returnedIdle);
|
|
|
|
const auto drainMs = std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
std::chrono::steady_clock::now() - drainStart)
|
|
.count();
|
|
INFO("Controller return-to-idle latency: " << drainMs << "ms");
|
|
|
|
daemon->stop();
|
|
|
|
std::error_code ec;
|
|
fs::remove_all(runtimeRoot, ec);
|
|
}
|