2022-06-15
This commit is contained in:
parent
652609ca71
commit
972e2c2900
9 changed files with 68 additions and 30 deletions
28
.github/workflow/build.yml
vendored
Normal file
28
.github/workflow/build.yml
vendored
Normal 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
3
.gitignore
vendored
|
@ -1,6 +1,7 @@
|
|||
rust/target
|
||||
rust/.history/
|
||||
rust/Cargo.lock
|
||||
rust/ed_lrr_test.log
|
||||
**/*.rs.bk
|
||||
*.tmp
|
||||
*.idx
|
||||
|
@ -27,4 +28,4 @@ ed_lrr_gui/web/ed_lrr_web_ui.db
|
|||
__version__.py
|
||||
.nox/
|
||||
dist_vis.py
|
||||
img/**
|
||||
img/**
|
||||
|
|
8
rust/.vscode/settings.json
vendored
8
rust/.vscode/settings.json
vendored
|
@ -16,5 +16,11 @@
|
|||
"*.vpy": "python",
|
||||
"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"
|
||||
}
|
||||
}
|
|
@ -23,7 +23,6 @@ csv = "1.1.6"
|
|||
humantime = "2.1.0"
|
||||
permutohedron = "0.2.4"
|
||||
serde_json = "1.0.81"
|
||||
fnv = "1.0.7"
|
||||
bincode = "1.3.3"
|
||||
sha3 = "0.10.1"
|
||||
byteorder = "1.4.3"
|
||||
|
@ -43,14 +42,6 @@ eval = "0.4.3"
|
|||
pythonize = "0.16.0"
|
||||
itertools = "0.10.3"
|
||||
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"
|
||||
eyre = "0.6.8"
|
||||
memmap = "0.7.0"
|
||||
|
@ -59,9 +50,17 @@ nohash-hasher = "0.2.0"
|
|||
dashmap = "5.3.4"
|
||||
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]
|
||||
profiling = ["tracing","tracing-subscriber","tracing-tracy","tracy-client"]
|
||||
profiling = ["tracing","tracing-subscriber","tracing-tracy","tracy-client","stats_alloc"]
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.3.5", features = ["real_blackbox"] }
|
||||
|
|
|
@ -76,8 +76,8 @@ r.load("../stars.csv", immediate=False)
|
|||
# start, end = "Sol", "Colonia"
|
||||
# systems = r.resolve(start, end)
|
||||
# sys_ids = {k: v["id"] for k, v in systems.items()}
|
||||
|
||||
r.bfs_test(JUMP_RANGE)
|
||||
r.floyd_warshall_test(JUMP_RANGE)
|
||||
# r.bfs_test(JUMP_RANGE)
|
||||
|
||||
# cfg = {}
|
||||
# cfg["mode"] = "incremental_broadening"
|
||||
|
|
|
@ -13,13 +13,15 @@ pub mod search_algos;
|
|||
pub mod ship;
|
||||
|
||||
// =========================
|
||||
#[cfg(feature="mem_profiling")]
|
||||
use stats_alloc::{Region, StatsAlloc, INSTRUMENTED_SYSTEM};
|
||||
#[cfg(feature="mem_profiling")]
|
||||
use std::alloc::System as SystemAlloc;
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::{BufWriter, Write};
|
||||
use std::path::Path;
|
||||
use std::time::Instant;
|
||||
#[cfg(not(feature = "profiling"))]
|
||||
#[cfg(feature = "mem_profiling")]
|
||||
#[global_allocator]
|
||||
static GLOBAL: &StatsAlloc<SystemAlloc> = &INSTRUMENTED_SYSTEM;
|
||||
// =========================
|
||||
|
@ -295,13 +297,13 @@ impl PyRouter {
|
|||
if is_default && !is_ship {
|
||||
warn!("no mode specified, defaulting to {}", mode);
|
||||
}
|
||||
#[cfg(not(feature = "profiling"))]
|
||||
#[cfg(feature = "mem_profiling")]
|
||||
let reg = Region::new(GLOBAL);
|
||||
let res = match self.router.compute_route(&ids, range, mode, num_workers) {
|
||||
Ok(route) => Ok(route),
|
||||
Err(err_msg) => Err(PyErr::new::<RoutingError, _>(err_msg)),
|
||||
};
|
||||
#[cfg(not(feature = "profiling"))]
|
||||
#[cfg(feature = "mem_profiling")]
|
||||
println!("{:?}", reg.change());
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1623,16 +1623,17 @@ impl Router {
|
|||
info!("nb...");
|
||||
let total = self.tree.size();
|
||||
for (n, node) in self.tree.iter().enumerate() {
|
||||
if (n % 100_000) == 0 {
|
||||
println!("{}/{}", n, total);
|
||||
}
|
||||
let key = (node.id as u64) << 32;
|
||||
for nb in self.neighbours(node, range) {
|
||||
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);
|
||||
println!("{}: {}",node.id,self.neighbours(node, range).count());
|
||||
// if (n % 100_000) == 0 {
|
||||
// println!("{}/{}", n, total);
|
||||
// }
|
||||
// let key = (node.id as u64) << 32;
|
||||
// for nb in self.neighbours(node, range) {
|
||||
// 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);
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::common::TreeNode;
|
||||
use crate::route::{Router, SearchState};
|
||||
use fnv::FnvHashMap;
|
||||
|
||||
trait SearchAlgoImpl<State = (), Weight: Ord = ()> {
|
||||
fn get_weight(&mut self, systems: &TreeNode, router: &Router) -> Option<Weight>;
|
||||
|
@ -23,7 +24,7 @@ trait SearchAlgoImpl<State = (), Weight: Ord = ()> {
|
|||
|
||||
struct SearchAlgo<'a> {
|
||||
algo: Box<dyn SearchAlgoImpl>,
|
||||
prev: FnvHashMap<u32, u32>,
|
||||
prev: FxHashMap<u32, u32>,
|
||||
state: Option<SearchState>,
|
||||
router: &'a Router,
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ impl<'a> SearchAlgo<'a> {
|
|||
fn new(router: &'a Router, algo: Box<dyn SearchAlgoImpl>) -> Self {
|
||||
Self {
|
||||
algo,
|
||||
prev: FnvHashMap::default(),
|
||||
prev: FxHashMap::default(),
|
||||
state: None,
|
||||
router,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue