Skip to content

uucore: gate getloadavg for Android, remove unsafe from Linux - #16816

Open
oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:getloadavg-droid
Open

oech3 wants to merge 1 commit into
uutils:mainfrom
oech3:getloadavg-droid

Conversation

@oech3

@oech3 oech3 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Also drop wasm32 cfg (wasip-shim is enough for browsers).

@xtqqczze

This comment was marked as resolved.

@oech3
oech3 force-pushed the getloadavg-droid branch 2 times, most recently from 720f62a to 0b08ed3 Compare November 24, 2026 17:59
@codspeed

codspeed Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will regress 3 benchmarks

Warning

uutils has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed.

2 warnings, 1 note

⚠️ 125 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

⚠️ 6 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

ℹ️ 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

⚡ 3 improved benchmarks
❌ 3 regressed benchmarks
✅ 409 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory timeout_enforced 88.8 KB 124.7 KB -28.83%
❌ CPU Simulation socket_addrs_direct[100000] 105.5 µs 131.9 µs -20.04%
❌ CPU Simulation hostname_ip_lookup[100000] 547.7 µs 576.2 µs -4.96%
⚡ Memory socket_addrs_direct[100000] 68 KB 8.6 KB ×7.9
⚡ Memory hostname_ip_lookup[100000] 160.3 KB 100.9 KB +58.88%
⚡ Memory cp_recursive_deep_tree[(120, 4)] 789 KB 671 KB +17.59%

Tip

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


Comparing oech3:getloadavg-droid (0eadf63) with main (719655e)2

Open in CodSpeed

Footnotes

  1. 70 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 (e47e3e6) during the generation of this report, so 719655e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Comment thread src/uucore/Cargo.toml Resolved
@oech3
oech3 force-pushed the getloadavg-droid branch 3 times, most recently from be024a4 to 0eadf63 Compare November 25, 2026 01:32
@oech3 oech3 changed the title uucore: gate getloadavg for Android uucore: gate getloadavg for Android, remove unsafe from Linux Nov 25, 2026
use libc::getloadavg;

let mut avg: [c_double; 3] = [0.0; 3];
// SAFETY: checked whether it returns -1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

By the way, a SAFETY comment must explain why an unsafe operation is sound, which this comment does not do.

@oech3 oech3 Nov 25, 2026 •

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.

And we should check == 3 to ensure initialize RAM instead of != -1 ? But this can be separated PR.

}

#[cfg(target_arch = "wasm32")]
pub fn get_loadavg() -> UResult<(f64, f64, f64)> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's a bit suspicious we have such a function that always returns an error, rather than gating cfg at the call sites.

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.

We can drop wasm32 later. diff is minimal at here.

@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

}

#[test]
fn test_get_load_average() {

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.

could you put it in a #[cfg(test)] mod tests and also check the 3 values are >= 0?

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.

It is difficult since other tests are gated by apple.

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.

3 participants