Skip to content
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

Various updates and improvements! #38

Merged
merged 3 commits into from
Sep 27, 2020
Merged

Various updates and improvements! #38

merged 3 commits into from
Sep 27, 2020

Conversation

Absolucy
Copy link
Contributor

@Absolucy Absolucy commented Sep 19, 2020

  • Update all crates to latest versions.
  • Use a DashMap over a RwLock<HashMap> for SQL pooling.
    • Also, use a usize as the key value instead of a string of the usize
  • Use once_cell over lazy_static - no macros needed.
    • The AtomicUsize used for pool IDs is no longer wrapped in a lazy_static, it's just it's own thing now.
  • Add codegen-units = 1 to the release profile. This allows the LLVM to optimize the code more, at the cost of multi-threaded compile time.

I've done a quick test, SQL appears to work correctly.

if let Some(output_filename) = prep.output_filename {
std::io::copy(&mut response, &mut std::fs::File::create(&output_filename)?)?;
let mut writer = std::io::BufWriter::new(std::fs::File::create(&output_filename)?);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

BufWriters are usually much better in this situation, unbuffered I/O has a performance penalty.

@@ -20,13 +20,10 @@ extern crate reqwest;
#[cfg(any(feature = "http", feature = "sql"))]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dunno why we still have extern crate definitions, we're using Rust 2018 now.

static ref NEXT_ID: std::sync::atomic::AtomicUsize = Default::default();
}
static POOL: Lazy<DashMap<String, Pool>> = Lazy::new(DashMap::new);
static NEXT_ID: AtomicUsize = AtomicUsize::new(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No clue why an AtomicUsize was in a lazy_static. That was redundant and probably had a tiny performance penalty.

@SpaceManiac SpaceManiac self-assigned this Sep 24, 2020
Copy link
Contributor

@SpaceManiac SpaceManiac left a comment

Choose a reason for hiding this comment

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

seems fine

@optimumtact
Copy link
Member

are you waiting for someone else to +1?

@SpaceManiac SpaceManiac merged commit 2e9b772 into tgstation:master Sep 27, 2020
@SpaceManiac
Copy link
Contributor

are you waiting for someone else to +1?

no, I'm just slow

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.

3 participants