-
Notifications
You must be signed in to change notification settings - Fork 0
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
Moved to Axum and async #33
Conversation
…mework Signed-off-by: David Pollak <[email protected]>
Signed-off-by: David Pollak <[email protected]>
…d addressing some performance issues with BufReader Signed-off-by: David Pollak <[email protected]>
Signed-off-by: David Pollak <[email protected]>
src/cluster_writer.rs
Outdated
// 25M | ||
const MAX_DATA_FILE_SIZE: u64 = 15 * 1024 * 1024 * 1024; | ||
const MAX_INDEX_CNT: usize = 25 * 1024 * 1024; | ||
|
||
// 15GB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments got dissociated from their target
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
.file | ||
.lock() | ||
.map_err(|e| anyhow!("Failed to lock {:?}", e))?; | ||
let mut my_file = self.file.lock().await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Locking that's infallible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably causes the whole Tokio runtime to panic/collapse... but that'll never happen in production at 2am... never!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no
src/server.rs
Outdated
.route("/bulk", post(serve_bulk)) | ||
.route("/{*gitoid}", get(serve_gitoid)) | ||
.route("/aa/{*gitoid}", get(serve_anti_alias)) | ||
.route("/north/{*gitoid}", get(serve_north)) | ||
.route("/north_purls/{*gitoid}", get(serve_north_purls)) | ||
.route("/north", post(serve_bulk_north)) | ||
.route("/north_purls", post(serve_bulk_north_purls)) | ||
.with_state(state); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much nicer to parse as a person trying to understand the structure of the app
src/config.rs
Outdated
pub fn num_threads(&self) -> u16 { | ||
self.threads.unwrap_or(7) | ||
} | ||
// pub fn num_threads(&self) -> u16 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this no longer needed? Should it be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
let mut data_file = GoatRodeoCluster::find_file(dir, hash, "grd")?; | ||
pub async fn new(dir: &PathBuf, hash: u64) -> Result<DataFile> { | ||
let mut data_file = GoatRodeoCluster::find_file(dir, hash, "grd").await?; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this magic value "grd" ? should it be a named constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Goat rodeo data"
I'm definitely on team "just inline them please, so I don't have to chase a zillion references to read anything"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created constants...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just left a couple nit-picky questions
Signed-off-by: David Pollak <[email protected]>
Signed-off-by: David Pollak <[email protected]>
src/rodeo_server.rs
Outdated
pub fn get_cluster(&self) -> GoatRodeoCluster { | ||
let the_cluster: GoatRodeoCluster = (&(**self.get_cluster_arcswap().load())).clone(); | ||
pub fn get_cluster(&self) -> Arc<GoatRodeoCluster> { | ||
let the_cluster: Arc<GoatRodeoCluster> = (&(*self.get_cluster_arcswap().load())).clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This smells funny, I might unpack that later and see if I can figure out why the reference hackery is needed. Looks like it does the right thing though so shipit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because we need to pass Arc<GoatRodeoCluster>
around... and clone()
ing an Arc
is much cheaper than cloning the underlying data structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay but the reference and pointer creation isn't needed:
let the_cluster: Arc<GoatRodeoCluster> = (&(*self.get_cluster_arcswap().load())).clone(); | |
let the_cluster: Arc<GoatRodeoCluster> = self.get_cluster_arcswap().load().clone(); |
src/rodeo_server.rs
Outdated
pub fn get_cluster(&self) -> Arc<GoatRodeoCluster> { | ||
let the_cluster: Arc<GoatRodeoCluster> = (&(*self.get_cluster_arcswap().load())).clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even this:
pub fn get_cluster(&self) -> Arc<GoatRodeoCluster> { | |
let the_cluster: Arc<GoatRodeoCluster> = (&(*self.get_cluster_arcswap().load())).clone(); | |
pub fn get_cluster(&self) -> Arc<GoatRodeoCluster> { | |
self.get_cluster_arcswap().load().clone() |
Signed-off-by: David Pollak <[email protected]>
Signed-off-by: David Pollak <[email protected]>
💻 Description of Change(s) (w/ context)
Moved From Roullie web framework (synchronous) to Axum (tokio's own web framework and async)
Updated a lot of code to be async. Addressed some async performance issues related to
BufReader
Cleaned up routing code
🧠 Rationale Behind Change(s)
Moving to a supported web framework is important.
Axum is OpenAPI-friendly and soon there'll be OpenAPI endpoints
Axum's routing scheme is easier to layer on top of which will be important for other applications
that embed Big Tent.
Async is Rust's future (ha ha)... so might as well get on the Async train... or at least Promise to...
📝 Test Plan
All existing tests work
📜 Documentation
Added code documentation
💣 Quality Control
(All items must be checked before a PR is merged)
Did you…
Before Merging…