Merge branch 'main' into pierremtb/adhoc/use-less-namespace-resources
This commit is contained in:
27
rust/Cargo.lock
generated
27
rust/Cargo.lock
generated
@ -2194,6 +2194,17 @@ dependencies = [
|
||||
"crc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lzma-sys"
|
||||
version = "0.1.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "measurements"
|
||||
version = "0.11.0"
|
||||
@ -4862,6 +4873,15 @@ version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547"
|
||||
|
||||
[[package]]
|
||||
name = "xz2"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2"
|
||||
dependencies = [
|
||||
"lzma-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
version = "0.4.5"
|
||||
@ -5006,9 +5026,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "2.2.3"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b280484c454e74e5fff658bbf7df8fdbe7a07c6b2de4a53def232c15ef138f3a"
|
||||
checksum = "938cc23ac49778ac8340e366ddc422b2227ea176edb447e23fc0627608dddadd"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"arbitrary",
|
||||
@ -5019,15 +5039,16 @@ dependencies = [
|
||||
"deflate64",
|
||||
"displaydoc",
|
||||
"flate2",
|
||||
"getrandom 0.3.1",
|
||||
"hmac",
|
||||
"indexmap 2.8.0",
|
||||
"lzma-rs",
|
||||
"memchr",
|
||||
"pbkdf2",
|
||||
"rand 0.8.5",
|
||||
"sha1",
|
||||
"thiserror 2.0.12",
|
||||
"time",
|
||||
"xz2",
|
||||
"zeroize",
|
||||
"zopfli",
|
||||
"zstd",
|
||||
|
||||
@ -49,7 +49,7 @@ tokio = { version = "1" }
|
||||
tower-lsp = { version = "0.20.0", default-features = false }
|
||||
tracing-subscriber = { version = "0.3.19", features = ["registry", "std", "fmt", "smallvec", "ansi", "tracing-log", "json"] }
|
||||
uuid = { version = "1", features = ["v4", "serde"] }
|
||||
zip = { version = "2.2.2", default-features = false }
|
||||
zip = { version = "2.4.1", default-features = false }
|
||||
|
||||
[workspace.lints.clippy]
|
||||
assertions_on_result_states = "warn"
|
||||
|
||||
@ -18,7 +18,7 @@ use tokio::sync::{mpsc, oneshot, RwLock};
|
||||
use tokio_tungstenite::tungstenite::Message as WsMsg;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::ExecutionKind;
|
||||
use super::{EngineStats, ExecutionKind};
|
||||
use crate::{
|
||||
engine::EngineManager,
|
||||
errors::{KclError, KclErrorDetails},
|
||||
@ -52,6 +52,7 @@ pub struct EngineConnection {
|
||||
session_data: Arc<RwLock<Option<ModelingSessionData>>>,
|
||||
|
||||
execution_kind: Arc<RwLock<ExecutionKind>>,
|
||||
stats: EngineStats,
|
||||
}
|
||||
|
||||
pub struct TcpRead {
|
||||
@ -344,6 +345,7 @@ impl EngineConnection {
|
||||
default_planes: Default::default(),
|
||||
session_data,
|
||||
execution_kind: Default::default(),
|
||||
stats: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -378,6 +380,10 @@ impl EngineManager for EngineConnection {
|
||||
original
|
||||
}
|
||||
|
||||
fn stats(&self) -> &EngineStats {
|
||||
&self.stats
|
||||
}
|
||||
|
||||
fn get_default_planes(&self) -> Arc<RwLock<Option<DefaultPlanes>>> {
|
||||
self.default_planes.clone()
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ use kittycad_modeling_cmds::{self as kcmc};
|
||||
use tokio::sync::RwLock;
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::ExecutionKind;
|
||||
use super::{EngineStats, ExecutionKind};
|
||||
use crate::{
|
||||
errors::KclError,
|
||||
exec::DefaultPlanes,
|
||||
@ -32,6 +32,7 @@ pub struct EngineConnection {
|
||||
execution_kind: Arc<RwLock<ExecutionKind>>,
|
||||
/// The default planes for the scene.
|
||||
default_planes: Arc<RwLock<Option<DefaultPlanes>>>,
|
||||
stats: EngineStats,
|
||||
}
|
||||
|
||||
impl EngineConnection {
|
||||
@ -42,6 +43,7 @@ impl EngineConnection {
|
||||
artifact_commands: Arc::new(RwLock::new(Vec::new())),
|
||||
execution_kind: Default::default(),
|
||||
default_planes: Default::default(),
|
||||
stats: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -60,6 +62,10 @@ impl crate::engine::EngineManager for EngineConnection {
|
||||
Arc::new(RwLock::new(IndexMap::new()))
|
||||
}
|
||||
|
||||
fn stats(&self) -> &EngineStats {
|
||||
&self.stats
|
||||
}
|
||||
|
||||
fn artifact_commands(&self) -> Arc<RwLock<Vec<ArtifactCommand>>> {
|
||||
self.artifact_commands.clone()
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ use uuid::Uuid;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use crate::{
|
||||
engine::ExecutionKind,
|
||||
engine::{EngineStats, ExecutionKind},
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{ArtifactCommand, DefaultPlanes, IdGenerator},
|
||||
SourceRange,
|
||||
@ -45,6 +45,7 @@ pub struct EngineConnection {
|
||||
execution_kind: Arc<RwLock<ExecutionKind>>,
|
||||
/// The default planes for the scene.
|
||||
default_planes: Arc<RwLock<Option<DefaultPlanes>>>,
|
||||
stats: EngineStats,
|
||||
}
|
||||
|
||||
// Safety: WebAssembly will only ever run in a single-threaded context.
|
||||
@ -62,6 +63,7 @@ impl EngineConnection {
|
||||
artifact_commands: Arc::new(RwLock::new(Vec::new())),
|
||||
execution_kind: Default::default(),
|
||||
default_planes: Default::default(),
|
||||
stats: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -141,6 +143,10 @@ impl crate::engine::EngineManager for EngineConnection {
|
||||
self.responses.clone()
|
||||
}
|
||||
|
||||
fn stats(&self) -> &EngineStats {
|
||||
&self.stats
|
||||
}
|
||||
|
||||
fn artifact_commands(&self) -> Arc<RwLock<Vec<ArtifactCommand>>> {
|
||||
self.artifact_commands.clone()
|
||||
}
|
||||
|
||||
@ -8,7 +8,13 @@ pub mod conn_mock;
|
||||
#[cfg(feature = "engine")]
|
||||
pub mod conn_wasm;
|
||||
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
use indexmap::IndexMap;
|
||||
use kcmc::{
|
||||
@ -58,6 +64,21 @@ impl ExecutionKind {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct EngineStats {
|
||||
pub commands_batched: AtomicUsize,
|
||||
pub batches_sent: AtomicUsize,
|
||||
}
|
||||
|
||||
impl Clone for EngineStats {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
commands_batched: AtomicUsize::new(self.commands_batched.load(Ordering::Relaxed)),
|
||||
batches_sent: AtomicUsize::new(self.batches_sent.load(Ordering::Relaxed)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
/// Get the batch of commands to be sent to the engine.
|
||||
@ -97,6 +118,8 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
/// Get the default planes.
|
||||
fn get_default_planes(&self) -> Arc<RwLock<Option<DefaultPlanes>>>;
|
||||
|
||||
fn stats(&self) -> &EngineStats;
|
||||
|
||||
/// Get the default planes, creating them if they don't exist.
|
||||
async fn default_planes(
|
||||
&self,
|
||||
@ -254,6 +277,7 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
|
||||
// Add cmd to the batch.
|
||||
self.batch().write().await.push((req, source_range));
|
||||
self.stats().commands_batched.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -277,6 +301,9 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
for cmd in cmds {
|
||||
extended_cmds.push((WebSocketRequest::ModelingCmdReq(cmd.clone()), source_range));
|
||||
}
|
||||
self.stats()
|
||||
.commands_batched
|
||||
.fetch_add(extended_cmds.len(), Ordering::Relaxed);
|
||||
self.batch().write().await.extend(extended_cmds);
|
||||
|
||||
Ok(())
|
||||
@ -303,6 +330,7 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
|
||||
// Add cmd to the batch end.
|
||||
self.batch_end().write().await.insert(id, (req, source_range));
|
||||
self.stats().commands_batched.fetch_add(1, Ordering::Relaxed);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -405,6 +433,7 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
||||
if batch_end {
|
||||
self.batch_end().write().await.clear();
|
||||
}
|
||||
self.stats().batches_sent.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
// We pop off the responses to cleanup our mappings.
|
||||
match final_req {
|
||||
|
||||
@ -750,6 +750,7 @@ impl ExecutorContext {
|
||||
"Post interpretation KCL memory stats: {:#?}",
|
||||
exec_state.stack().memory.stats
|
||||
));
|
||||
crate::log::log(format!("Engine stats: {:?}", self.engine.stats()));
|
||||
|
||||
if !self.is_mock() {
|
||||
let mut mem = exec_state.stack().deep_clone();
|
||||
|
||||
@ -81,7 +81,7 @@ mod walk;
|
||||
mod wasm;
|
||||
|
||||
pub use coredump::CoreDump;
|
||||
pub use engine::{EngineManager, ExecutionKind};
|
||||
pub use engine::{EngineManager, EngineStats, ExecutionKind};
|
||||
pub use errors::{
|
||||
CompilationError, ConnectionError, ExecError, KclError, KclErrorWithOutputs, Report, ReportWithOutputs,
|
||||
};
|
||||
|
||||
@ -11,7 +11,13 @@ use kcl_lib::{ExecState, ExecutorContext, ExecutorSettings, Program};
|
||||
async fn main() {
|
||||
let mut args = env::args();
|
||||
args.next();
|
||||
let filename = args.next().unwrap_or_else(|| "main.kcl".to_owned());
|
||||
let mut filename = args.next().unwrap_or_else(|| "main.kcl".to_owned());
|
||||
if !filename.ends_with(".kcl") {
|
||||
if !filename.ends_with('/') && !filename.ends_with('\\') {
|
||||
filename += "/";
|
||||
}
|
||||
filename += "main.kcl";
|
||||
}
|
||||
|
||||
let mut f = File::open(&filename).unwrap();
|
||||
let mut text = String::new();
|
||||
|
||||
@ -8,9 +8,9 @@ mod TEST_NAME_HERE {
|
||||
}
|
||||
|
||||
/// Test that parsing and unparsing KCL produces the original KCL input.
|
||||
#[test]
|
||||
fn unparse() {
|
||||
super::unparse(TEST_NAME)
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn unparse() {
|
||||
super::unparse(TEST_NAME).await
|
||||
}
|
||||
|
||||
/// Test that KCL is executed correctly.
|
||||
|
||||
@ -4,7 +4,7 @@ use anyhow::Result;
|
||||
use indexmap::IndexMap;
|
||||
use kcl_lib::{
|
||||
exec::{ArtifactCommand, DefaultPlanes, IdGenerator},
|
||||
ExecutionKind, KclError,
|
||||
EngineStats, ExecutionKind, KclError,
|
||||
};
|
||||
use kittycad_modeling_cmds::{
|
||||
self as kcmc,
|
||||
@ -26,6 +26,7 @@ pub struct EngineConnection {
|
||||
execution_kind: Arc<RwLock<ExecutionKind>>,
|
||||
/// The default planes for the scene.
|
||||
default_planes: Arc<RwLock<Option<DefaultPlanes>>>,
|
||||
stats: EngineStats,
|
||||
}
|
||||
|
||||
impl EngineConnection {
|
||||
@ -38,6 +39,7 @@ impl EngineConnection {
|
||||
core_test: result,
|
||||
execution_kind: Default::default(),
|
||||
default_planes: Default::default(),
|
||||
stats: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@ -369,6 +371,10 @@ impl kcl_lib::EngineManager for EngineConnection {
|
||||
Arc::new(RwLock::new(IndexMap::new()))
|
||||
}
|
||||
|
||||
fn stats(&self) -> &EngineStats {
|
||||
&self.stats
|
||||
}
|
||||
|
||||
fn artifact_commands(&self) -> Arc<RwLock<Vec<ArtifactCommand>>> {
|
||||
Arc::new(RwLock::new(Vec::new()))
|
||||
}
|
||||
|
||||
@ -371,6 +371,11 @@ export class SceneEntities {
|
||||
const yAxisMesh = new Mesh(yAxisGeometry, yAxisMaterial)
|
||||
xAxisMesh.renderOrder = -2
|
||||
yAxisMesh.renderOrder = -1
|
||||
|
||||
// This makes sure axis lines are picked after segment lines in case of overlapping
|
||||
xAxisMesh.position.z = -0.1
|
||||
yAxisMesh.position.z = -0.1
|
||||
|
||||
xAxisMesh.userData = {
|
||||
type: X_AXIS,
|
||||
baseColor: baseXColor,
|
||||
|
||||
Reference in New Issue
Block a user