Skip to content

Commit

Permalink
Apply rustfmt
Browse files Browse the repository at this point in the history
Reviewed By: zertosh

Differential Revision: D37581085

fbshipit-source-id: bbc68101831e11b3452f9e2ed4b81b6e104ea72d
  • Loading branch information
stepancheg authored and facebook-github-bot committed Jul 1, 2022
1 parent ef1e688 commit 7c730b8
Show file tree
Hide file tree
Showing 63 changed files with 664 additions and 266 deletions.
7 changes: 6 additions & 1 deletion below/below_derive/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
// limitations under the License.

use quote::ToTokens;
use syn::{parse::Parse, punctuated::Punctuated, spanned::Spanned, Attribute, Ident, Token};
use syn::parse::Parse;
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::Attribute;
use syn::Ident;
use syn::Token;

/// Adapted from strum_macros
pub fn get_metadata<'a, T: Parse + Spanned>(
Expand Down
7 changes: 5 additions & 2 deletions below/below_derive/src/qenum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@

use crate::helper::to_snakecase;

use proc_macro2::{Span, TokenStream};
use proc_macro2::Span;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{spanned::Spanned, DeriveInput, LitStr};
use syn::spanned::Spanned;
use syn::DeriveInput;
use syn::LitStr;

fn get_variants(
ast: &DeriveInput,
Expand Down
20 changes: 13 additions & 7 deletions below/below_derive/src/queriable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::helper::{get_metadata, occurrence_error, parse_option, to_camelcase};
use crate::helper::get_metadata;
use crate::helper::occurrence_error;
use crate::helper::parse_option;
use crate::helper::to_camelcase;

use proc_macro2::{Span, TokenStream};
use proc_macro2::Span;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{
parse::{Parse, ParseStream},
spanned::Spanned,
DeriveInput, Field, Ident, Token,
};
use syn::parse::Parse;
use syn::parse::ParseStream;
use syn::spanned::Spanned;
use syn::DeriveInput;
use syn::Field;
use syn::Ident;
use syn::Token;

mod kw {
use syn::custom_keyword;
Expand Down
3 changes: 2 additions & 1 deletion below/btrfs/src/btrfs_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::{ffi::CStr, ops::RangeInclusive};
use std::ffi::CStr;
use std::ops::RangeInclusive;

#[cfg(fbcode_build)]
pub use btrfs_sys::*;
Expand Down
3 changes: 2 additions & 1 deletion below/btrfs/src/btrfs_api/sudotest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ use std::os::unix::fs::MetadataExt;
use std::os::unix::io::AsRawFd;
use std::path::Path;

use nix::sys::statfs::{fstatfs, FsType};
use nix::sys::statfs::fstatfs;
use nix::sys::statfs::FsType;

// Currently, sudotests test basic functionality. Will testing infrastructure in later commits

Expand Down
3 changes: 2 additions & 1 deletion below/btrfs/src/btrfs_api/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::ops::{Deref, DerefMut};
use std::ops::Deref;
use std::ops::DerefMut;

#[repr(C)]
pub struct WithMemAfter<T, const N: usize> {
Expand Down
10 changes: 7 additions & 3 deletions below/btrfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use rand_distr::{Distribution, Uniform};
use slog::{self, error, warn};
use rand_distr::Distribution;
use rand_distr::Uniform;
use slog::error;
use slog::warn;
use slog::{self};
use std::collections::HashMap;
use std::fs::File;
use std::os::unix::io::AsRawFd;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::path::PathBuf;
use std::rc::Rc;

pub mod btrfs_api;
Expand Down
3 changes: 2 additions & 1 deletion below/btrfs/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use serde::{Deserialize, Serialize};
use serde::Deserialize;
use serde::Serialize;
use std::collections::BTreeMap;

#[derive(Default, Clone, PartialEq, Debug, Serialize, Deserialize)]
Expand Down
16 changes: 11 additions & 5 deletions below/cgroupfs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@
#![deny(clippy::all)]
use std::collections::BTreeMap;
use std::ffi::OsStr;
use std::io::{BufRead, BufReader, ErrorKind};
use std::path::{Path, PathBuf};

use nix::sys::statfs::{fstatfs, CGROUP2_SUPER_MAGIC};
use openat::{AsPath, Dir, SimpleType};
use std::io::BufRead;
use std::io::BufReader;
use std::io::ErrorKind;
use std::path::Path;
use std::path::PathBuf;

use nix::sys::statfs::fstatfs;
use nix::sys::statfs::CGROUP2_SUPER_MAGIC;
use openat::AsPath;
use openat::Dir;
use openat::SimpleType;
use thiserror::Error;

mod types;
Expand Down
3 changes: 2 additions & 1 deletion below/cgroupfs/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use std::ffi::OsStr;
use std::fs::File;
use std::io::Write;
use std::os::linux::fs::MetadataExt;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::path::PathBuf;

use tempfile::TempDir;

Expand Down
3 changes: 2 additions & 1 deletion below/cgroupfs/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use serde::{Deserialize, Serialize};
use serde::Deserialize;
use serde::Serialize;

#[derive(Default, Clone, PartialEq, Debug, Serialize, Deserialize)]
pub struct CpuStat {
Expand Down
8 changes: 6 additions & 2 deletions below/common/src/cliutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use anyhow::{anyhow, bail, Result};
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use anyhow::anyhow;
use anyhow::bail;
use anyhow::Result;
use std::time::Duration;
use std::time::SystemTime;
use std::time::UNIX_EPOCH;

use crate::dateutil;
use crate::util;
Expand Down
14 changes: 10 additions & 4 deletions below/common/src/dateutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@
use chrono::prelude::*;
use chrono::Duration;
use regex::Regex;
use std::ops::{Add, Range, Sub};
use std::sync::atomic::{AtomicI32, Ordering};

use chrono::{Local, NaiveDateTime, NaiveTime, TimeZone};
use std::ops::Add;
use std::ops::Range;
use std::ops::Sub;
use std::sync::atomic::AtomicI32;
use std::sync::atomic::Ordering;

use chrono::Local;
use chrono::NaiveDateTime;
use chrono::NaiveTime;
use chrono::TimeZone;
use std::time::SystemTime;

/// A simple time structure that matches hg's time representation.
Expand Down
6 changes: 4 additions & 2 deletions below/common/src/fileutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ pub fn get_dir_size<P: AsRef<Path>>(path: P) -> u64 {
#[cfg(test)]
mod tests {
use super::*;
use std::fs::{self, File};
use std::io::{BufWriter, Write};
use std::fs::File;
use std::fs::{self};
use std::io::BufWriter;
use std::io::Write;
use tempdir::TempDir;

fn make_file<P: AsRef<Path>>(path: P, size: u64) {
Expand Down
4 changes: 3 additions & 1 deletion below/common/src/logutil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use slog::Level;

use std::cell::RefCell;
use std::io;
use std::sync::{Arc, Mutex, RwLock};
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::RwLock;

#[derive(PartialEq, Copy, Clone)]
pub enum TargetLog {
Expand Down
4 changes: 3 additions & 1 deletion below/common/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

/// This file contains various helpers
use chrono::prelude::*;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::time::Duration;
use std::time::SystemTime;
use std::time::UNIX_EPOCH;

const BELOW_RC: &str = "/.config/below/belowrc";

Expand Down
9 changes: 6 additions & 3 deletions below/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
// limitations under the License.

use std::fs;
use std::path::{Path, PathBuf};
use std::path::Path;
use std::path::PathBuf;

use anyhow::{bail, Result};
use anyhow::bail;
use anyhow::Result;
use once_cell::sync::OnceCell;
use serde::{Deserialize, Serialize};
use serde::Deserialize;
use serde::Serialize;

#[cfg(test)]
mod test;
Expand Down
47 changes: 36 additions & 11 deletions below/dump/src/cgroup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,42 @@ impl HasRenderConfigForDump for model::SingleCgroupModel {
fn get_render_config_for_dump(field_id: &SingleCgroupModelFieldId) -> RenderConfig {
use common::util::get_prefix;
use model::CgroupCpuModelFieldId::ThrottledPct;
use model::CgroupIoModelFieldId::{
DbytesPerSec, DiosPerSec, RbytesPerSec, RiosPerSec, RwbytesPerSec, WbytesPerSec,
WiosPerSec,
};
use model::CgroupMemoryModelFieldId::{
Anon, File, Pgactivate, Pgdeactivate, Pgfault, Pglazyfree, Pglazyfreed, Pgmajfault,
Pgrefill, Pgscan, Pgsteal, Shmem, Slab, Sock, Swap, ThpCollapseAlloc, ThpFaultAlloc,
Total, WorkingsetActivate, WorkingsetNodereclaim, WorkingsetRefault, Zswap,
};
use model::CgroupPressureModelFieldId::{MemoryFullPct, MemorySomePct};
use model::SingleCgroupModelFieldId::{Cpu, Io, Mem, Name, Pressure};
use model::CgroupIoModelFieldId::DbytesPerSec;
use model::CgroupIoModelFieldId::DiosPerSec;
use model::CgroupIoModelFieldId::RbytesPerSec;
use model::CgroupIoModelFieldId::RiosPerSec;
use model::CgroupIoModelFieldId::RwbytesPerSec;
use model::CgroupIoModelFieldId::WbytesPerSec;
use model::CgroupIoModelFieldId::WiosPerSec;
use model::CgroupMemoryModelFieldId::Anon;
use model::CgroupMemoryModelFieldId::File;
use model::CgroupMemoryModelFieldId::Pgactivate;
use model::CgroupMemoryModelFieldId::Pgdeactivate;
use model::CgroupMemoryModelFieldId::Pgfault;
use model::CgroupMemoryModelFieldId::Pglazyfree;
use model::CgroupMemoryModelFieldId::Pglazyfreed;
use model::CgroupMemoryModelFieldId::Pgmajfault;
use model::CgroupMemoryModelFieldId::Pgrefill;
use model::CgroupMemoryModelFieldId::Pgscan;
use model::CgroupMemoryModelFieldId::Pgsteal;
use model::CgroupMemoryModelFieldId::Shmem;
use model::CgroupMemoryModelFieldId::Slab;
use model::CgroupMemoryModelFieldId::Sock;
use model::CgroupMemoryModelFieldId::Swap;
use model::CgroupMemoryModelFieldId::ThpCollapseAlloc;
use model::CgroupMemoryModelFieldId::ThpFaultAlloc;
use model::CgroupMemoryModelFieldId::Total;
use model::CgroupMemoryModelFieldId::WorkingsetActivate;
use model::CgroupMemoryModelFieldId::WorkingsetNodereclaim;
use model::CgroupMemoryModelFieldId::WorkingsetRefault;
use model::CgroupMemoryModelFieldId::Zswap;
use model::CgroupPressureModelFieldId::MemoryFullPct;
use model::CgroupPressureModelFieldId::MemorySomePct;
use model::SingleCgroupModelFieldId::Cpu;
use model::SingleCgroupModelFieldId::Io;
use model::SingleCgroupModelFieldId::Mem;
use model::SingleCgroupModelFieldId::Name;
use model::SingleCgroupModelFieldId::Pressure;
use render::HasRenderConfig;

let rc = model::SingleCgroupModel::get_render_config_builder(field_id);
Expand Down
21 changes: 14 additions & 7 deletions below/dump/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::{CommonField, DumpField};
use crate::CommonField;
use crate::DumpField;
use model::BtrfsModelFieldId;
use model::EnumIter;
use model::{
BtrfsModelFieldId, FieldId, NetworkModelFieldId, SingleCgroupModelFieldId,
SingleDiskModelFieldId, SingleNetModelFieldId, SingleProcessModelFieldId, SystemModelFieldId,
};

use anyhow::{bail, Error, Result};
use model::FieldId;
use model::NetworkModelFieldId;
use model::SingleCgroupModelFieldId;
use model::SingleDiskModelFieldId;
use model::SingleNetModelFieldId;
use model::SingleProcessModelFieldId;
use model::SystemModelFieldId;

use anyhow::bail;
use anyhow::Error;
use anyhow::Result;
use clap::Parser;
use once_cell::sync::Lazy;
use regex::Regex;
Expand Down
30 changes: 22 additions & 8 deletions below/dump/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,31 @@
// limitations under the License.

use std::fs::File;
use std::io::{self, Write};
use std::io::Write;
use std::io::{self};
use std::path::PathBuf;
use std::str::FromStr;
use std::sync::mpsc::Receiver;
use std::time::SystemTime;

use anyhow::{bail, Error, Result};
use serde_json::{json, Value};
use anyhow::bail;
use anyhow::Error;
use anyhow::Result;
use serde_json::json;
use serde_json::Value;
use toml::value::Value as TValue;

use common::cliutil;
use common::util::{get_belowrc_dump_section_key, get_belowrc_filename, timestamp_to_datetime};
use model::{EnumIter, Field, FieldId, Queriable};
use common::util::get_belowrc_dump_section_key;
use common::util::get_belowrc_filename;
use common::util::timestamp_to_datetime;
use model::EnumIter;
use model::Field;
use model::FieldId;
use model::Queriable;

use store::advance::{new_advance_local, new_advance_remote};
use store::advance::new_advance_local;
use store::advance::new_advance_remote;
use store::Advance;
use store::Direction;

Expand All @@ -46,10 +56,14 @@ pub mod transport;
#[cfg(test)]
mod test;

use command::expand_fields;
pub use command::DumpCommand;
use command::{expand_fields, GeneralOpt, OutputFormat};
use command::GeneralOpt;
use command::OutputFormat;
use print::HasRenderConfigForDump;
use tmain::{dump_timeseries, Dumper, IterExecResult};
use tmain::dump_timeseries;
use tmain::Dumper;
use tmain::IterExecResult;

/// Fields available to all commands. Each enum represents some semantics and
/// knows how to extract relevant data from a CommonFieldContext.
Expand Down

0 comments on commit 7c730b8

Please sign in to comment.