Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c7572e215 | ||
|
|
061738a63b | ||
|
|
e8bd97655f |
@@ -274,7 +274,8 @@ mod tests {
|
|||||||
|
|
||||||
// Pseudo-random noise vs gradient — correlation should be low.
|
// Pseudo-random noise vs gradient — correlation should be low.
|
||||||
let noise: Vec<u8> = (0..256)
|
let noise: Vec<u8> = (0..256)
|
||||||
.map(|i| ((i * 1103515245 + 12345) as u32 >> 8 & 0xff) as u8)
|
.map(|i| (i as u32).wrapping_mul(1_103_515_245).wrapping_add(12_345))
|
||||||
|
.map(|value| ((value >> 8) & 0xff) as u8)
|
||||||
.collect();
|
.collect();
|
||||||
let r = asm.correlation_with_last(&noise).expect("r");
|
let r = asm.correlation_with_last(&noise).expect("r");
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
@@ -1641,29 +1641,56 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
'settings': ['/vchan.js', '/scheduler.js']
|
'settings': ['/vchan.js', '/scheduler.js']
|
||||||
};
|
};
|
||||||
var loaded = new Set();
|
var loaded = new Set();
|
||||||
function loadPlugins(tab) {
|
var loading = new Map();
|
||||||
var scripts = pluginScripts[tab];
|
|
||||||
if (!scripts) return;
|
function loadScript(src) {
|
||||||
scripts.forEach(function(src) {
|
if (loaded.has(src)) return Promise.resolve();
|
||||||
if (loaded.has(src)) return;
|
if (loading.has(src)) return loading.get(src);
|
||||||
loaded.add(src);
|
|
||||||
|
var request = new Promise(function(resolve, reject) {
|
||||||
var s = document.createElement('script');
|
var s = document.createElement('script');
|
||||||
s.src = src;
|
s.src = src;
|
||||||
s.defer = true;
|
s.onload = function() {
|
||||||
|
loaded.add(src);
|
||||||
|
loading.delete(src);
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
s.onerror = function() {
|
||||||
|
loading.delete(src);
|
||||||
|
reject(new Error('Failed to load plugin script: ' + src));
|
||||||
|
};
|
||||||
document.body.appendChild(s);
|
document.body.appendChild(s);
|
||||||
});
|
});
|
||||||
|
loading.set(src, request);
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadPlugins(tab) {
|
||||||
|
var scripts = pluginScripts[tab];
|
||||||
|
if (!scripts) return Promise.resolve();
|
||||||
|
return scripts.reduce(function(sequence, src) {
|
||||||
|
return sequence.then(function() { return loadScript(src); });
|
||||||
|
}, Promise.resolve());
|
||||||
|
}
|
||||||
|
|
||||||
|
function requestPlugins(tab) {
|
||||||
|
return loadPlugins(tab).catch(function(err) {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Eager plugin loading is triggered by app.js (after window.trx is set up)
|
// Eager plugin loading is triggered by app.js (after window.trx is set up)
|
||||||
// via window.loadEagerPlugins(). Dynamic scripts are effectively async, so
|
// via window.loadEagerPlugins(). Dynamic scripts are effectively async, so
|
||||||
// loading them before app.js would cause map-core.js to crash when
|
// loading them before app.js would cause map-core.js to crash when
|
||||||
// window.trx is not yet defined.
|
// window.trx is not yet defined.
|
||||||
window.loadEagerPlugins = function() {
|
window.loadEagerPlugins = function() {
|
||||||
['digital-modes', 'map-data', 'bookmarks', 'settings'].forEach(loadPlugins);
|
return Promise.all(
|
||||||
|
['digital-modes', 'map-data', 'bookmarks', 'settings'].map(requestPlugins)
|
||||||
|
);
|
||||||
};
|
};
|
||||||
// Load others on tab switch
|
// Load others on tab switch
|
||||||
document.addEventListener('click', function(e) {
|
document.addEventListener('click', function(e) {
|
||||||
var tab = e.target.closest('[data-tab]');
|
var tab = e.target.closest('[data-tab]');
|
||||||
if (tab) loadPlugins(tab.dataset.tab);
|
if (tab) requestPlugins(tab.dataset.tab);
|
||||||
});
|
});
|
||||||
window.loadPluginsForTab = loadPlugins;
|
window.loadPluginsForTab = loadPlugins;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -226,20 +226,38 @@ pub fn flush_all(db: &mut PickleDb, rig_id: &str, histories: &Arc<DecoderHistori
|
|||||||
let _ = db.dump();
|
let _ = db.dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn flush_all_rigs(db: &Mutex<PickleDb>, rig_histories: &[(String, Arc<DecoderHistories>)]) {
|
||||||
|
let Ok(mut guard) = db.lock() else {
|
||||||
|
tracing::warn!("history database mutex poisoned; skipping periodic flush");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
for (rig_id, histories) in rig_histories {
|
||||||
|
flush_all(&mut guard, rig_id, histories);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Spawn a Tokio task that flushes all rigs' histories to disk every 60 seconds.
|
/// Spawn a Tokio task that flushes all rigs' histories to disk every 60 seconds.
|
||||||
|
///
|
||||||
|
/// Snapshot cloning, JSON serialization, and disk I/O run on Tokio's blocking
|
||||||
|
/// pool so a large history database cannot stall an async runtime worker.
|
||||||
pub fn spawn_flush_task(
|
pub fn spawn_flush_task(
|
||||||
db: Arc<Mutex<PickleDb>>,
|
db: Arc<Mutex<PickleDb>>,
|
||||||
rig_histories: Vec<(String, Arc<DecoderHistories>)>,
|
rig_histories: Vec<(String, Arc<DecoderHistories>)>,
|
||||||
) {
|
) {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
let rig_histories = Arc::new(rig_histories);
|
||||||
let mut interval = tokio::time::interval(Duration::from_secs(60));
|
let mut interval = tokio::time::interval(Duration::from_secs(60));
|
||||||
interval.tick().await; // consume the immediate first tick
|
interval.tick().await; // consume the immediate first tick
|
||||||
loop {
|
loop {
|
||||||
interval.tick().await;
|
interval.tick().await;
|
||||||
if let Ok(mut guard) = db.lock() {
|
let db = Arc::clone(&db);
|
||||||
for (rig_id, histories) in &rig_histories {
|
let rig_histories = Arc::clone(&rig_histories);
|
||||||
flush_all(&mut guard, rig_id, histories);
|
if let Err(err) = tokio::task::spawn_blocking(move || {
|
||||||
}
|
flush_all_rigs(&db, rig_histories.as_slice());
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
tracing::warn!(error = %err, "history flush worker failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -251,9 +251,9 @@ fn mul_freq_domain(buf: &mut [FftComplex<f32>], h_freq: &[FftComplex<f32>], scal
|
|||||||
unsafe {
|
unsafe {
|
||||||
mul_freq_domain_neon(buf, h_freq, scale);
|
mul_freq_domain_neon(buf, h_freq, scale);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(target_arch = "aarch64"))]
|
||||||
mul_freq_domain_scalar(buf, h_freq, scale);
|
mul_freq_domain_scalar(buf, h_freq, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user