Skip to content

rust: Port the Linux system info parsing in obs-nix.c to obs-core #2719

Closed

Description

@rdoupe

Unit

libobs/obs-nix.c.h: the Linux and BSD system info parsing (the /proc/cpuinfo and dmesg.boot line rules and the memory sizes of the startup log), moved to libobs/obs-nix-system-info.c.h and ported to rust/obs-core as a new module nix_system_info.

Phase and position

Phase 6 (libobs core), one unit of the remaining obs-nix.c.h C; tracking issue #4.

Dependencies and existing tests

No other unit. No real-libobs test covers the system-info log, so a characterization test (test_nix_system_info_steps) lands first, feeding saved cpuinfo and dmesg.boot text and memory values through the moved rules.

Scope

Rust takes over these decisions:

  • log_processor_info (Linux): which key a line holds (model name, physical id, cpu MHz, compared with strncmp by prefix length, so a longer key with that prefix also matches); the value after the first : (none when there is no : or nothing after it); the physical id as atoi reads it; and when a block is printed (a line that is only \n, with a physical id other than the last one printed);
  • log_processor_speed (FreeBSD): the speed of a CPU: line, from after the last ( up to the first -;
  • log_memory_info: the MB values, totalram * mem_unit / 1024 / 1024 and (freeram + bufferram) * mem_unit / 1024 / 1024 in uint64_t, and OpenBSD's mem / 1024 / 1024 in int64_t.

C keeps fopen, getline, fclose and free, every dstr_* copy and trim, sysinfo, sysctl, uname, access, getenv, the flatpak config reads, strlist_split/strlist_free, read_distribution_info, check_path, the X11 log and every blog, each where it is today. The NULL checks (the flatpak none/unknown defaults, which extension lists are logged, the desktop names, the data file search) stay C too: they are pointer checks, as in the canvas rules port (#2544). Everything from the hotkey platform calls on is untouched.

Plan

The standard six commits:

  1. move;
  2. characterization test;
  3. Tier 1 RED;
  4. GREEN in a libobs.ported-nix-system-info group (Linux ported sources; FreeBSD and OpenBSD build the same list);
  5. Tier 3 parity;
  6. docs.

Notes

No SIMD, no MSVC traps (no division by a variable, no 128-bit multiply). The core is OS-free and takes byte slices, returning offsets into them, so C keeps its own buffers. atoi overflow is undefined in C, so the parity inputs keep the physical id within int.

Activity

  1. added
    enhancement
    port
    on Oct 28, 2026
  2. rdoupe commented on Oct 28, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2719.

    1. Move the cpuinfo, dmesg.boot and memory rules of obs-nix.c.h into libobs/obs-nix-system-info.c.h (hidden, not EXPORT), behaviour-neutral, checked with a move harness.
    2. Characterize them in test_nix_system_info_steps.
    3. RED: obs_core::nix_system_info Tier 1 against todo!() stubs.
    4. GREEN: the core and its shims, in libobs.ported-nix-system-info.
    5. Tier 3 parity with proptest and a mutation check.
    6. Docs.

    Decisions:

    • The NULL checks (flatpak defaults, extension lists, desktop names, the data file search) stay C, as pointer checks did in the canvas rules port; the flatpak extension name is strlist_split's first field, which stays C.

    Draft PR with the RED commit expected today.

  3. added
    ready
    on Oct 28, 2026
  4. rdoupe commented on Oct 28, 2026

    @rdoupe
    CollaboratorAuthor

    Fixed by the PR that ports the Linux system info parsing to Rust (#2721), now merged. The /proc/cpuinfo and dmesg.boot line rules and the startup-log memory sizes now live in the nix_system_info module of rust/obs-core, with the C shims in libobs/obs-nix-system-info.c.h. The log output is unchanged.

    What is left: the plain pointer checks (flatpak defaults, extension lists, desktop names, data file search), the fopen/getline/sysinfo/sysctl calls, every blog, and everything from the hotkey platform calls on stay in C in obs-nix.c.h, as this issue's scope said. Those are host calls and pointer checks, not decisions to port, so no follow-up issue is filed for them. The Phase 6 tracking issue (#444) has no checkbox for this unit, so there was nothing to tick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementportready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions