nushell/crates
Darren Schroeder 0c5a67f4e5
make polars plugin use mimalloc (#12967)
# Description
@maxim-uvarov did a ton of research and work with the dply-rs author and
ritchie from polars and found out that the allocator matters on macos
and it seems to be what was messing up the performance of polars plugin.
ritchie suggested to use jemalloc but i switched it to mimalloc to match
nushell and it seems to run better.

## Before (default allocator)
note - using 1..10 vs 1..100 since it takes so long. also notice how
high the `max` timings are compared to mimalloc below.
```nushell
❯ 1..10 | each {timeit {polars open Data7602DescendingYearOrder.csv | polars group-by year | polars agg (polars col geo_count | polars sum) | polars collect | null}} |   | {mean: ($in | math avg), min: ($in | math min), max: ($in | math max), stddev: ($in | into int | into float | math stddev | into int | $'($in)ns' | into duration)}
╭────────┬─────────────────────────╮
│ mean   │ 4sec 999ms 605µs 995ns  │
│ min    │ 983ms 627µs 42ns        │
│ max    │ 13sec 398ms 135µs 791ns │
│ stddev │ 3sec 476ms 479µs 939ns  │
╰────────┴─────────────────────────╯
❯ use std bench
❯ bench { polars open Data7602DescendingYearOrder.csv | polars group-by year | polars agg (polars col geo_count | polars sum) | polars collect | null } -n 10
╭───────┬────────────────────────╮
│ mean  │ 6sec 220ms 783µs 983ns │
│ min   │ 1sec 184ms 997µs 708ns │
│ max   │ 18sec 882ms 81µs 708ns │
│ std   │ 5sec 350ms 375µs 697ns │
│ times │ [list 10 items]        │
╰───────┴────────────────────────╯
```

## After (using mimalloc)
```nushell
❯ 1..100 | each {timeit {polars open Data7602DescendingYearOrder.csv | polars group-by year | polars agg (polars col geo_count | polars sum) | polars collect | null}} |   | {mean: ($in | math avg), min: ($in | math min), max: ($in | math max), stddev: ($in | into int | into float | math stddev | into int | $'($in)ns' | into duration)}
╭────────┬───────────────────╮
│ mean   │ 103ms 728µs 902ns │
│ min    │ 97ms 107µs 42ns   │
│ max    │ 149ms 430µs 84ns  │
│ stddev │ 5ms 690µs 664ns   │
╰────────┴───────────────────╯
❯ use std bench
❯ bench { polars open Data7602DescendingYearOrder.csv | polars group-by year | polars agg (polars col geo_count | polars sum) | polars collect | null } -n 100
╭───────┬───────────────────╮
│ mean  │ 103ms 620µs 195ns │
│ min   │ 97ms 541µs 166ns  │
│ max   │ 130ms 262µs 166ns │
│ std   │ 4ms 948µs 654ns   │
│ times │ [list 100 items]  │
╰───────┴───────────────────╯
```

## After (using jemalloc - just for comparison)
```nushell
❯ 1..100 | each {timeit {polars open Data7602DescendingYearOrder.csv | polars group-by year | polars agg (polars col geo_count | polars sum) | polars collect | null}} |   | {mean: ($in | math avg), min: ($in | math min), max: ($in | math max), stddev: ($in | into int | into float | math stddev | into int | $'($in)ns' | into duration)}

╭────────┬───────────────────╮
│ mean   │ 113ms 939µs 777ns │
│ min    │ 108ms 337µs 333ns │
│ max    │ 166ms 467µs 458ns │
│ stddev │ 6ms 175µs 618ns   │
╰────────┴───────────────────╯
❯ use std bench
❯ bench { polars open Data7602DescendingYearOrder.csv | polars group-by year | polars agg (polars col geo_count | polars sum) | polars collect | null } -n 100
╭───────┬───────────────────╮
│ mean  │ 114ms 363µs 530ns │
│ min   │ 108ms 804µs 833ns │
│ max   │ 143ms 521µs 459ns │
│ std   │ 5ms 88µs 56ns     │
│ times │ [list 100 items]  │
╰───────┴───────────────────╯
```

## After (using parquet + mimalloc)
```nushell
❯ 1..100 | each {timeit {polars open data.parquet | polars group-by year | polars agg (polars col geo_count | polars sum) | polars collect | null}} |   | {mean: ($in | math avg), min: ($in | math min), max: ($in | math max), stddev: ($in | into int | into float | math stddev | into int | $'($in)ns' | into duration)}
╭────────┬──────────────────╮
│ mean   │ 34ms 255µs 492ns │
│ min    │ 31ms 787µs 250ns │
│ max    │ 76ms 408µs 416ns │
│ stddev │ 4ms 472µs 916ns  │
╰────────┴──────────────────╯
❯ use std bench
❯ bench { polars open data.parquet | polars group-by year | polars agg (polars col geo_count | polars sum) | polars collect | null } -n 100
╭───────┬──────────────────╮
│ mean  │ 34ms 897µs 562ns │
│ min   │ 31ms 518µs 542ns │
│ max   │ 65ms 943µs 625ns │
│ std   │ 3ms 450µs 741ns  │
│ times │ [list 100 items] │
╰───────┴──────────────────╯
```

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2024-05-25 09:10:01 -05:00
..
nu_plugin_custom_values Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_example Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
nu_plugin_formats Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_gstat Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_inc Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_nu_example Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_polars make polars plugin use mimalloc (#12967) 2024-05-25 09:10:01 -05:00
nu_plugin_python Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_query Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu_plugin_stress_internals Upgrade to interprocess 2.0.0 (#12729) 2024-05-02 22:31:33 -07:00
nu-cli Revert "Remove std::env::set_current_dir() call from EngineState::merge_env()" (#12954) 2024-05-24 11:09:59 -05:00
nu-cmd-base Revert "Remove std::env::set_current_dir() call from EngineState::merge_env()" (#12954) 2024-05-24 11:09:59 -05:00
nu-cmd-extra Make get_full_help take &dyn Command (#12903) 2024-05-19 19:56:33 +02:00
nu-cmd-lang Revert "Remove std::env::set_current_dir() call from EngineState::merge_env()" (#12954) 2024-05-24 11:09:59 -05:00
nu-cmd-plugin Make get_full_help take &dyn Command (#12903) 2024-05-19 19:56:33 +02:00
nu-color-config Replace ExternalStream with new ByteStream type (#12774) 2024-05-16 07:11:18 -07:00
nu-command Do not propagate glob creation error for external args (#12955) 2024-05-25 08:59:36 +08:00
nu-engine Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
nu-explore explore refactoring+clarification (#12940) 2024-05-23 08:51:39 -05:00
nu-glob Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-json Minimize future false positive typos (#12751) 2024-05-04 15:00:44 +00:00
nu-lsp Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
nu-parser Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
nu-path Fix trailing slash in PWD set by cd (#12760) 2024-05-04 12:38:37 +03:00
nu-plugin Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
nu-plugin-core Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
nu-plugin-engine Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
nu-plugin-protocol Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
nu-plugin-test-support Replace ExternalStream with new ByteStream type (#12774) 2024-05-16 07:11:18 -07:00
nu-pretty-hex Add string/binary type color to ByteStream (#12897) 2024-05-20 00:35:32 +00:00
nu-protocol Allow byte streams with unknown type to be compatiable with binary (#12959) 2024-05-24 17:54:38 -07:00
nu-std Revert "Remove std::env::set_current_dir() call from EngineState::merge_env()" (#12954) 2024-05-24 11:09:59 -05:00
nu-system Add support for the ps command on FreeBSD, NetBSD, and OpenBSD (#12892) 2024-05-22 08:13:45 -07:00
nu-table Avoid taking unnecessary ownership of intermediates (#12740) 2024-05-04 00:53:15 +00:00
nu-term-grid Bump version to 0.93.1 (#12710) 2024-05-01 17:19:20 -05:00
nu-test-support Exclude polars from ensure_plugins_built(), for performance reasons (#12896) 2024-05-17 15:04:59 +00:00
nu-utils overhaul shell_integration to enable individual control over ansi escape sequences (#12629) 2024-05-02 09:56:50 -04:00
nuon Shrink Value by boxing Range/Closure (#12784) 2024-05-09 08:10:58 +08:00
README.md Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00

Nushell core libraries and plugins

These sub-crates form both the foundation for Nu and a set of plugins which extend Nu with additional functionality.

Foundational libraries are split into two kinds of crates:

  • Core crates - those crates that work together to build the Nushell language engine
  • Support crates - a set of crates that support the engine with additional features like JSON support, ANSI support, and more.

Plugins are likewise also split into two types:

  • Core plugins - plugins that provide part of the default experience of Nu, including access to the system properties, processes, and web-connectivity features.
  • Extra plugins - these plugins run a wide range of different capabilities like working with different file types, charting, viewing binary data, and more.