You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nushell performance degrades when storing large tables in variables #9048
Storing large tables into variables in nushell causes all other operations to slow down.
How to reproduce
Run the python code to produce a very large fake data file
Run let table = (open data.jsonl | lines | each {|row| $row | from json} | flatten)
Run ls and observe slowdown
Expected behavior
I expect nushell to take time processing large files, but after a file has been processes and stored in memory, I wouldn't expect all other operations to slow down.
Screenshots
No response
Configuration
key
value
version
0.78.0
branch
commit_hash
build_os
macos-aarch64
build_target
aarch64-apple-darwin
rust_version
rustc 1.68.2 (9eb3afe9e 2023-03-27) (built from a source tarball)
No problem, it probably can be reduced to just a flat file with no nesting, since running the commands to manipulate the data don't introduce the slowdown - its only storing the data the introduces it.
5 million rows is enormous for our current setup. I'm sure if the dataframe stuff can handle jsonl currently (update: just tried it and seems like it doesn't support jsonl by default).
To work with data of the size, you should definitely be streaming it and pulling out the parts you need. If you try to hold this in memory, you'll likely grow your memory usage sky high. Rule of thumb: Each element of data has not only its data, but also the span it comes from. I'd estimate to full load this into a variable, would push Nushell into the gigabytes of memory usage?
So let's stream this rather than actually consuming the whole thing. There are a few solutions, but here's the one that worked okay for me:
open data.jsonl --raw | lines | each { from json } | group 10 | flatten | flatten
The index on the left will repeat, but you should still be able to do things like | first 1000 and get a block of the first 1000 rows.
But yeah, the short answer is that for something this large you should use dataframes. Nushell isn't memory-efficient enough to do large datasets using the standard data types.
Another way to think about the performance impact:
Currently, in Nushell, we store a span (start and end location in the original source) with each value. So for this example, that's one for each cell, then also another for each row (which is a record). Assuming no other metadata that's nearly a 900 megabytes of just span information. Add to that the overhead of each value being a Value enum not just the data itself. It'll grow to be quite large.
This is another reason we encourage folks to use dataframes for large amounts of data, as that will both a) not have the span info, and b) will use a more compact in-memory representation of the data it does have.
Holding a large table in a variable no longer slows down every later command since #11654.
I checked with 500k rows of the sample data and the prompt stayed under 10 ms.
Activity
JosephTLyons commentedon Apr 28, 2023
Btw, loving nushell for doing all sorts of manipulation of real-world data. Super cool to be putting nushell to work like this.
fdncred commentedon Apr 28, 2023
Thanks @JosephTLyons. This is a great sample case. I'm experiencing the slowdown now.
JosephTLyons commentedon Apr 28, 2023
No problem, it probably can be reduced to just a flat file with no nesting, since running the commands to manipulate the data don't introduce the slowdown - its only storing the data the introduces it.
bobhy commentedon Apr 29, 2023
Perfmon shows your system is not driven into swapping?
amtoine commentedon Apr 29, 2023
sheeeesh @JosephTLyons, the file is so big, even the
let table = (...)crashes my computer 😆could the slowdonw be caused by the memory being full? 🤔
fdncred commentedon Apr 29, 2023
I have 32GB of memory on my mac, so running out of memory isn't the problem for me.
It does take a lot of memory though.

Every command after loading that file takes about 10 seconds
sophiajt commentedon Apr 30, 2023
I see a few things:
So let's stream this rather than actually consuming the whole thing. There are a few solutions, but here's the one that worked okay for me:
open data.jsonl --raw | lines | each { from json } | group 10 | flatten | flattenThe index on the left will repeat, but you should still be able to do things like
| first 1000and get a block of the first 1000 rows.But yeah, the short answer is that for something this large you should use dataframes. Nushell isn't memory-efficient enough to do large datasets using the standard data types.
sophiajt commentedon Apr 30, 2023
Another way to think about the performance impact:
Currently, in Nushell, we store a span (start and end location in the original source) with each value. So for this example, that's one for each cell, then also another for each row (which is a record). Assuming no other metadata that's nearly a 900 megabytes of just span information. Add to that the overhead of each value being a Value enum not just the data itself. It'll grow to be quite large.
This is another reason we encourage folks to use dataframes for large amounts of data, as that will both a) not have the span info, and b) will use a more compact in-memory representation of the data it does have.
kronberger-droid commentedon Nov 14, 2026
Holding a large table in a variable no longer slows down every later command since #11654.
I checked with 500k rows of the sample data and the prompt stayed under 10 ms.