2022-06-15

This commit is contained in:
Daniel S. 2022-06-15 09:55:44 +02:00
parent 652609ca71
commit 972e2c2900
9 changed files with 68 additions and 30 deletions

28
.github/workflow/build.yml vendored Normal file
View File

@ -0,0 +1,28 @@
on: push
env:
PYTHON_VERSION: 3.7
RUST_TOOLCHAIN: nightly
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
name: Build Rust Extension for ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4.0.0
with:
python-version: ${{env.PYTHON_VERSION}}
cache: pip
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: ${{env.RUST_TOOLCHAIN}}
profile: minimal
default: true
- name: Build Python Extension
run: |
python -m build .

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
rust/target rust/target
rust/.history/ rust/.history/
rust/Cargo.lock rust/Cargo.lock
rust/ed_lrr_test.log
**/*.rs.bk **/*.rs.bk
*.tmp *.tmp
*.idx *.idx
@ -27,4 +28,4 @@ ed_lrr_gui/web/ed_lrr_web_ui.db
__version__.py __version__.py
.nox/ .nox/
dist_vis.py dist_vis.py
img/** img/**

View File

@ -16,5 +16,11 @@
"*.vpy": "python", "*.vpy": "python",
"stat.h": "c" "stat.h": "c"
}, },
"rust-analyzer.diagnostics.disabled": ["unresolved-import"] "rust-analyzer.diagnostics.disabled": [
"unresolved-import"
],
"yaml.schemas": {
"https://raw.githubusercontent.com/kaitai-io/ksy_schema/master/ksy_schema.json": "*.ksy",
"https://json.schemastore.org/github-workflow.json": "file:///d%3A/devel/rust/ed_lrr_gui/.github/workflow/build.yml"
}
} }

View File

@ -23,7 +23,6 @@ csv = "1.1.6"
humantime = "2.1.0" humantime = "2.1.0"
permutohedron = "0.2.4" permutohedron = "0.2.4"
serde_json = "1.0.81" serde_json = "1.0.81"
fnv = "1.0.7"
bincode = "1.3.3" bincode = "1.3.3"
sha3 = "0.10.1" sha3 = "0.10.1"
byteorder = "1.4.3" byteorder = "1.4.3"
@ -43,14 +42,6 @@ eval = "0.4.3"
pythonize = "0.16.0" pythonize = "0.16.0"
itertools = "0.10.3" itertools = "0.10.3"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
stats_alloc = "0.1.10"
tracing = { version = "0.1.34", optional = true }
tracing-subscriber = { version = "0.3.11", optional = true }
tracing-tracy = { version = "0.10.0", optional = true }
# tracing-unwrap = { version = "0.9.2", optional = true }
tracy-client = { version = "0.14.0", optional = true }
tracing-chrome = "0.6.0"
rand = "0.8.5" rand = "0.8.5"
eyre = "0.6.8" eyre = "0.6.8"
memmap = "0.7.0" memmap = "0.7.0"
@ -59,9 +50,17 @@ nohash-hasher = "0.2.0"
dashmap = "5.3.4" dashmap = "5.3.4"
rayon = "1.5.3" rayon = "1.5.3"
stats_alloc = {version="0.1.10", optional=true}
tracing = { version = "0.1.34", optional = true }
tracing-subscriber = { version = "0.3.11", optional = true }
tracing-tracy = { version = "0.10.0", optional = true }
# tracing-unwrap = { version = "0.9.2", optional = true }
tracy-client = { version = "0.14.0", optional = true }
tracing-chrome = "0.6.0"
[features] [features]
profiling = ["tracing","tracing-subscriber","tracing-tracy","tracy-client"] profiling = ["tracing","tracing-subscriber","tracing-tracy","tracy-client","stats_alloc"]
[dev-dependencies] [dev-dependencies]
criterion = { version = "0.3.5", features = ["real_blackbox"] } criterion = { version = "0.3.5", features = ["real_blackbox"] }

View File

View File

@ -76,8 +76,8 @@ r.load("../stars.csv", immediate=False)
# start, end = "Sol", "Colonia" # start, end = "Sol", "Colonia"
# systems = r.resolve(start, end) # systems = r.resolve(start, end)
# sys_ids = {k: v["id"] for k, v in systems.items()} # sys_ids = {k: v["id"] for k, v in systems.items()}
r.floyd_warshall_test(JUMP_RANGE)
r.bfs_test(JUMP_RANGE) # r.bfs_test(JUMP_RANGE)
# cfg = {} # cfg = {}
# cfg["mode"] = "incremental_broadening" # cfg["mode"] = "incremental_broadening"

View File

@ -13,13 +13,15 @@ pub mod search_algos;
pub mod ship; pub mod ship;
// ========================= // =========================
#[cfg(feature="mem_profiling")]
use stats_alloc::{Region, StatsAlloc, INSTRUMENTED_SYSTEM}; use stats_alloc::{Region, StatsAlloc, INSTRUMENTED_SYSTEM};
#[cfg(feature="mem_profiling")]
use std::alloc::System as SystemAlloc; use std::alloc::System as SystemAlloc;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::{BufWriter, Write}; use std::io::{BufWriter, Write};
use std::path::Path; use std::path::Path;
use std::time::Instant; use std::time::Instant;
#[cfg(not(feature = "profiling"))] #[cfg(feature = "mem_profiling")]
#[global_allocator] #[global_allocator]
static GLOBAL: &StatsAlloc<SystemAlloc> = &INSTRUMENTED_SYSTEM; static GLOBAL: &StatsAlloc<SystemAlloc> = &INSTRUMENTED_SYSTEM;
// ========================= // =========================
@ -295,13 +297,13 @@ impl PyRouter {
if is_default && !is_ship { if is_default && !is_ship {
warn!("no mode specified, defaulting to {}", mode); warn!("no mode specified, defaulting to {}", mode);
} }
#[cfg(not(feature = "profiling"))] #[cfg(feature = "mem_profiling")]
let reg = Region::new(GLOBAL); let reg = Region::new(GLOBAL);
let res = match self.router.compute_route(&ids, range, mode, num_workers) { let res = match self.router.compute_route(&ids, range, mode, num_workers) {
Ok(route) => Ok(route), Ok(route) => Ok(route),
Err(err_msg) => Err(PyErr::new::<RoutingError, _>(err_msg)), Err(err_msg) => Err(PyErr::new::<RoutingError, _>(err_msg)),
}; };
#[cfg(not(feature = "profiling"))] #[cfg(feature = "mem_profiling")]
println!("{:?}", reg.change()); println!("{:?}", reg.change());
return res; return res;
} }

View File

@ -1623,16 +1623,17 @@ impl Router {
info!("nb..."); info!("nb...");
let total = self.tree.size(); let total = self.tree.size();
for (n, node) in self.tree.iter().enumerate() { for (n, node) in self.tree.iter().enumerate() {
if (n % 100_000) == 0 { println!("{}: {}",node.id,self.neighbours(node, range).count());
println!("{}/{}", n, total); // if (n % 100_000) == 0 {
} // println!("{}/{}", n, total);
let key = (node.id as u64) << 32; // }
for nb in self.neighbours(node, range) { // let key = (node.id as u64) << 32;
let key = key | nb.id as u64; // for nb in self.neighbours(node, range) {
dist.entry(key).or_insert(1); // let key = key | nb.id as u64;
} // dist.entry(key).or_insert(1);
let key = ((node.id as u64) << 32) | node.id as u64; // }
dist.insert(key, 0); // let key = ((node.id as u64) << 32) | node.id as u64;
// dist.insert(key, 0);
} }
todo!() todo!()
} }

View File

@ -1,6 +1,7 @@
use rustc_hash::FxHashMap;
use crate::common::TreeNode; use crate::common::TreeNode;
use crate::route::{Router, SearchState}; use crate::route::{Router, SearchState};
use fnv::FnvHashMap;
trait SearchAlgoImpl<State = (), Weight: Ord = ()> { trait SearchAlgoImpl<State = (), Weight: Ord = ()> {
fn get_weight(&mut self, systems: &TreeNode, router: &Router) -> Option<Weight>; fn get_weight(&mut self, systems: &TreeNode, router: &Router) -> Option<Weight>;
@ -23,7 +24,7 @@ trait SearchAlgoImpl<State = (), Weight: Ord = ()> {
struct SearchAlgo<'a> { struct SearchAlgo<'a> {
algo: Box<dyn SearchAlgoImpl>, algo: Box<dyn SearchAlgoImpl>,
prev: FnvHashMap<u32, u32>, prev: FxHashMap<u32, u32>,
state: Option<SearchState>, state: Option<SearchState>,
router: &'a Router, router: &'a Router,
} }
@ -40,7 +41,7 @@ impl<'a> SearchAlgo<'a> {
fn new(router: &'a Router, algo: Box<dyn SearchAlgoImpl>) -> Self { fn new(router: &'a Router, algo: Box<dyn SearchAlgoImpl>) -> Self {
Self { Self {
algo, algo,
prev: FnvHashMap::default(), prev: FxHashMap::default(),
state: None, state: None,
router, router,
} }