Add some LLVM specific optims for O1 builds

next
Sayan Nandan 3 years ago
parent aaa84b150e
commit 0f06f7b26f

@ -48,7 +48,7 @@ const ADDR: &str = "127.0.0.1";
pub async fn start_repl() {
let cfg_layout = load_yaml!("./cli.yml");
let matches = App::from_yaml(cfg_layout).get_matches();
let host = matches.value_of("host").unwrap_or(ADDR);
let host = libsky::option_unwrap_or!(matches.value_of("host"), ADDR);
let port = match matches.value_of("port") {
Some(p) => match p.parse::<u16>() {
Ok(p) => p,

@ -49,6 +49,19 @@ lazy_static::lazy_static! {
static ref RE: regex::Regex = regex::Regex::from_str(r#"("[^"]*"|'[^']*'|[\S]+)+"#).unwrap();
}
#[macro_export]
/// Don't use unwrap_or but use this macro as the optimizer fails to optimize away usages
/// of unwrap_or and creates a lot of LLVM IR bloat. use
// FIXME(@ohsayan): Fix this when https://github.com/rust-lang/rust/issues/68667 is addressed
macro_rules! option_unwrap_or {
($try:expr, $fallback:expr) => {
match $try {
Some(t) => t,
None => $fallback,
}
};
}
pub fn split_into_args(q: &str) -> Vec<String> {
let args: Vec<String> = RE
.find_iter(q)

@ -50,11 +50,6 @@ pub struct Config {
/// The `server` key
server: ConfigKeyServer,
/// The `bgsave` key
/* TODO(@ohsayan): As of now, we will keep this optional, but post 0.6.0,
* we will make it compulsory (so that we don't break semver)
* See the link below for more details:
* https://github.com/Skytable/Skytable/issues/21#issuecomment-693217709
*/
bgsave: Option<ConfigKeyBGSAVE>,
/// The snapshot key
snapshot: Option<ConfigKeySnapshot>,
@ -283,7 +278,7 @@ impl ParsedConfig {
/// TOML file (represented as an object)
fn from_config(cfg_info: Config) -> Self {
ParsedConfig {
noart: cfg_info.server.noart.unwrap_or(false),
noart: libsky::option_unwrap_or!(cfg_info.server.noart, false),
bgsave: if let Some(bgsave) = cfg_info.bgsave {
match (bgsave.enabled, bgsave.every) {
// TODO: Show a warning that there are unused keys
@ -301,7 +296,7 @@ impl ParsedConfig {
SnapshotConfig::Enabled(SnapshotPref::new(
snapshot.every,
snapshot.atmost,
snapshot.failsafe.unwrap_or(true),
libsky::option_unwrap_or!(snapshot.failsafe, true),
))
})
.unwrap_or_else(SnapshotConfig::default),
@ -533,11 +528,12 @@ pub fn get_config_file_or_return_cfg() -> Result<ConfigType<ParsedConfig, String
},
None => None,
};
let failsafe = if let Ok(failsafe) = matches
.value_of("stop-write-on-fail")
.map(|val| val.parse::<bool>())
.unwrap_or(Ok(true))
{
let failsafe = if let Ok(failsafe) = libsky::option_unwrap_or!(
matches
.value_of("stop-write-on-fail")
.map(|val| val.parse::<bool>()),
Ok(true)
) {
failsafe
} else {
return Err(ConfigError::CliArgErr(

@ -153,9 +153,8 @@ impl CoreDB {
{
snap_count = Some(atmost);
}
let snapcfg = snap_count
.map(|max| Some(SnapshotStatus::new(*max)))
.unwrap_or(None);
let snapcfg =
libsky::option_unwrap_or!(snap_count.map(|max| Some(SnapshotStatus::new(*max))), None);
let db = if let Some(coremap) = coremap {
CoreDB {
coremap,

@ -108,7 +108,7 @@ impl<'a> SnapshotEngine<'a> {
} else {
(maxtop, false)
};
let snap_dir = snap_dir.unwrap_or(DIR_SNAPSHOT);
let snap_dir = libsky::option_unwrap_or!(snap_dir, DIR_SNAPSHOT);
match fs::create_dir(snap_dir) {
Ok(_) => (),
Err(e) => match e.kind() {

Loading…
Cancel
Save