[PR #373] [MERGED] use buffered IO when loading and saving config #502

Closed
opened 2026-02-28 14:33:14 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jpochyla/psst/pull/373
Author: @HookedBehemoth
Created: 1/28/2023
Status: Merged
Merged: 1/29/2023
Merged by: @Insprill

Base: masterHead: perf/buf-cfg-io


📝 Commits (1)

  • 82e38f2 use buffered IO when loading and saving config

📊 Changes

1 file changed (+5 additions, -2 deletions)

View changed files

📝 psst-gui/src/data/config.rs (+5 -2)

📄 Description

As per https://docs.rs/serde_json/latest/serde_json/fn.from_reader.html

The content of the IO stream is deserialized directly from the stream without being buffered in memory by serde_json.

When reading from a source against which short reads are not efficient, such as a File, you will want to apply your own buffering because serde_json will not buffer the input. See std::io::BufReader.

This is also true for to_writer_pretty.

In my minimal testing, this shaved off 1000 syscalls and 15ms of the launch time. Especially reading was pretty bad as it read one byte at a time.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jpochyla/psst/pull/373 **Author:** [@HookedBehemoth](https://github.com/HookedBehemoth) **Created:** 1/28/2023 **Status:** ✅ Merged **Merged:** 1/29/2023 **Merged by:** [@Insprill](https://github.com/Insprill) **Base:** `master` ← **Head:** `perf/buf-cfg-io` --- ### 📝 Commits (1) - [`82e38f2`](https://github.com/jpochyla/psst/commit/82e38f23ca3c571348960f315e373c085eb4167f) use buffered IO when loading and saving config ### 📊 Changes **1 file changed** (+5 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `psst-gui/src/data/config.rs` (+5 -2) </details> ### 📄 Description As per https://docs.rs/serde_json/latest/serde_json/fn.from_reader.html > The content of the IO stream is deserialized directly from the stream without being buffered in memory by serde_json. > > When reading from a source against which short reads are not efficient, such as a [File](https://doc.rust-lang.org/std/fs/struct.File.html), you will want to apply your own buffering because serde_json will not buffer the input. See [std::io::BufReader](https://doc.rust-lang.org/std/io/struct.BufReader.html). This is also true for `to_writer_pretty`. In my minimal testing, this shaved off 1000 syscalls and 15ms of the launch time. Especially reading was pretty bad as it read one byte at a time. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 14:33:14 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/psst#502
No description provided.