Skip to content

Commit

Permalink
Better tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Apr 10, 2023
1 parent 1b5be78 commit 621d7a5
Show file tree
Hide file tree
Showing 12 changed files with 365 additions and 83 deletions.
17 changes: 10 additions & 7 deletions packages/perspective/src/js/perspective.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Decompress } from "fflate";
import wasm_worker from "../../src/js/perspective.worker.js";
import wasm from "../../dist/pkg/esm/perspective.cpp.wasm";

const INLINE_WARNING = `Perspective has been compiled in "inline" mode.`;
let IS_INLINE = false;

function is_gzip(buffer) {
return new Uint32Array(buffer.slice(0, 4))[0] == 559903;
Expand Down Expand Up @@ -53,7 +53,7 @@ const _override = /* @__PURE__ */ (function () {
}

if (_wasm.buffer && _wasm.buffer instanceof ArrayBuffer) {
console.info(INLINE_WARNING);
IS_INLINE = true;
if (is_gzip(_wasm.buffer)) {
decompressor.push(_wasm, true);
} else {
Expand Down Expand Up @@ -163,15 +163,18 @@ class WebWorkerClient extends Client {
this._worker = undefined;
}

get transferable() {
return this._worker?.transferable || false;
}

get inline() {
return IS_INLINE;
}

_detect_transferable() {
var ab = new ArrayBuffer(1);
this._worker.postMessage(ab, [ab]);
this._worker.transferable = ab.byteLength === 0;
if (!this._worker.transferable) {
console.warn("Transferable support not detected");
} else {
console.debug("Transferable support detected");
}
}
}

Expand Down
54 changes: 39 additions & 15 deletions rust/perspective-viewer/Cargo.lock

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

68 changes: 27 additions & 41 deletions rust/perspective-viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,26 @@ path = "src/rust/lib.rs"
define_custom_elements_async = []
default = []

[profile.dev]
panic = "abort"
opt-level = "s"

[profile.release]
panic = "abort"
opt-level = "z"
codegen-units = 1
lto = true
strip = true

[build-dependencies]
serde_json = { version = "1.0.59", features = ["raw_value"] }
procss = { version = "0.1.12" }
glob = "0.3.0"
anyhow = "1.0.66"

[dev-dependencies]
wasm-bindgen-test = "0.3.13"

[dependencies]
# Provides async `Mutex` for locked sections such as `render`
async-std = "1.9.0"
Expand Down Expand Up @@ -60,8 +74,8 @@ itertools = "0.10.1"
# Performance improvements for common string to JS conversions
js-intern = "0.3.1"

# Memoize Intl locales
lazy_static = "1.4.0"
# JavaScript stdlib bindings
js-sys = "0.3"

# Parse ExprTK for syntax highlighting.
nom = "7.1.1"
Expand All @@ -70,37 +84,33 @@ nom = "7.1.1"
num-format = "0.4.4"

# MessagePack serialization
rmp-serde = "0.15.5"
rmp-serde = "1.1.1"

# Serialization for tokens and JS APIs
serde = { version = "1.0", features = ["derive"] }

# Support for "unknown"/dictionary types such as `plugin_config`
serde_json = { version = "1.0.85", features = ["raw_value"] }

# Faster struct serialize/deserialize
serde-wasm-bindgen = "0.4.5"
# Async-aware logging that can be disabled at compile-time.
tracing = { version = ">=0.1.36", features = [
"release_max_level_error",
"max_level_info",
] }

# A JS console printer for `tracing`.
tracing-wasm = ">=0.2.1"
# Async-aware logging that can be disabled at compile-time.
tracing = { version = ">=0.1.36", features = ["release_max_level_error"] }
tracing-subscriber = "0.3.15"

# Browser API bindings
wasm-bindgen = { version = "=0.2.83", features = ["serde-serialize"] }

# Browser `Promise` bindings
wasm-bindgen-futures = "0.4.20"

# https://github.com/yewstack/yew/issues/2154
# Web framework
yew = { version = "0.20.0", features = ["csr"] }

[dependencies.web-sys]
version = "0.3.59"
features = [
# "Performance",
# Browser stdlib bindings
web-sys.version = "0.3.59"
web-sys.features = [
"Blob",
"Clipboard",
"CssStyleDeclaration",
Expand All @@ -116,34 +126,28 @@ features = [
"DomStringMap",
"DomTokenList",
"Element",
# "DomTokenList",
"Event",
"EventTarget",
"EventListener",
"FontFace",
"FontFaceSet",
"FontFaceSetIterator",
"FontFaceSetIteratorResult",
# "DocumentFragment",
"HtmlCollection",
"HtmlElement",
"HtmlTextAreaElement",
"HtmlStyleElement",
"HtmlSelectElement",
"InputEvent",
"KeyboardEvent",
# "MouseEvent",
"MutationObserver",
"MutationObserverInit",
"MutationRecord",
"Navigator",
"Node",
"NodeList",
'Performance',
# "TouchEvent",
# "TouchList",
# "Touch",
# "WheelEvent",
"Performance",
"PerformanceMark",
"Range",
"ReadableStreamDefaultReader",
"Selection",
Expand All @@ -156,21 +160,3 @@ features = [
"VisibilityState",
"Window",
]


[dependencies.js-sys]
version = "0.3"

[dev-dependencies]
wasm-bindgen-test = "0.3.13"

[profile.dev]
panic = "abort"
opt-level = "s"

[profile.release]
panic = "abort"
opt-level = "z"
codegen-units = 1
lto = true
strip = true
6 changes: 3 additions & 3 deletions rust/perspective-viewer/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2022-10-24"
components = [ "rustfmt", "clippy", "rust-src" ]
targets = [ "wasm32-unknown-unknown" ]
channel = "nightly-2023-04-07"
components = ["rustfmt", "clippy", "rust-src"]
targets = ["wasm32-unknown-unknown"]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// of the Apache License 2.0. The full license can be found in the LICENSE
// file.

use lazy_static::*;
use std::sync::LazyLock;

use wasm_bindgen::*;
use web_sys::*;
use yew::prelude::*;
Expand All @@ -28,20 +29,22 @@ extern "C" {
pub fn supported_values_of(s: &JsValue) -> js_sys::Array;
}

lazy_static! {
static ref ALL_TIMEZONES: Vec<SelectItem<String>> =
supported_values_of(&JsValue::from("timeZone"))
.iter()
.map(|x| SelectItem::Option(x.as_string().unwrap()))
.collect();
static ref USER_TIMEZONE: String = js_sys::Reflect::get(
static ALL_TIMEZONES: LazyLock<Vec<SelectItem<String>>> = LazyLock::new(|| {
supported_values_of(&JsValue::from("timeZone"))
.iter()
.map(|x| SelectItem::Option(x.as_string().unwrap()))
.collect()
});

static USER_TIMEZONE: LazyLock<String> = LazyLock::new(|| {
js_sys::Reflect::get(
&js_sys::Intl::DateTimeFormat::new(&json!([]), &json!({})).resolved_options(),
&JsValue::from("timeZone")
&JsValue::from("timeZone"),
)
.unwrap()
.as_string()
.unwrap();
}
.unwrap()
});

pub enum DatetimeColumnStyleMsg {
Reset(DatetimeColumnStyleConfig),
Expand Down
Loading

0 comments on commit 621d7a5

Please sign in to comment.