yams/src/daemon/client/meson.build
Trevon 777e35adae
feat(profiling): Tracy for every library, zones on p2p and memory-sync, per-test CPU/RSS (#294)
* feat(profiling): Tracy zones on p2p and memory-sync background paths

Zone the memory-sync cycle (publish, sync, reconcile, apply, backfill,
delete-outbox drain), the p2p reconnect cycle, accept loop, per-session
worker and frame read, and the delta send/apply/bootstrap stages. Plot the
retained session count and pending erase intents. No behavior change; the
macros are no-ops without Tracy.

Signed-off-by: trvon <me@trevon.dev>

* test(infra): per-test-case CPU and peak RSS accounting for Catch2 binaries

A Catch2 listener in the shared test main records getrusage (GetProcessTimes
on Windows) CPU per case and prints the five heaviest cases plus the run's
peak RSS to stderr at run end. YAMS_TEST_RUSAGE=1 adds one line per case.
The measurement helpers are header-only and unit tested.

Signed-off-by: trvon <me@trevon.dev>

* fix(vector): make vector_database.cpp compile with Tracy enabled

The Profiling lane did not build: eight YAMS_PLOT sites in
vector_database.cpp used -> on a Result<T>, and two passed an int that is
ambiguous between Tracy's PlotData overloads. Use .value() and int64_t
casts. No behavior change outside TRACY_ENABLE builds.

Signed-off-by: trvon <me@trevon.dev>

* build: enable Tracy for every yams library in the Profiling lane

Define yams_tracy_args/yams_tracy_deps once in the root meson.build
(Tracy found, optional rocprofiler hooks, link check) and apply them to
every library and executable under src/, replacing the per-library copies
in search, topology, vector, daemon and tests/benchmarks. Empty when
enable-profiling is off.

Make YAMS_PLOT accept any numeric type and fix a Result deref in
search_service so the newly instrumented TUs compile with Tracy.

Signed-off-by: trvon <me@trevon.dev>

---------

Signed-off-by: trvon <me@trevon.dev>
2026-10-14 08:32:56 -06:00

136 lines
5.1 KiB
Meson

tl_expected_dep = dependency('tl-expected', required: true)
protobuf_dep = dependency('protobuf')
nlohmann_json_dep = dependency('nlohmann_json')
daemon_client_testing_cpp_args = []
if get_option('build-tests') or get_option('build-benchmarks')
daemon_client_testing_cpp_args += ['-DYAMS_TEST_LIFECYCLE_CONTROLS=1']
endif
# Protobuf generation for client
protoc_override = get_option('protoc-path')
proto_prefix = protobuf_dep.get_variable(pkgconfig: 'prefix', default_value: '')
dep_protoc_prog = disabler()
if proto_prefix != ''
dep_protoc_prog = find_program(join_paths(proto_prefix, 'bin', 'protoc'), required: false)
endif
if protoc_override != ''
protoc_prog = find_program(protoc_override, native: meson.is_cross_build(), required: true)
elif meson.is_cross_build()
protoc_prog = find_program('protoc', native: true, required: true)
else
protoc_candidate = proto_prefix != '' ? join_paths(proto_prefix, 'bin', 'protoc') : 'protoc'
protoc_prog = find_program(protoc_candidate, required: protobuf_dep.found())
endif
if protobuf_dep.found()
protobuf_version = protobuf_dep.version()
protoc_version_cmd = run_command(protoc_prog, '--version', check: false)
protoc_version = ''
if protoc_version_cmd.returncode() == 0
protoc_version_text = protoc_version_cmd.stdout().strip().split(' ')
if protoc_version_text.length() >= 2
protoc_version = protoc_version_text[1]
endif
endif
# Normalize versions: protoc may report "34.1" while protobuf pkg-config
# reports "34.1.0". Treat them as matching if one is a prefix of the other.
_versions_match = protoc_version == protobuf_version or protobuf_version.startswith(protoc_version + '.') or protoc_version.startswith(protobuf_version + '.')
if protoc_version != '' and not _versions_match
fallback_ok = false
fallback_version = ''
if dep_protoc_prog.found() and dep_protoc_prog.full_path() != protoc_prog.full_path()
fallback_version_cmd = run_command(dep_protoc_prog, '--version', check: false)
if fallback_version_cmd.returncode() == 0
fallback_version_text = fallback_version_cmd.stdout().strip().split(' ')
if fallback_version_text.length() >= 2
fallback_version = fallback_version_text[1]
endif
endif
fallback_ok = fallback_version == protobuf_version or protobuf_version.startswith(fallback_version + '.') or fallback_version.startswith(protobuf_version + '.')
endif
if fallback_ok
warning('Configured protoc @0@ (version @1@) does not match protobuf dependency version @2@; falling back to @3@.'.format(
protoc_prog.full_path(), protoc_version, protobuf_version, dep_protoc_prog.full_path()))
protoc_prog = dep_protoc_prog
else
error('Configured protoc version @0@ does not match protobuf dependency version @1@. Use a matching protoc, or leave -Dprotoc-path empty to use the dependency-provided generator.'.format(
protoc_version == '' ? 'unknown' : protoc_version, protobuf_version))
endif
endif
endif
proto_source_root = join_paths(meson.project_source_root(), 'include')
proto_input = join_paths(proto_source_root, 'yams', 'daemon', 'ipc', 'proto', 'ipc_envelope.proto')
# Use generator to preserve path structure matching the include hierarchy
proto_generator = generator(protoc_prog,
output: ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
arguments: [
'--cpp_out=lite:@BUILD_DIR@',
'--proto_path=' + proto_source_root,
'@INPUT@'
]
)
proto_generated = proto_generator.process(
[proto_input],
preserve_path_from: proto_source_root
)
yams_daemon_client_lib = static_library('yams_daemon_client',
[
'asio_connection.cpp',
'asio_connection_pool.cpp',
'daemon_client.cpp',
'asio_transport.cpp',
'process_discovery.cpp',
'systemd_user_unit.cpp',
'sandbox_detection.cpp',
'sandbox_probe.cpp',
'global_io_context.cpp',
'../ipc/connection_fsm.cpp',
'../ipc/message_framing.cpp',
'../ipc/ipc_protocol.cpp',
'../ipc/proto_serializer.cpp',
'../ipc/socket_utils.cpp',
proto_generated,
],
dependencies: [
dependency('yams_core'),
dependency('yams_config'),
dependency('yams_compression'),
dependency('yams_tune_advisor'),
dependency('spdlog'),
protobuf_dep,
# Boost.Asio relies on Boost.System + Boost.Thread at link time; both
# are bundled in the top-level boost_dep (per-library pkg-config probe).
# Re-invoking dependency('Boost'/'boost', modules: ...) here would bypass
# meson's override_dependency on the modules: form (meson #14146).
boost_dep,
tl_expected_dep,
nlohmann_json_dep,
] + yams_tracy_deps,
cpp_args: daemon_client_testing_cpp_args +
(cpp.get_id() == 'msvc' ? ['/wd4100'] : ['-Wno-unused-parameter']) + yams_tracy_args,
include_directories: include_directories('../../../include'),
install: false,
)
yams_daemon_client_dep = declare_dependency(
link_with: yams_daemon_client_lib,
include_directories: include_directories('../../../include'),
dependencies: [
boost_dep,
tl_expected_dep,
dependency('yams_core'),
dependency('yams_config'),
dependency('yams_tune_advisor'),
],
)
meson.override_dependency('yams_daemon_client', yams_daemon_client_dep)