Skip to content

Fix: NotSameFileSystem at clonefile - #546

Merged
Jarred-Sumner merged 1 commit into
oven-sh:mainfrom
adi-g15:fix-notsamefs
Jul 11, 2022
Merged

Jarred-Sumner merged 1 commit into
oven-sh:mainfrom
adi-g15:fix-notsamefs

Conversation

@adi-g15

@adi-g15 adi-g15 commented Jul 10, 2022 •

Copy link
Copy Markdown
Contributor

Fixes #531

Before this, using 'bun install' on a directory in different filesystem
such as tmpfs (/tmp) would have caused "Error: NotSameFileSystem".

This commit fixes that by handling this error, and at end of function it
will fall back to use copyfile (same as --backend=copyfile).

The discussion is in #531 (comment).

Credit due to @Beamnawap, who suggested me about --backend=copyfile as a fix.

Note: I think this error (NotSameFileSystem) may occur in case of clonefile_each_dir too, and should be handled there similarly:

bun/src/install/install.zig

Lines 1085 to 1087 in f5d8965

error.NotSupported => {
supported_method = .copyfile;
},

changed to:

-error.NotSupported => {
+error.NotSameFileSystem, error.NotSupported => {
     supported_method = .copyfile;
},

Does it seem okay, should I add that in this PR?

Fixes issue oven-sh#531

Before this, using 'bun install' on a directory in different filesystem
such as tmpfs (/tmp) would have caused "Error: NotSameFileSystem".

This commit fixes that by handling this error, and at end of function it
will fall back to use copyfile (same as --backend=copyfile)
@Jarred-Sumner

Copy link
Copy Markdown
Collaborator

I don't think this actually fixes it because the error is not generated, but it would be worth making the returned error consistent here anyway

@Jarred-Sumner
Jarred-Sumner merged commit 2659feb into oven-sh:main Jul 11, 2022
@addy

addy commented Jul 11, 2022

Copy link
Copy Markdown
Contributor

FYI this just broke the build

Jarred-Sumner added a commit that referenced this pull request Jul 11, 2022
Jarred-Sumner added a commit that referenced this pull request Jul 11, 2022
Jarred-Sumner added a commit that referenced this pull request Sep 1, 2026
…e release + CodeBlock aging, #543 #548 module loader, #545, #529)
Jarred-Sumner added a commit that referenced this pull request Sep 1, 2026
)

Stacked on #40987 (WebKit upgrade) and pins WebKit to oven-sh/WebKit
`491b5cc236e9` — fork `main` with oven-sh/WebKit#542 / #546 / #547
(MarkedBlock page release, CodeBlock aging that reaches optimized code),
#543 / #548 (module loader), #545, #529.

### What

`GarbageCollectionController`'s repeating timer (1 s while the heap is
changing, 30 s once it isn't) already issues one `collectAsync` per tick
and reads `blockBytesAllocated`. This makes that one request a **full**
collection on two ticks per quiet period: when the JS heap hasn't grown
(by more than 2 MB) for `BUN_IDLE_RELEASE_SECONDS` (default 30; `0` =
off; main thread only; not while a debugger is attached), and again 65 s
of quiet later. The first also `MADV_PAGEOUT`s a standalone executable's
embedded module graph (Linux; clean file-backed pages that fault back on
demand; honours `BUN_FEATURE_FLAG_DISABLE_STANDALONE_MADVISE`). One
`u32` of state, no new timer, no syscalls or clock reads per tick; when
an idle collection is due before the next 30 s tick, that tick is pulled
forward.

### Why

Full collections are where JSC ages out CodeBlocks that no longer run
and releases the memory behind them (WebKit#542/#546). JSC's own
`FullGCActivityCallback` is allocation-paced — it fires at most once
after the last allocation burst and never again without new allocation —
so a process waiting for input never gets there. Two are the minimum
with sampled execution counters: the first records which code is still
running, the second (a lease later) frees what hasn't run since.

### Numbers

Large `--compile --bytecode` TUI app, 100 scripted turns, then 150 s
hands-off; same binary, three interleaved pairs:

| after 150 s idle | `BUN_IDLE_RELEASE_SECONDS=0` | default |
|---|---|---|
| RSS | 460 / 477 / 491 MB | **373 / 380 / 365 MB** |

With the feature on, RSS is ~400–440 MB after the first idle collection
(~50 s) and ~365–380 MB after the second (~110 s); JIT memory 45 → ~14
MB. Cost while busy: none. Cost while idle: two concurrent full GCs per
quiet period.

### Tests

`test/js/bun/gc/gc-controller-cadence.test.ts`: with `BUN_JSC_logGC=1`,
a `FullCollection` appears while a script sits idle with
`BUN_IDLE_RELEASE_SECONDS=2`, and none with `=0`.

---------

Co-authored-by: robobun <117481402+robobun@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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.

Projects on different file system: error: NotSameFileSystem

3 participants