Skip to content

utmpx: handle unavailable logind session metadata - #16568

Open
mattsu2020 wants to merge 3 commits into
uutils:mainfrom
mattsu2020:utmpx/logind-metadata
Open

mattsu2020 wants to merge 3 commits into
uutils:mainfrom
mattsu2020:utmpx/logind-metadata

Conversation

@mattsu2020

@mattsu2020 mattsu2020 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #16478. Related to #8376. Split from #11579.

Review this change.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

GNU testsuite comparison:

Congrats! The gnu test tests/tail/follow-name is no longer failing!
Congrats! The gnu test tests/tail/pid-pipe is no longer failing!

@mattsu2020
mattsu2020 marked this pull request as ready for review November 17, 2026 05:07
@sylvestre
sylvestre force-pushed the utmpx/logind-metadata branch from 73a2c08 to ebef859 Compare November 17, 2026 05:22
@codspeed

codspeed Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 42.49%

3 warnings, 1 note

⚠️ 123 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 3 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚠️ 4 benchmarks with a significant change ran in a different software environment

Their base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the changes might come from this difference rather than from the code. Open an affected benchmark to see what changed.

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 4 improved benchmarks
❌ 3 regressed benchmarks
✅ 384 untouched benchmarks
⏩ 92 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory socket_addrs_direct[100000] 8.6 KB 68 KB -87.29%
❌ Memory hostname_ip_lookup[100000] 9.1 KB 66.4 KB -86.24%
❌ Memory tr_ascii_range_lower_to_upper 131.8 KB 138.4 KB -4.77%
⚡ CPU Simulation split_number_chunks_round_robin 32.8 ms 28.9 ms +13.39%
⚡ CPU Simulation dd_copy_with_skip 4.9 ms 4.8 ms +3.27%
⚡ CPU Simulation dd_copy_with_seek 5 ms 4.9 ms +3.26%
⚡ CPU Simulation dd_copy_8k_blocks 1.9 ms 1.9 ms +3.22%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mattsu2020:utmpx/logind-metadata (612d7ef) with main (e1b90fa)2

Open in CodSpeed

Footnotes

  1. 92 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (91f89c4) during the generation of this report, so e1b90fa was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩


/// Get the login time, or the Unix epoch when it is unavailable.
/// Use [`Self::try_login_time_offset`] when displaying timestamps.
pub fn login_time_offset(&self) -> time::OffsetDateTime {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still used outside the test? looks like dead code now, same for the compat login_time()/pid()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compat login_time() and pid() methods are still used by UtmpxRecord

Comment thread src/uucore/src/lib/features/utmpx.rs Resolved
Comment thread src/uu/who/src/platform/unix.rs Resolved
@mattsu2020
mattsu2020 marked this pull request as draft November 18, 2026 12:30
@mattsu2020
mattsu2020 marked this pull request as ready for review November 18, 2026 12:49
Comment thread src/uucore/src/lib/features/utmpx.rs Outdated
match self {
Self::Traditional(utmpx) => utmpx.pid(),
#[cfg(all(feature = "systemd_logind", target_os = "linux"))]
Self::Traditional(utmpx) => Option::from(utmpx.pid()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why Option::from and not Some(...)? looks like it is only there to dodge the clippy lint

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code to use expect.

@github-actions

Copy link
Copy Markdown

Binary size comparison:

Individual binary size comparison VS main (threshold: >=5% AND >=4 KB).

Total size of compared binaries: 155.49 MB (+104 KB, +0.07%)

Significant per-binary changes:
  env     1.20 MB ->    1.28 MB  (+80 KB, +6.51%)

@mattsu2020
mattsu2020 force-pushed the utmpx/logind-metadata branch from cbb8c12 to 612d7ef Compare November 18, 2026 22:36

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants