mirror of
https://github.com/uqbar-dao/nectar.git
synced 2025-01-04 15:53:21 +03:00
fs: optimize get/set-state queue based on kernel metadata (#67)
This commit is contained in:
parent
483f6decdc
commit
f11d323586
@ -455,12 +455,15 @@ pub async fn fs_sender(
|
||||
let manifest_clone = manifest.clone();
|
||||
|
||||
let our_name = our_name.clone();
|
||||
let source = kernel_message.source.clone();
|
||||
let mut source = kernel_message.source.clone();
|
||||
let send_to_loop = send_to_loop.clone();
|
||||
let send_to_terminal = send_to_terminal.clone();
|
||||
|
||||
let mut process_lock = process_queues.lock().await;
|
||||
|
||||
// optimization for get/set_state queues.
|
||||
update_src_from_kernel_metadata(&mut source, &kernel_message);
|
||||
|
||||
if let Some(queue) = process_lock.get_mut(&source.process) {
|
||||
queue.push_back(kernel_message.clone());
|
||||
} else {
|
||||
@ -761,6 +764,24 @@ pub fn hash_bytes(bytes: &[u8]) -> [u8; 32] {
|
||||
hasher.finalize().into()
|
||||
}
|
||||
|
||||
fn update_src_from_kernel_metadata(source: &mut Address, kernel_message: &KernelMessage) {
|
||||
if kernel_message.source.process == *KERNEL_PROCESS_ID {
|
||||
if let Message::Request(request) = &kernel_message.message {
|
||||
if let Some(process_id_str) = &request.metadata {
|
||||
if let Ok(process_id) = ProcessId::from_str(process_id_str) {
|
||||
source.process = process_id;
|
||||
}
|
||||
}
|
||||
} else if let Message::Response((response, _)) = &kernel_message.message {
|
||||
if let Some(process_id_str) = &response.metadata {
|
||||
if let Ok(process_id) = ProcessId::from_str(process_id_str) {
|
||||
source.process = process_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn make_error_message(our_name: String, km: &KernelMessage, error: FsError) -> KernelMessage {
|
||||
KernelMessage {
|
||||
id: km.id,
|
||||
|
@ -145,7 +145,7 @@ impl StandardHost for ProcessWasi {
|
||||
self.process.metadata.our.process.clone(),
|
||||
))
|
||||
.unwrap(),
|
||||
metadata: None,
|
||||
metadata: Some(self.process.metadata.our.process.to_string()),
|
||||
},
|
||||
None,
|
||||
)
|
||||
@ -186,7 +186,7 @@ impl StandardHost for ProcessWasi {
|
||||
self.process.metadata.our.process.clone(),
|
||||
))
|
||||
.unwrap(),
|
||||
metadata: None,
|
||||
metadata: Some(self.process.metadata.our.process.to_string()),
|
||||
},
|
||||
Some(wit::Payload { mime: None, bytes }),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user