fix: automatic rebuilds, num_threads for localpools (#4583)
* fix: automatic rebuilds * Fix concurrency for locapoolhandle
This commit is contained in:
1 parent
74163984be
commit
23908b9d49
5 files changed
+27
-8
No files matched your search
@@ -267,13 +267,14 @@ pub(crate) async fn serve_all(args: ServeArgs, tracer: &TraceController) -> Resu
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServeUpdate::ToggleShouldRebuild => {
|
ServeUpdate::ToggleShouldRebuild => {
|
||||||
|
use crate::styles::{ERROR, NOTE_STYLE};
|
||||||
builder.automatic_rebuilds = !builder.automatic_rebuilds;
|
builder.automatic_rebuilds = !builder.automatic_rebuilds;
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
"Automatic rebuilds are currently: {}",
|
"Automatic rebuilds are currently: {}",
|
||||||
if builder.automatic_rebuilds {
|
if builder.automatic_rebuilds {
|
||||||
"enabled"
|
format!("{NOTE_STYLE}enabled{NOTE_STYLE:#}")
|
||||||
} else {
|
} else {
|
||||||
"disabled"
|
format!("{ERROR}disabled{ERROR:#}")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,7 +492,7 @@ impl AppServer {
|
|||||||
|
|
||||||
// todo - we need to distinguish between hotpatchable rebuilds and true full rebuilds.
|
// todo - we need to distinguish between hotpatchable rebuilds and true full rebuilds.
|
||||||
// A full rebuild is required when the user modifies static initializers which we haven't wired up yet.
|
// A full rebuild is required when the user modifies static initializers which we haven't wired up yet.
|
||||||
if needs_full_rebuild {
|
if needs_full_rebuild && self.automatic_rebuilds {
|
||||||
if self.use_hotpatch_engine {
|
if self.use_hotpatch_engine {
|
||||||
self.client.patch_rebuild(files.to_vec());
|
self.client.patch_rebuild(files.to_vec());
|
||||||
if let Some(server) = self.server.as_mut() {
|
if let Some(server) = self.server.as_mut() {
|
||||||
@@ -526,6 +526,14 @@ impl AppServer {
|
|||||||
let file =
|
let file =
|
||||||
file.trim_start_matches(&self.client.build.crate_dir().display().to_string());
|
file.trim_start_matches(&self.client.build.crate_dir().display().to_string());
|
||||||
|
|
||||||
|
if needs_full_rebuild && !self.automatic_rebuilds {
|
||||||
|
use crate::styles::NOTE_STYLE;
|
||||||
|
tracing::warn!(
|
||||||
|
"Ignoring full rebuild for: {NOTE_STYLE}{}{NOTE_STYLE:#}",
|
||||||
|
file
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Only send a hotreload message for templates and assets - otherwise we'll just get a full rebuild
|
// Only send a hotreload message for templates and assets - otherwise we'll just get a full rebuild
|
||||||
//
|
//
|
||||||
// todo: move the android file uploading out of hotreload_bundled_asset and
|
// todo: move the android file uploading out of hotreload_bundled_asset and
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ impl LiveViewPool {
|
|||||||
dioxus_html::set_event_converter(Box::new(SerializedHtmlEventConverter));
|
dioxus_html::set_event_converter(Box::new(SerializedHtmlEventConverter));
|
||||||
|
|
||||||
LiveViewPool {
|
LiveViewPool {
|
||||||
pool: LocalPoolHandle::new(16),
|
pool: LocalPoolHandle::new(
|
||||||
|
std::thread::available_parallelism()
|
||||||
|
.map(usize::from)
|
||||||
|
.unwrap_or(1),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,11 @@ async fn serve_server(
|
|||||||
base_path().map(|s| s.to_string()),
|
base_path().map(|s| s.to_string()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let task_pool = LocalPoolHandle::new(5);
|
let task_pool = LocalPoolHandle::new(
|
||||||
|
std::thread::available_parallelism()
|
||||||
|
.map(usize::from)
|
||||||
|
.unwrap_or(1),
|
||||||
|
);
|
||||||
let mut make_service = router.into_make_service();
|
let mut make_service = router.into_make_service();
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind(address).await.unwrap();
|
let listener = tokio::net::TcpListener::bind(address).await.unwrap();
|
||||||
|
|||||||
@@ -40,9 +40,11 @@ where
|
|||||||
static TASK_POOL: std::sync::OnceLock<LocalPoolHandle> = std::sync::OnceLock::new();
|
static TASK_POOL: std::sync::OnceLock<LocalPoolHandle> = std::sync::OnceLock::new();
|
||||||
|
|
||||||
let pool = TASK_POOL.get_or_init(|| {
|
let pool = TASK_POOL.get_or_init(|| {
|
||||||
let threads = std::thread::available_parallelism()
|
LocalPoolHandle::new(
|
||||||
.unwrap_or(std::num::NonZeroUsize::new(1).unwrap());
|
std::thread::available_parallelism()
|
||||||
LocalPoolHandle::new(threads.into())
|
.map(usize::from)
|
||||||
|
.unwrap_or(1),
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
pool.spawn_pinned(f)
|
pool.spawn_pinned(f)
|
||||||
|
|||||||
Reference in new issue
Block a user