2021-01-10 02:50:49 +00:00
|
|
|
[package]
|
2022-03-22 20:25:38 +00:00
|
|
|
authors = ["The Nushell Project Developers"]
|
2022-04-11 18:17:06 +00:00
|
|
|
description = "Nushell's evaluation engine"
|
2022-08-14 12:21:20 +00:00
|
|
|
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-engine"
|
2022-03-22 20:25:38 +00:00
|
|
|
edition = "2021"
|
|
|
|
license = "MIT"
|
2021-01-10 02:50:49 +00:00
|
|
|
name = "nu-engine"
|
2023-02-21 23:21:39 +00:00
|
|
|
version = "0.76.1"
|
2021-08-10 18:51:08 +00:00
|
|
|
|
2023-02-12 22:22:00 +00:00
|
|
|
[lib]
|
|
|
|
bench = false
|
|
|
|
|
2021-08-10 18:51:08 +00:00
|
|
|
[dependencies]
|
2023-02-21 23:21:39 +00:00
|
|
|
nu-protocol = { path = "../nu-protocol", features = ["plugin"], version = "0.76.1" }
|
|
|
|
nu-path = { path = "../nu-path", version = "0.76.1" }
|
|
|
|
nu-glob = { path = "../nu-glob", version = "0.76.1" }
|
|
|
|
nu-utils = { path = "../nu-utils", version = "0.76.1" }
|
2022-03-13 18:30:27 +00:00
|
|
|
|
2022-11-26 18:19:02 +00:00
|
|
|
chrono = { version="0.4.23", features = ["std"], default-features = false }
|
LazyRecord (#7619)
This is an attempt to implement a new `Value::LazyRecord` variant for
performance reasons.
`LazyRecord` is like a regular `Record`, but it's possible to access
individual columns without evaluating other columns. I've implemented
`LazyRecord` for the special `$nu` variable; accessing `$nu` is
relatively slow because of all the information in `scope`, and [`$nu`
accounts for about 2/3 of Nu's startup time on
Linux](https://github.com/nushell/nushell/issues/6677#issuecomment-1364618122).
### Benchmarks
I ran some benchmarks on my desktop (Linux, 12900K) and the results are
very pleasing.
Nu's time to start up and run a command (`cargo build --release;
hyperfine 'target/release/nu -c "echo \"Hello, world!\""' --shell=none
--warmup 10`) goes from **8.8ms to 3.2ms, about 2.8x faster**.
Tests are also much faster! Running `cargo nextest` (with our very slow
`proptest` tests disabled) goes from **7.2s to 4.4s (1.6x faster)**,
because most tests involve launching a new instance of Nu.
### Design (updated)
I've added a new `LazyRecord` trait and added a `Value` variant wrapping
those trait objects, much like `CustomValue`. `LazyRecord`
implementations must implement these 2 functions:
```rust
// All column names
fn column_names(&self) -> Vec<&'static str>;
// Get 1 specific column value
fn get_column_value(&self, column: &str) -> Result<Value, ShellError>;
```
### Serializability
`Value` variants must implement `Serializable` and `Deserializable`, which poses some problems because I want to use unserializable things like `EngineState` in `LazyRecord`s. To work around this, I basically lie to the type system:
1. Add `#[typetag::serde(tag = "type")]` to `LazyRecord` to make it serializable
2. Any unserializable fields in `LazyRecord` implementations get marked with `#[serde(skip)]`
3. At the point where a `LazyRecord` normally would get serialized and sent to a plugin, I instead collect it into a regular `Value::Record` (which can be serialized)
2023-01-19 03:27:26 +00:00
|
|
|
serde = {version = "1.0.143", default-features = false }
|
2023-02-20 02:58:07 +00:00
|
|
|
sysinfo ="0.28.0"
|
2021-12-02 06:35:32 +00:00
|
|
|
|
|
|
|
[features]
|
|
|
|
plugin = []
|