This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Commit c830dc2
committed
Use ArrayPool in FileStream.CopyToAsync
Rather than allocating a new buffer in CopyToAsync, take one from the shared array pool. This drastically reduces the memory allocation from a FileStream.CopyToAsync operation, and helps to improve throughput as a result. In one microbenchmark that repeatedly copied an 80K file with CopyToAsync's default args, throughput increased by 20% and gen0 GCs decreased by 100x.1 parent 775331b commit c830dc2
File tree
4 files changed
+8
-3
lines changed- src/System.IO.FileSystem/src
- System/IO
- netcore50
- win
4 files changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
1775 | 1776 | | |
1776 | 1777 | | |
1777 | 1778 | | |
1778 | | - | |
| 1779 | + | |
1779 | 1780 | | |
1780 | 1781 | | |
1781 | 1782 | | |
1782 | 1783 | | |
1783 | | - | |
1784 | | - | |
| 1784 | + | |
| 1785 | + | |
1785 | 1786 | | |
1786 | 1787 | | |
1787 | 1788 | | |
| |||
1914 | 1915 | | |
1915 | 1916 | | |
1916 | 1917 | | |
| 1918 | + | |
1917 | 1919 | | |
1918 | 1920 | | |
1919 | 1921 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
0 commit comments