Skip to content

WIP: preparing conditional compilation for multiple os#148

Merged
bpetit merged 141 commits intodevfrom
feat/conditional-compilation
Aug 8, 2022
Merged

WIP: preparing conditional compilation for multiple os#148
bpetit merged 141 commits intodevfrom
feat/conditional-compilation

Conversation

@bpetit
Copy link
Copy Markdown
Contributor

@bpetit bpetit commented Dec 22, 2021

No description provided.

@bpetit bpetit linked an issue Dec 22, 2021 that may be closed by this pull request
@bpetit bpetit changed the title chore: preparing conditional compilation for multiple os WIP: preparing conditional compilation for multiple os Dec 23, 2021
@bpetit bpetit force-pushed the feat/conditional-compilation branch from 0de123c to c18855c Compare December 24, 2021 07:23
@bpetit
Copy link
Copy Markdown
Contributor Author

bpetit commented Jul 20, 2022

Here is the repo of the driver for reading MSRs on windows : https://github.com/hubblo-org/windows-rapl-driver

@bpetit bpetit requested review from PierreRust and uggla July 20, 2022 16:41
Copy link
Copy Markdown
Collaborator

@uggla uggla left a comment

Choose a reason for hiding this comment

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

Pretty large MR hard to review. 123 commits is a bit too much. :)
It would have been good to split them into several topics (CI, Win,...).
Anyway, I have reviewed it, hoping I have not missed too much stuff.

Overall it looks ok, and I understand what you did. Good work ! Especially the windows driver part, which looks not trivial ! 👍

I think some functions could be refactored to reduce nested levels. This is particularly true in one function in the windows driver part that is hard to read due to unsafe and if let blocks plus formating.

Outside of this review, I saw a lot of signatures with Result<xxxx, String>.
To my mind, maybe signatures need to be reviewed to Option or error handling could be improved.

That's all for this first pass, but maybe another one would be required as my focus decreased at the end of the review.

uses: actions-rs/cargo@v1
with:
command : clippy
args: --no-default-features --features "prometheus json riemann"
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.

Why do you restrict to such features and not use the default ones?

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.

For now, other exporters require openssl crate which asks for linux openssl libraries.

Once we hare removed this requirements for rustls we should be able to allow all features on windows.

Cargo.toml Outdated
warp10 = { version = "1.0.0", optional = true }
rand = { version = "0.7.3" }
time = "0.2.25"
lazy_static = "1.4.0"
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.

Hum, I was curious to know where it is used.
But it appears to be not used in the code unless I'm wrong. So I think, it could be removed.

uggla   feat/conditional-compilation  ~  workspace  rust  scaphandre  rg -l lazy_static
Cargo.toml
Cargo.lock

hostname: String,
qemu: bool,
watch_containers: bool,
_qemu: bool,
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.

What is the reason to rename them to _qemu and _watch_containers ?

@@ -158,14 +192,33 @@ impl Topology {
/// }
/// ```
pub fn generate_cpu_cores() -> Result<Vec<CPUCore>, String> {
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.

As there is no ? or Err below.
Should the signature be changed to an option and not a Result.

Anyway, the above doc is up2date and needs to be changed.

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.

changed it in d413af5

Does that make sense ?

.map(IProcess::from_linux_process)
.collect::<Vec<_>>();

info!("Before refresh procs loop.");
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.

I think it can be refactored to reduce the number of nested levels and make it easier to read.

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.

What do you think about this ?

e9c96cb

.values()
.map(IProcess::from_windows_process)
.collect::<Vec<_>>();
for p in current_procs {
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.

idem above.

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'll do the same as e9c96cb on windows, depending on your appreciation :)

}
}
impl RecordReader for CPUSocket {
fn read_record(&self) -> Result<Record, Box<dyn Error>> {
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.

Fonction really hard to read due to nested blocks and formating.
I think a refactor with functions to flatten it would help.

Copy link
Copy Markdown
Contributor Author

@bpetit bpetit Jul 25, 2022

Choose a reason for hiding this comment

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

It is a bit badly written, as I had a hard time at first to make send_request work properly.

I intend to push windows support in 0.5 as an experimental feature, then work on packaging and improvements for the 0.6.

Do you think it could wait the 0.6 ?

pub tty_nr: i32,
pub tpgid: i32,
pub flags: u32,
//pub minflt: u64,
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.

comments to remove ? Here and below

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 agree it's not that pretty to have all those comments, but this is kind of a reminder to explore what procfs and sysinfo have to offer.

@bpetit bpetit merged commit 25e2a69 into dev Aug 8, 2022
maxhoesel pushed a commit to maxhoesel/master-thesis-scaphandre that referenced this pull request Mar 29, 2025
maxhoesel pushed a commit to maxhoesel/master-thesis-scaphandre that referenced this pull request Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Previous releases

Development

Successfully merging this pull request may close these issues.

Support Windows servers - bare metal and virtual hosts

2 participants