Skip to content

Commit 6643f02

Browse files
committed
[PIPEFS] Reduce garbage generation
The current PIPEFS `read()` implementation seems to produce excessive garbage with use cases such as write several bytes, read everything, write, read..., since it everytime throws away an almost empty 8Kb buffer. This commit addes a fix proposed by @cynecx.
1 parent 5e0a6d5 commit 6643f02

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/library_pipefs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ mergeInto(LibraryManager.library, {
116116
}
117117
}
118118

119+
if (toRemove && toRemove == pipe.buckets.length) {
120+
// Do not generate excessive garbage in use cases such as
121+
// write several bytes, read everything, write several bytes, read everything...
122+
toRemove--;
123+
pipe.buckets[toRemove].offset = 0;
124+
pipe.buckets[toRemove].roffset = 0;
125+
}
126+
119127
while (toRemove--) {
120128
pipe.buckets.shift();
121129
}

0 commit comments

Comments
 (0)