Skip to content

Move instead of copy when committing a SafeFileOutputStream - #2961

Merged
vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:safe-file-output-stream-move
Sep 22, 2026
Merged

vogella merged 1 commit into
eclipse-platform:masterfrom
vogella:safe-file-output-stream-move

Conversation

@vogella

@vogella vogella commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

SafeFileOutputStream committed by copying the temporary file over the target and deleting it afterwards, so every byte was written twice. The workspace save writes the workspace tree and the per-project .markers and .syncinfo files through this stream, so the duplicate write is paid on every save and every snapshot. The commit now renames the temporary file, falling back to a replacing move and then to the previous copy, which halves the writes and also avoids leaving a partially copied target behind after a crash. The core.resources bundle builds, and SafeFileInputOutputStreamTest, SafeChunkyInputOutputStreamTest and LocalStoreRegressionTests pass locally

Contributes to #2887

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The bundle version must be incremented for this significant performance change.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Optimizes workspace persistence by moving temporary files instead of copying them during commit.

Changes:

  • Tries an atomic move first.
  • Falls back to replacing move, then copy.
File Description
resources/​bundles/​org.eclipse.core.resources/​src/​org/​eclipse/​core/​internal/​localstore/​SafeFileOutputStream.java Adds move-based commit paths to reduce writes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@iloveeclipse

Copy link
Copy Markdown
Member

Interestingly, the double work was introduced in 73c56a3 . Before this commit, the code used sourceFile.renameTo(destinationFile)) .

@github-actions

github-actions Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  +  3      54 suites  +3   57m 59s ⏱️ + 3m 1s
 4 811 tests ±  0   4 789 ✅ +  1   22 💤 ±0  0 ❌  - 1 
12 324 runs  +261  12 171 ✅ +262  153 💤 ±0  0 ❌  - 1 

Results for commit 5ea80d2. ± Comparison against base commit 6e4cd9b.

♻️ This comment has been updated with latest results.

@vogella
vogella force-pushed the safe-file-output-stream-move branch from 36fbb55 to 722404a Compare September 21, 2026 22:11
The commit step copied the temporary file over the target and then deleted
it, so every byte was written twice. The workspace save uses this stream for
the workspace tree and the .markers and .syncinfo files of every project, so
the extra write is paid on every save and every snapshot. A crash during the
copy could also leave a partially written target, which the recovery in the
constructor never repairs because it only acts when the target is missing.

Rename the temporary file atomically instead, and fall back to the previous
copy only when the file system cannot move it atomically.

Contributes to eclipse-platform#2887

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@vogella
vogella force-pushed the safe-file-output-stream-move branch from 722404a to 5ea80d2 Compare September 21, 2026 23:05
@vogella

vogella commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Removed the silent fallbacks: only the case where an atomic move isn't supported falls back to the copy, and any other failure is reported to the caller.

@vogella
vogella merged commit df561d3 into eclipse-platform:master Sep 22, 2026
18 checks passed
@vogella
vogella deleted the safe-file-output-stream-move branch September 22, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants