Skip to content

Commit

Permalink
address cargo audit errors and warnings (#120)
Browse files Browse the repository at this point in the history
Addresses all of the cargo audit errors and warnings by updating
dependencies.

Removes public export of clocksource types from the common lib and
moves to directly depending on clocksource where necessary.
  • Loading branch information
brayniac authored Jan 24, 2024
1 parent 01bd14e commit f2f936b
Show file tree
Hide file tree
Showing 21 changed files with 680 additions and 961 deletions.
1,527 changes: 632 additions & 895 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ members = [
]

[workspace.dependencies]
ahash = "0.8.3"
ahash = "0.8.7"
arrayvec = "0.7.4"
awaken = "0.1.0"
backtrace = "0.3.69"
Expand All @@ -48,7 +48,7 @@ boring-sys = "3.1.0"
bstr = "1.7.0"
bytes = "1.5.0"
clap = "4.4.6"
clocksource = "0.6.0"
clocksource = "0.8.1"
crossbeam-channel = "0.5.8"
datatier = { path = "./src/storage/datatier", version = "0.1.0"}
foreign-types-shared = "0.3.1"
Expand All @@ -68,7 +68,7 @@ quote = "1.0.33"
rand = "0.8.5"
rand_chacha = "0.3.1"
rand_xoshiro = "0.6.0"
ringlog = "0.3.2"
ringlog = "0.5.0"
serde = "1.0.189"
serde_json = "1.0.107"
signal-hook = "0.3.17"
Expand Down
9 changes: 4 additions & 5 deletions src/common/src/expiry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

use crate::time::*;
use serde::{Deserialize, Serialize};

use std::time::SystemTime;
Expand Down Expand Up @@ -70,11 +69,11 @@ impl Expiry {
}
}

pub fn as_duration(&self) -> Duration<Nanoseconds<u64>> {
Duration::<Nanoseconds<u64>>::from_secs(self.as_secs().into())
pub fn as_duration(&self) -> clocksource::precise::Duration {
clocksource::precise::Duration::from_secs(self.as_secs())
}

pub fn as_coarse_duration(&self) -> Duration<Seconds<u32>> {
Duration::<Seconds<u32>>::from_secs(self.as_secs())
pub fn as_coarse_duration(&self) -> clocksource::coarse::Duration {
clocksource::coarse::Duration::from_secs(self.as_secs())
}
}
1 change: 0 additions & 1 deletion src/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ pub mod expiry;
pub mod metrics;
pub mod signal;
pub mod ssl;
pub mod time;
pub mod traits;
3 changes: 0 additions & 3 deletions src/common/src/time.rs

This file was deleted.

3 changes: 1 addition & 2 deletions src/core/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extern crate logger;
extern crate metriken;

use admin::AdminBuilder;
use clocksource::precise::Instant;
use common::signal::Signal;
use common::ssl::tls_acceptor;
use config::proxy::*;
Expand All @@ -31,8 +32,6 @@ use std::io::{Error, ErrorKind, Result};
use std::sync::Arc;
use switchboard::{Queues, Waker};

type Instant = clocksource::Instant<clocksource::Nanoseconds<u64>>;

mod backend;
mod frontend;
mod listener;
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ protocol-common = { path = "../../protocol/common" }
storage-types = { path = "../../storage/types" }

[dev-dependencies]
criterion = "0.3.4"
criterion = "0.5.1"
2 changes: 1 addition & 1 deletion src/protocol/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ logger = { path = "../../logger" }
storage-types = { path = "../../storage/types" }

[dev-dependencies]
criterion = "0.3.4"
criterion = "0.5.1"
3 changes: 2 additions & 1 deletion src/protocol/memcache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ harness = false

[dependencies]
common = { path = "../../common" }
clocksource = { workspace = true }
logger = { path = "../../logger" }
metriken = { workspace = true }
nom = { workspace = true }
protocol-common = { path = "../../protocol/common" }

[dev-dependencies]
criterion = "0.3.4"
criterion = "0.5.1"
15 changes: 7 additions & 8 deletions src/protocol/memcache/src/request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// http://www.apache.org/licenses/LICENSE-2.0

use crate::*;
use common::time::{Seconds, UnixInstant};
use clocksource::coarse::UnixInstant;
use core::fmt::{Display, Formatter};
use core::num::NonZeroI32;
use protocol_common::{BufMut, Parse, ParseOk};
Expand Down Expand Up @@ -427,19 +427,18 @@ impl Ttl {
};

// calculate the ttl in seconds
let seconds = UnixInstant::from_secs(exptime)
.checked_duration_since(UnixInstant::<Seconds<u32>>::recent())
.map(|v| v.as_secs())
.unwrap_or(0);
let now = UnixInstant::now()
.duration_since(UnixInstant::EPOCH)
.as_secs();

// zero would be immediate expiration, early return
if seconds == 0 {
// would immediately expire, early return
if now >= exptime {
return Self {
inner: NonZeroI32::new(-1),
};
}

seconds as i64
(exptime - now) as i64
} else {
exptime
};
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/ping/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protocol-common = { path = "../../protocol/common" }
storage-types = { path = "../../storage/types" }

[dev-dependencies]
criterion = "0.3.4"
criterion = "0.5.1"

[features]
default = []
Expand Down
1 change: 0 additions & 1 deletion src/proxy/momento/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub static ADMIN_CONN_CLOSE: Counter = Counter::new();

pub(crate) async fn admin(mut log_drain: Box<dyn logger::Drain>, admin_listener: TcpListener) {
loop {
clocksource::refresh_clock();
let _ = log_drain.flush();

// accept a new client
Expand Down
2 changes: 1 addition & 1 deletion src/server/pingserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ protocol-ping = { path = "../../protocol/ping", features = ["server"] }
server = { path = "../../core/server" }

[dev-dependencies]
criterion = "0.3"
criterion = "0.5.1"
2 changes: 1 addition & 1 deletion src/server/rds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ protocol-resp = { path = "../../protocol/resp" }
server = { path = "../../core/server" }

[dev-dependencies]
criterion = "0.3"
criterion = "0.5.1"
2 changes: 1 addition & 1 deletion src/server/segcache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ protocol-memcache = { path = "../../protocol/memcache" }
server = { path = "../../core/server" }

[dev-dependencies]
criterion = "0.3"
criterion = "0.5.1"
1 change: 1 addition & 0 deletions src/session/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = { workspace = true }

[dependencies]
bytes = { workspace = true }
clocksource = { workspace = true }
common = { path = "../common" }
log = { workspace = true }
metriken = { workspace = true }
Expand Down
16 changes: 4 additions & 12 deletions src/session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,16 @@ pub use buffer::*;
pub use client::ClientSession;
pub use server::ServerSession;

use std::os::unix::prelude::AsRawFd;

use common::time::Nanoseconds;
use clocksource::precise::Instant;
use core::borrow::{Borrow, BorrowMut};
use core::fmt::Debug;
use core::marker::PhantomData;
use metriken::*;
use pelikan_net::*;
use protocol_common::Compose;
use protocol_common::Parse;
use protocol_common::{Compose, Parse};
use std::collections::VecDeque;
use std::io::Error;
use std::io::ErrorKind;
use std::io::Read;
use std::io::Result;
use std::io::Write;
use std::io::{Error, ErrorKind, Read, Result, Write};
use std::os::unix::prelude::AsRawFd;

#[metric(
name = "session_buffer_byte",
Expand Down Expand Up @@ -79,8 +73,6 @@ pub static SESSION_SEND_BYTE: Counter = Counter::new();
)]
pub static REQUEST_LATENCY: AtomicHistogram = AtomicHistogram::new(7, 32);

type Instant = common::time::Instant<Nanoseconds<u64>>;

// The size of one kilobyte, in bytes
const KB: usize = 1024;

Expand Down
2 changes: 1 addition & 1 deletion src/storage/bloom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ twox-hash = { workspace = true, default-features = false }
rand = { workspace = true, optional = true }

[dev-dependencies]
criterion = "0.4"
criterion = "0.5.1"

[[bench]]
name = "bloom"
Expand Down
34 changes: 17 additions & 17 deletions src/storage/datatier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// http://www.apache.org/licenses/LICENSE-2.0

use blake3::Hash;
use clocksource::{Instant, Nanoseconds, Seconds, UnixInstant};
// use clocksource::{Instant, Nanoseconds, Seconds, UnixInstant};
use core::ops::Range;
use std::fs::{File, OpenOptions};
use std::io::{Error, ErrorKind, Read, Seek, SeekFrom, Write};
Expand Down Expand Up @@ -85,10 +85,10 @@ pub struct Header {
checksum: [u8; 32],
magic: [u8; 8],
version: u64,
time_monotonic_s: Instant<Seconds<u32>>,
time_unix_s: UnixInstant<Seconds<u32>>,
time_monotonic_ns: Instant<Nanoseconds<u64>>,
time_unix_ns: UnixInstant<Nanoseconds<u64>>,
time_monotonic_s: clocksource::coarse::Instant,
time_unix_s: clocksource::coarse::UnixInstant,
time_monotonic_ns: clocksource::precise::Instant,
time_unix_ns: clocksource::precise::UnixInstant,
user_version: u64,
options: u64,
_pad: [u8; 4008],
Expand All @@ -100,10 +100,10 @@ impl Header {
checksum: [0; 32],
magic: MAGIC,
version: VERSION,
time_monotonic_s: Instant::<Seconds<u32>>::now(),
time_unix_s: UnixInstant::<Seconds<u32>>::now(),
time_monotonic_ns: Instant::<Nanoseconds<u64>>::now(),
time_unix_ns: UnixInstant::<Nanoseconds<u64>>::now(),
time_monotonic_s: clocksource::coarse::Instant::now(),
time_unix_s: clocksource::coarse::UnixInstant::now(),
time_monotonic_ns: clocksource::precise::Instant::now(),
time_unix_ns: clocksource::precise::UnixInstant::now(),
user_version: 0,
options: 0,
_pad: [0; 4008],
Expand Down Expand Up @@ -315,19 +315,19 @@ impl MmapFile {
unsafe { &*(header.as_ptr() as *const Header) }
}

pub fn time_monotonic_s(&self) -> Instant<Seconds<u32>> {
pub fn time_monotonic_s(&self) -> clocksource::coarse::Instant {
self.header().time_monotonic_s
}

pub fn time_monotonic_ns(&self) -> Instant<Nanoseconds<u64>> {
pub fn time_monotonic_ns(&self) -> clocksource::precise::Instant {
self.header().time_monotonic_ns
}

pub fn time_unix_s(&self) -> UnixInstant<Seconds<u32>> {
pub fn time_unix_s(&self) -> clocksource::coarse::UnixInstant {
self.header().time_unix_s
}

pub fn time_unix_ns(&self) -> UnixInstant<Nanoseconds<u64>> {
pub fn time_unix_ns(&self) -> clocksource::precise::UnixInstant {
self.header().time_unix_ns
}
}
Expand Down Expand Up @@ -598,19 +598,19 @@ impl FileBackedMemory {
unsafe { &*(self.header.as_ptr() as *const Header) }
}

pub fn time_monotonic_s(&self) -> Instant<Seconds<u32>> {
pub fn time_monotonic_s(&self) -> clocksource::coarse::Instant {
self.header().time_monotonic_s
}

pub fn time_monotonic_ns(&self) -> Instant<Nanoseconds<u64>> {
pub fn time_monotonic_ns(&self) -> clocksource::precise::Instant {
self.header().time_monotonic_ns
}

pub fn time_unix_s(&self) -> UnixInstant<Seconds<u32>> {
pub fn time_unix_s(&self) -> clocksource::coarse::UnixInstant {
self.header().time_unix_s
}

pub fn time_unix_ns(&self) -> UnixInstant<Nanoseconds<u64>> {
pub fn time_unix_ns(&self) -> clocksource::precise::UnixInstant {
self.header().time_unix_ns
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/storage/segcache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ rand_xoshiro = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
criterion = "0.3.4"
criterion = "0.5.1"
6 changes: 1 addition & 5 deletions src/storage/segcache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
extern crate log;

// external crate includes
use clocksource::Seconds;
use clocksource::coarse::{Duration, Instant};

// includes from core/std
use core::hash::{BuildHasher, Hasher};
Expand Down Expand Up @@ -64,10 +64,6 @@ pub use eviction::Policy;
pub use item::Item;
pub use value::Value;

// type aliases
pub(crate) type Duration = clocksource::Duration<Seconds<u32>>;
pub(crate) type Instant = clocksource::Instant<Seconds<u32>>;

// items from submodules which are imported for convenience to the crate level
pub(crate) use crate::rand::*;
pub(crate) use hashtable::*;
Expand Down

0 comments on commit f2f936b

Please sign in to comment.