zed/crates
Piotr Osiewicz 7b73e2824b
fs: allocate backing storage once in Fs::load (#9020)
`futures_lite::AsyncReadExt::read_to_string` (that we use in
`RealFs::load`) explicitly does not allocate memory for String contents
up front, which leads to excessive reallocations. That reallocation time
is a significant contributor to the time we spend loading files (esp
large ones). For example, out of ~1s that it takes to open up a 650Mb
ASCII buffer on my machine (after changes related to fingerprinting from
#9007), 350ms is spent in `RealFs::load`.
This change slashes that figure to ~110ms, which is still *a lot*. About
60ms out of 110ms remaining is spent zeroing memory. Sadly,
`AsyncReadExt` API forces us to zero a buffer we're reading into
(whether it's via read_to_string or read_exact), but at the very least
this commit alleviates unnecessary reallocations.

We could probably use something like
[simdutf8](https://docs.rs/simdutf8/latest/simdutf8/) to speed up UTF8
validation in this method as well, though that takes only about ~18ms
out of 110ms, so while it is significant, I've left that out for now.
Memory zeroing is a bigger problem at this point.

Before:

![image](https://github.com/zed-industries/zed/assets/24362066/5e53c004-8a02-47db-bc75-04cb4113a6bc)

After:

![image](https://github.com/zed-industries/zed/assets/24362066/00099032-d647-4683-b290-eaeb969cac4a)

/cc @as-cii 

Release Notes:

- Improved performance when loading large files.
2024-03-08 14:40:26 +01:00
..
activity_indicator Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
ai Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
assets Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
assistant Make anchor_in_excerpt Optional (#8975) 2024-03-06 18:55:36 -07:00
audio Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
auto_update Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
breadcrumbs Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
call Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
channel Fix joining hosted projects (#9038) 2024-03-07 19:56:41 -07:00
cli Remove todo! comments (#8981) 2024-03-06 18:25:20 -08:00
client Fix joining hosted projects (#9038) 2024-03-07 19:56:41 -07:00
clock Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
collab Fix joining hosted projects (#9038) 2024-03-07 19:56:41 -07:00
collab_ui Fix joining hosted projects (#9038) 2024-03-07 19:56:41 -07:00
collections Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
color Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
command_palette Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
command_palette_hooks Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
copilot Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
copilot_ui Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
db Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
diagnostics Make anchor_in_excerpt Optional (#8975) 2024-03-06 18:55:36 -07:00
editor Fix panic in open urls (#9032) 2024-03-07 13:52:50 -07:00
extension Fix extension store test failure on main due to wasi-sdk download 2024-03-07 10:53:28 -08:00
extension_api Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
extensions_ui Add a command for building and installing a locally-developed Zed extension (#8781) 2024-03-06 15:35:22 -08:00
feature_flags Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
feedback Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
file_finder Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
fs fs: allocate backing storage once in Fs::load (#9020) 2024-03-08 14:40:26 +01:00
fsevent Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
fuzzy Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
git Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
go_to_line Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
gpui Fix panic in layout_line when Y coordinate is too high (#9052) 2024-03-07 22:33:44 -07:00
gpui_macros Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
install_cli Remove todo! comments (#8981) 2024-03-06 18:25:20 -08:00
journal Fix panic in open urls (#9032) 2024-03-07 13:52:50 -07:00
language language: Track buffer dirty state based on edits, not on file contents 2024-03-07 14:11:35 +01:00
language_selector Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
language_tools Make anchor_in_excerpt Optional (#8975) 2024-03-06 18:55:36 -07:00
languages Add Elixir symbols in outline view (#8761) 2024-03-07 19:35:01 -07:00
live_kit_client Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
live_kit_server Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
lsp Always resolve code action if needed (#8904) 2024-03-05 23:42:12 +02:00
markdown_preview Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
media Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
menu Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
multi_buffer Make anchor_in_excerpt Optional (#8975) 2024-03-06 18:55:36 -07:00
node_runtime Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
notifications Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
outline Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
picker Small fixes to task modal & long commands (#8974) 2024-03-07 03:21:11 +02:00
prettier Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
project Fix joining hosted projects (#9038) 2024-03-07 19:56:41 -07:00
project_core Add a command for building and installing a locally-developed Zed extension (#8781) 2024-03-06 15:35:22 -08:00
project_panel Fix project panel icon bouncing when renaming (#8988) 2024-03-07 09:18:59 +01:00
project_symbols Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
quick_action_bar Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
recent_projects Fix panic in open urls (#9032) 2024-03-07 13:52:50 -07:00
refineable Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
release_channel Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
rich_text Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
rope Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
rpc Fix joining hosted projects (#9038) 2024-03-07 19:56:41 -07:00
search Update Project search to Project Search. (#8943) 2024-03-06 15:23:55 +01:00
semantic_index Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
settings Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
snippet Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
sqlez Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
sqlez_macros Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
story Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
storybook Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
sum_tree Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
task Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
tasks_ui Add ZED_SELECTED_TEXT variable to tasks (#8865) 2024-03-07 11:59:25 +01:00
telemetry_events Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
terminal Fix terminal on Windows (#8999) 2024-03-07 15:54:58 -08:00
terminal_view prevent empty cwd in terminal view (#8924) 2024-03-06 11:26:16 -08:00
text Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
theme Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
theme_importer Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
theme_selector Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
time_format Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
ui Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
util Make comment above util::fs::remove_matching a doc comment (#9051) 2024-03-07 21:15:52 -08:00
vcs_menu Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
vim vim: smartcase find option (#9033) 2024-03-07 19:44:20 -07:00
welcome Fix panic in open urls (#9032) 2024-03-07 13:52:50 -07:00
workspace Fix joining hosted projects (#9038) 2024-03-07 19:56:41 -07:00
zed Initial Linux nightly bundles upload (#8913) 2024-03-07 23:22:53 +02:00
zed_actions Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00