Skip to content

other: skip the initial sleep on data collection initialization #1779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 13, 2025

Conversation

ClementTsang
Copy link
Owner

@ClementTsang ClementTsang commented Aug 13, 2025

Description

A description of the change, what it does, and why it was made. If relevant (such as any change that modifies the UI), please provide screenshots of the changes:

Don't think we need this anymore; this also bumps sysinfo and cleans up some things.

Issue

If applicable, what issue does this address?

May help with #1777.

Testing

If relevant, please state how this was tested. All changes must be tested to work:

If this is a code change, please also indicate which platforms were tested:

  • Windows
  • macOS
  • Linux

Checklist

If relevant, ensure the following have been met:

  • Areas your change affects have been linted using rustfmt (cargo fmt)
  • The change has been tested and doesn't appear to cause any unintended breakage
  • Documentation has been added/updated if needed (README.md, help menu, doc pages, etc.)
  • The pull request passes the provided CI pipeline
  • There are no merge conflicts
  • If relevant, new tests were added (don't worry too much about coverage)

Copy link

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 51.66667% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.12%. Comparing base (868667a) to head (acfe530).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/collection.rs 50.00% 29 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1779       +/-   ##
===========================================
- Coverage   53.53%   42.12%   -11.41%     
===========================================
  Files         115      115               
  Lines       16035    16057       +22     
===========================================
- Hits         8584     6764     -1820     
- Misses       7451     9293     +1842     
Flag Coverage Δ
macos-14 37.36% <0.00%> (-0.06%) ⬇️
ubuntu-latest 43.69% <54.38%> (-12.01%) ⬇️
windows-2022 37.74% <0.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ClementTsang ClementTsang requested a review from Copilot August 13, 2025 04:39
Copilot

This comment was marked as outdated.

@ClementTsang ClementTsang requested a review from Copilot August 13, 2025 04:58
Copilot

This comment was marked as outdated.

@ClementTsang ClementTsang requested a review from Copilot August 13, 2025 05:58
Copilot

This comment was marked as outdated.

@ClementTsang ClementTsang requested a review from Copilot August 13, 2025 06:14
Copilot

This comment was marked as outdated.

Copilot

This comment was marked as outdated.

@ClementTsang ClementTsang requested a review from Copilot August 13, 2025 06:41
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Removes the initial sleep delay during data collection initialization to improve startup performance, while also upgrading sysinfo dependency and refactoring collection logic for better maintainability.

Key changes:

  • Eliminates the initialization sleep that was causing startup delays
  • Refactors battery initialization to be lazy rather than upfront
  • Upgrades sysinfo dependency from 0.36.1 to 0.37.0

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/lib.rs Removes init() call and renames update_time to update_sleep for clarity
src/collection.rs Major refactor removing init() method, implementing lazy battery initialization, and reorganizing struct fields
src/options.rs Updates comment to better describe the update rate functionality
Cargo.toml Bumps sysinfo dependency from 0.36.1 to 0.37.0

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

self.battery_list = Some(battery_list);
self.battery_manager = Some(manager);
}

Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

This line returns self.battery_manager which is Option<Manager>, but the function expects to return &Manager. The code should return a reference to the manager that was just stored.

Suggested change
// Return a reference to the manager we just stored

Copilot uses AI. Check for mistakes.

.map(|batteries| batteries.filter_map(Result::ok).collect::<Vec<_>>())
else {
return;
};
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

This let Ok(battery_list) = manager pattern is incorrect. The code should handle the Result properly and extract the battery list from the Ok variant, not pattern match directly on the manager.

Suggested change
};
if let Ok(battery_list) = manager
.batteries()
.map(|batteries| batteries.filter_map(Result::ok).collect::<Vec<_>>())
{
// battery_list is available
} else {
return;
}

Copilot uses AI. Check for mistakes.

@ClementTsang ClementTsang enabled auto-merge (squash) August 13, 2025 06:53
@ClementTsang ClementTsang merged commit 0f21218 into main Aug 13, 2025
36 checks passed
@ClementTsang ClementTsang deleted the speed_up_startup branch August 13, 2025 06:57
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 16, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ClementTsang/bottom](https://github.com/ClementTsang/bottom) | patch | `0.11.0` -> `0.11.1` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>ClementTsang/bottom (ClementTsang/bottom)</summary>

### [`v0.11.1`](https://github.com/ClementTsang/bottom/blob/HEAD/CHANGELOG.md#0111---2025-08-15)

[Compare Source](ClementTsang/bottom@0.11.0...0.11.1)

##### Bug Fixes

- [#&#8203;1776](ClementTsang/bottom#1776): Fix `disk.columns` being incorrectly interpreted as blank.
- [#&#8203;1787](ClementTsang/bottom#1787): Fix issue with battery widget time and small widths.

##### Other

- [#&#8203;1779](ClementTsang/bottom#1779), [#&#8203;1788](ClementTsang/bottom#1788): Speed up time between startup and displaying data.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS43MS4wIiwidXBkYXRlZEluVmVyIjoiNDEuNzEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
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.

1 participant