Skip to content

Commit

Permalink
Parallelize interactive WASM routing
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Nov 5, 2023
1 parent de701af commit 1cdbe79
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
run: |
cd viewer
npm ci
#rustup toolchain install nightly-2023-10-03-x86_64-unknown-linux-gnu
#rustup component add rust-src --toolchain nightly-2023-10-03-x86_64-unknown-linux-gnu
npm run wasm
npm run build --if-present
Expand Down
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"wasm": "wasm-pack build --release --target web ../lts && wasm-pack build --release --target web ../wasm-od2net",
"wasm": "wasm-pack build --release --target web ../lts && rustup run nightly-2023-10-03 wasm-pack build --release --target web ../wasm-od2net",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json",
"fmt": "npx prettier --write *.html src/**"
Expand Down
5 changes: 3 additions & 2 deletions viewer/src/InteractiveApp.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { Map as MapType } from "maplibre-gl";
import { onMount } from "svelte";
import { GeoJSON, MapLibre, Marker } from "svelte-maplibre";
import init, { JsNetwork } from "wasm-od2net";
import init, { initThreadPool, JsNetwork } from "wasm-od2net";
import markerSvg from "../assets/marker.svg?raw";
import CostFunction from "./CostFunction.svelte";
import Header from "./Header.svelte";
Expand All @@ -13,6 +13,7 @@
onMount(async () => {
await init();
await initThreadPool(navigator.hardwareConcurrency);
await initLts();
});
Expand All @@ -24,7 +25,7 @@
features: [],
};
let maxRequests = 1000;
let maxRequests = 1000000;
// TODO When we load a network.bin, overwrite this
let cost = "Distance";
let controls = {
Expand Down
5 changes: 5 additions & 0 deletions wasm-od2net/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.wasm32-unknown-unknown]
rustflags = ["-C", "target-feature=+atomics,+bulk-memory,+mutable-globals"]

[unstable]
build-std = ["panic_abort", "std"]
1 change: 1 addition & 0 deletions wasm-od2net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ rstar = "0.11.0"
serde = "1.0.188"
serde-wasm-bindgen = "0.6.0"
wasm-bindgen = "0.2.87"
wasm-bindgen-rayon = "1.0.3"
web-sys = { version = "0.3.64", features = ["console"] }
3 changes: 2 additions & 1 deletion wasm-od2net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extern crate log;

use std::sync::Once;

pub use wasm_bindgen_rayon::init_thread_pool;
use instant::Instant;
use rstar::RTree;
use serde::Deserialize;
Expand Down Expand Up @@ -129,7 +130,7 @@ impl JsNetwork {
}
let routing_time = Instant::now().duration_since(routing_start);

info!("Got counts for {} edges", counts.count_per_edge.len());
info!("Got counts for {} edges in {:?}", counts.count_per_edge.len(), routing_time);
let output_metadata =
od2net::OutputMetadata::new(config, &counts, num_requests, routing_time);
let mut gj_bytes = Vec::new();
Expand Down

0 comments on commit 1cdbe79

Please sign in to comment.