turbopipe 1.0.4__cp39-cp39-win_amd64.whl → 1.1.0__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of turbopipe might be problematic. Click here for more details.
- turbopipe/__init__.py +7 -4
- turbopipe/_turbopipe.cp39-win_amd64.pyd +0 -0
- turbopipe-1.1.0.dist-info/METADATA +372 -0
- turbopipe-1.1.0.dist-info/RECORD +7 -0
- turbopipe-1.0.4.dist-info/METADATA +0 -223
- turbopipe-1.0.4.dist-info/RECORD +0 -7
- {turbopipe-1.0.4.dist-info → turbopipe-1.1.0.dist-info}/License.md +0 -0
- {turbopipe-1.0.4.dist-info → turbopipe-1.1.0.dist-info}/WHEEL +0 -0
turbopipe/__init__.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
from
|
|
1
|
+
from typing import Union
|
|
2
2
|
|
|
3
3
|
from moderngl import Buffer
|
|
4
4
|
|
|
5
5
|
from turbopipe import _turbopipe
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
def pipe(buffer: Buffer,
|
|
8
|
+
def pipe(buffer: Union[Buffer, memoryview], fileno: int) -> None:
|
|
9
9
|
"""
|
|
10
|
-
Pipe the content of a moderngl.Buffer to a file descriptor,
|
|
10
|
+
Pipe the content of a moderngl.Buffer or memoryview to a file descriptor,
|
|
11
11
|
Fast, threaded and non-blocking. Call `sync()` when done!
|
|
12
12
|
|
|
13
13
|
Usage:
|
|
@@ -24,7 +24,10 @@ def pipe(buffer: Buffer, file: IOBase) -> None:
|
|
|
24
24
|
turbopipe.pipe(buffer, child.stdin.fileno())
|
|
25
25
|
```
|
|
26
26
|
"""
|
|
27
|
-
|
|
27
|
+
if isinstance(buffer, Buffer):
|
|
28
|
+
buffer = memoryview(buffer.mglo)
|
|
29
|
+
_turbopipe.pipe(buffer, fileno)
|
|
30
|
+
del buffer
|
|
28
31
|
|
|
29
32
|
def sync() -> None:
|
|
30
33
|
"""Waits for all jobs to finish"""
|
|
Binary file
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: turbopipe
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: 🌀 Faster MemoryView inter-process data transfers for subprocesses
|
|
5
|
+
Home-page: https://brokensrc.dev
|
|
6
|
+
Author-Email: Tremeschin <29046864+Tremeschin@users.noreply.github.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2024 Gabriel Tremeschin
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
Project-URL: Issues, https://github.com/BrokenSource/TurboPipe/issues
|
|
29
|
+
Project-URL: Repository, https://github.com/BrokenSource/TurboPipe
|
|
30
|
+
Project-URL: Documentation, https://github.com/BrokenSource/TurboPipe
|
|
31
|
+
Project-URL: Homepage, https://brokensrc.dev
|
|
32
|
+
Requires-Python: >=3.7
|
|
33
|
+
Requires-Dist: moderngl
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
> [!IMPORTANT]
|
|
37
|
+
> <sub>Also check out [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow), where **TurboPipe** shines! 😉</sub>
|
|
38
|
+
<!-- PyPI -->
|
|
39
|
+
<div align="center">
|
|
40
|
+
<a href="https://brokensrc.dev/"><img src="https://raw.githubusercontent.com/BrokenSource/TurboPipe/main/turbopipe/resources/images/turbopipe.png" width="200"></a>
|
|
41
|
+
<h1>TurboPipe</h1>
|
|
42
|
+
Faster <a href="https://github.com/moderngl/moderngl"><b>ModernGL Buffers</b></a> inter-process data transfers for subprocesses
|
|
43
|
+
<br>
|
|
44
|
+
<br>
|
|
45
|
+
<a href="https://pypi.org/project/turbopipe/"><img src="https://img.shields.io/pypi/v/turbopipe?label=PyPI&color=blue"></a>
|
|
46
|
+
<a href="https://pypi.org/project/turbopipe/"><img src="https://img.shields.io/pypi/dw/turbopipe?label=Installs&color=blue"></a>
|
|
47
|
+
<a href="https://github.com/BrokenSource/TurboPipe"><img src="https://img.shields.io/github/v/tag/BrokenSource/TurboPipe?label=GitHub&color=orange"></a>
|
|
48
|
+
<a href="https://github.com/BrokenSource/TurboPipe/stargazers"><img src="https://img.shields.io/github/stars/BrokenSource/TurboPipe?label=Stars&style=flat&color=orange"></a>
|
|
49
|
+
<a href="https://discord.gg/KjqvcYwRHm"><img src="https://img.shields.io/discord/1184696441298485370?label=Discord&style=flat&color=purple"></a>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<br>
|
|
53
|
+
|
|
54
|
+
# 🔥 Description
|
|
55
|
+
|
|
56
|
+
> TurboPipe speeds up sending raw bytes from `moderngl.Buffer` objects primarily to `FFmpeg` subprocess
|
|
57
|
+
|
|
58
|
+
The **optimizations** involved are:
|
|
59
|
+
|
|
60
|
+
- **Zero-copy**: Avoid unnecessary memory copies or allocation (intermediate `buffer.read()`)
|
|
61
|
+
- **C++**: The core of TurboPipe is written in C++ for speed, efficiency and low-level control
|
|
62
|
+
- **Chunks**: Write in chunks of 4096 bytes (RAM page size), so the hardware is happy (Unix)
|
|
63
|
+
- **Threaded**:
|
|
64
|
+
- Doesn't block Python code execution, allows to render next frame
|
|
65
|
+
- Decouples the main thread from the I/O thread for performance
|
|
66
|
+
|
|
67
|
+
✅ Don't worry, there's proper **safety** in place. TurboPipe will block Python if a memory address is already queued for writing, and guarantees order of writes per file-descriptor. Just call `.sync()` when done 😉
|
|
68
|
+
|
|
69
|
+
<br>
|
|
70
|
+
|
|
71
|
+
# 📦 Installation
|
|
72
|
+
|
|
73
|
+
It couldn't be easier! Just install the [**`turbopipe`**](https://pypi.org/project/turbopipe/) package from PyPI:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# With pip (https://pip.pypa.io/)
|
|
77
|
+
pip install turbopipe
|
|
78
|
+
|
|
79
|
+
# With Poetry (https://python-poetry.org/)
|
|
80
|
+
poetry add turbopipe
|
|
81
|
+
|
|
82
|
+
# With PDM (https://pdm-project.org/en/latest/)
|
|
83
|
+
pdm add turbopipe
|
|
84
|
+
|
|
85
|
+
# With Rye (https://rye.astral.sh/)
|
|
86
|
+
rye add turbopipe
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
<br>
|
|
90
|
+
|
|
91
|
+
# 🚀 Usage
|
|
92
|
+
|
|
93
|
+
See also the [**Examples**](https://github.com/BrokenSource/TurboPipe/tree/main/examples) folder for comparisons, and [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow/blob/main/ShaderFlow/Scene.py) usage of it!
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import subprocess
|
|
97
|
+
|
|
98
|
+
import moderngl
|
|
99
|
+
import turbopipe
|
|
100
|
+
|
|
101
|
+
# Create ModernGL objects
|
|
102
|
+
ctx = moderngl.create_standalone_context()
|
|
103
|
+
buffer = ctx.buffer(reserve=1920*1080*3)
|
|
104
|
+
|
|
105
|
+
# Make sure resolution, pixel format matches!
|
|
106
|
+
ffmpeg = subprocess.Popen(
|
|
107
|
+
'ffmpeg -f rawvideo -pix_fmt rgb24 -r 60 -s 1920x1080 -i - -f null -'.split(),
|
|
108
|
+
stdin=subprocess.PIPE
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
# Rendering loop of yours (eg. 1m footage)
|
|
112
|
+
for _ in range(60 * 60):
|
|
113
|
+
turbopipe.pipe(buffer, ffmpeg.stdin.fileno())
|
|
114
|
+
|
|
115
|
+
# Finalize writing, encoding
|
|
116
|
+
turbopipe.sync()
|
|
117
|
+
ffmpeg.stdin.close()
|
|
118
|
+
ffmpeg.wait()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
<br>
|
|
122
|
+
|
|
123
|
+
# ⭐️ Benchmarks
|
|
124
|
+
|
|
125
|
+
> [!NOTE]
|
|
126
|
+
> **The tests conditions are as follows**:
|
|
127
|
+
> - The tests are the average of 3 runs to ensure consistency, with 5 GB of the same data being piped
|
|
128
|
+
> - These aren't tests of render speed; but rather the throughput speed of GPU -> CPU -> RAM -> IPC
|
|
129
|
+
> - All resolutions are wide-screen (16:9) and have 3 components (RGB) with 3 bytes per pixel (SDR)
|
|
130
|
+
> - The data is a random noise per-buffer between 128-135. So, multi-buffers runs are a noise video
|
|
131
|
+
> - Multi-buffer cycles through a list of buffer (eg. 1, 2, 3, 1, 2, 3... for 3-buffers)
|
|
132
|
+
> - All FFmpeg outputs are scrapped with `-f null -` to avoid any disk I/O bottlenecks
|
|
133
|
+
> - The `gain` column is the percentage increase over the standard method
|
|
134
|
+
> - When `x264` is Null, no encoding took place (passthrough)
|
|
135
|
+
> - The test cases emoji signifies:
|
|
136
|
+
> - 🐢: Standard `ffmpeg.stdin.write(buffer.read())` on just the main thread, pure Python
|
|
137
|
+
> - 🚀: Threaded `ffmpeg.stdin.write(buffer.read())` with a queue (similar to turbopipe)
|
|
138
|
+
> - 🌀: The magic of `turbopipe.pipe(buffer, ffmpeg.stdin.fileno())`
|
|
139
|
+
>
|
|
140
|
+
> Also see [`benchmark.py`](https://github.com/BrokenSource/TurboPipe/blob/main/examples/benchmark.py) for the implementation
|
|
141
|
+
|
|
142
|
+
✅ Check out benchmarks in a couple of systems below:
|
|
143
|
+
|
|
144
|
+
📦 TurboPipe v1.0.4:
|
|
145
|
+
|
|
146
|
+
<details>
|
|
147
|
+
<summary><b>Desktop</b> • (AMD Ryzen 9 5900x) • (NVIDIA RTX 3060 12 GB) • (DDR4 2x32 GB 3200 MT/s) • (Arch Linux)</summary>
|
|
148
|
+
<br>
|
|
149
|
+
|
|
150
|
+
<b>Note:</b> I have noted inconsistency across tests, specially at lower resolutions. Some 720p runs might peak at 2900 fps and stay there, while others are limited by 1750 fps. I'm not sure if it's the Linux EEVDF scheduler, or CPU Topology that causes this. Nevertheless, results are stable on Windows 11 on the same machine.
|
|
151
|
+
|
|
152
|
+
| 720p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
153
|
+
|:----:|:----------|:---------:|----------:|------------:|---------:|
|
|
154
|
+
| 🐢 | Null | 1 | 882 fps | 2.44 GB/s | |
|
|
155
|
+
| 🚀 | Null | 1 | 793 fps | 2.19 GB/s | -10.04% |
|
|
156
|
+
| 🌀 | Null | 1 | 1911 fps | 5.28 GB/s | 116.70% |
|
|
157
|
+
| 🐢 | Null | 4 | 857 fps | 2.37 GB/s | |
|
|
158
|
+
| 🚀 | Null | 4 | 891 fps | 2.47 GB/s | 4.05% |
|
|
159
|
+
| 🌀 | Null | 4 | 2309 fps | 6.38 GB/s | 169.45% |
|
|
160
|
+
| 🐢 | ultrafast | 4 | 714 fps | 1.98 GB/s | |
|
|
161
|
+
| 🚀 | ultrafast | 4 | 670 fps | 1.85 GB/s | -6.10% |
|
|
162
|
+
| 🌀 | ultrafast | 4 | 1093 fps | 3.02 GB/s | 53.13% |
|
|
163
|
+
| 🐢 | slow | 4 | 206 fps | 0.57 GB/s | |
|
|
164
|
+
| 🚀 | slow | 4 | 208 fps | 0.58 GB/s | 1.37% |
|
|
165
|
+
| 🌀 | slow | 4 | 214 fps | 0.59 GB/s | 3.93% |
|
|
166
|
+
|
|
167
|
+
| 1080p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
168
|
+
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
169
|
+
| 🐢 | Null | 1 | 410 fps | 2.55 GB/s | |
|
|
170
|
+
| 🚀 | Null | 1 | 399 fps | 2.48 GB/s | -2.60% |
|
|
171
|
+
| 🌀 | Null | 1 | 794 fps | 4.94 GB/s | 93.80% |
|
|
172
|
+
| 🐢 | Null | 4 | 390 fps | 2.43 GB/s | |
|
|
173
|
+
| 🚀 | Null | 4 | 391 fps | 2.43 GB/s | 0.26% |
|
|
174
|
+
| 🌀 | Null | 4 | 756 fps | 4.71 GB/s | 94.01% |
|
|
175
|
+
| 🐢 | ultrafast | 4 | 269 fps | 1.68 GB/s | |
|
|
176
|
+
| 🚀 | ultrafast | 4 | 272 fps | 1.70 GB/s | 1.48% |
|
|
177
|
+
| 🌀 | ultrafast | 4 | 409 fps | 2.55 GB/s | 52.29% |
|
|
178
|
+
| 🐢 | slow | 4 | 115 fps | 0.72 GB/s | |
|
|
179
|
+
| 🚀 | slow | 4 | 118 fps | 0.74 GB/s | 3.40% |
|
|
180
|
+
| 🌀 | slow | 4 | 119 fps | 0.75 GB/s | 4.34% |
|
|
181
|
+
|
|
182
|
+
| 1440p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
183
|
+
|:-----:|:----------|:---------:|----------:|------------:|---------:|
|
|
184
|
+
| 🐢 | Null | 1 | 210 fps | 2.33 GB/s | |
|
|
185
|
+
| 🚀 | Null | 1 | 239 fps | 2.64 GB/s | 13.84% |
|
|
186
|
+
| 🌀 | Null | 1 | 534 fps | 5.91 GB/s | 154.32% |
|
|
187
|
+
| 🐢 | Null | 4 | 219 fps | 2.43 GB/s | |
|
|
188
|
+
| 🚀 | Null | 4 | 231 fps | 2.56 GB/s | 5.64% |
|
|
189
|
+
| 🌀 | Null | 4 | 503 fps | 5.56 GB/s | 129.75% |
|
|
190
|
+
| 🐢 | ultrafast | 4 | 141 fps | 1.56 GB/s | |
|
|
191
|
+
| 🚀 | ultrafast | 4 | 150 fps | 1.67 GB/s | 6.92% |
|
|
192
|
+
| 🌀 | ultrafast | 4 | 226 fps | 2.50 GB/s | 60.37% |
|
|
193
|
+
| 🐢 | slow | 4 | 72 fps | 0.80 GB/s | |
|
|
194
|
+
| 🚀 | slow | 4 | 71 fps | 0.79 GB/s | -0.70% |
|
|
195
|
+
| 🌀 | slow | 4 | 75 fps | 0.83 GB/s | 4.60% |
|
|
196
|
+
|
|
197
|
+
| 2160p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
198
|
+
|:-----:|:----------|:---------:|----------:|------------:|---------:|
|
|
199
|
+
| 🐢 | Null | 1 | 81 fps | 2.03 GB/s | |
|
|
200
|
+
| 🚀 | Null | 1 | 107 fps | 2.67 GB/s | 32.26% |
|
|
201
|
+
| 🌀 | Null | 1 | 213 fps | 5.31 GB/s | 163.47% |
|
|
202
|
+
| 🐢 | Null | 4 | 87 fps | 2.18 GB/s | |
|
|
203
|
+
| 🚀 | Null | 4 | 109 fps | 2.72 GB/s | 25.43% |
|
|
204
|
+
| 🌀 | Null | 4 | 212 fps | 5.28 GB/s | 143.72% |
|
|
205
|
+
| 🐢 | ultrafast | 4 | 59 fps | 1.48 GB/s | |
|
|
206
|
+
| 🚀 | ultrafast | 4 | 67 fps | 1.68 GB/s | 14.46% |
|
|
207
|
+
| 🌀 | ultrafast | 4 | 95 fps | 2.39 GB/s | 62.66% |
|
|
208
|
+
| 🐢 | slow | 4 | 37 fps | 0.94 GB/s | |
|
|
209
|
+
| 🚀 | slow | 4 | 43 fps | 1.07 GB/s | 16.22% |
|
|
210
|
+
| 🌀 | slow | 4 | 44 fps | 1.11 GB/s | 20.65% |
|
|
211
|
+
|
|
212
|
+
</details>
|
|
213
|
+
|
|
214
|
+
<details>
|
|
215
|
+
<summary><b>Desktop</b> • (AMD Ryzen 9 5900x) • (NVIDIA RTX 3060 12 GB) • (DDR4 2x32 GB 3200 MT/s) • (Windows 11)</summary>
|
|
216
|
+
<br>
|
|
217
|
+
|
|
218
|
+
| 720p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
219
|
+
|:----:|:----------|:---------:|----------:|------------:|--------:|
|
|
220
|
+
| 🐢 | Null | 1 | 981 fps | 2.71 GB/s | |
|
|
221
|
+
| 🚀 | Null | 1 | 1145 fps | 3.17 GB/s | 16.74% |
|
|
222
|
+
| 🌀 | Null | 1 | 1504 fps | 4.16 GB/s | 53.38% |
|
|
223
|
+
| 🐢 | Null | 4 | 997 fps | 2.76 GB/s | |
|
|
224
|
+
| 🚀 | Null | 4 | 1117 fps | 3.09 GB/s | 12.08% |
|
|
225
|
+
| 🌀 | Null | 4 | 1467 fps | 4.06 GB/s | 47.14% |
|
|
226
|
+
| 🐢 | ultrafast | 4 | 601 fps | 1.66 GB/s | |
|
|
227
|
+
| 🚀 | ultrafast | 4 | 616 fps | 1.70 GB/s | 2.57% |
|
|
228
|
+
| 🌀 | ultrafast | 4 | 721 fps | 1.99 GB/s | 20.04% |
|
|
229
|
+
| 🐢 | slow | 4 | 206 fps | 0.57 GB/s | |
|
|
230
|
+
| 🚀 | slow | 4 | 206 fps | 0.57 GB/s | 0.39% |
|
|
231
|
+
| 🌀 | slow | 4 | 206 fps | 0.57 GB/s | 0.13% |
|
|
232
|
+
|
|
233
|
+
| 1080p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
234
|
+
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
235
|
+
| 🐢 | Null | 1 | 451 fps | 2.81 GB/s | |
|
|
236
|
+
| 🚀 | Null | 1 | 542 fps | 3.38 GB/s | 20.31% |
|
|
237
|
+
| 🌀 | Null | 1 | 711 fps | 4.43 GB/s | 57.86% |
|
|
238
|
+
| 🐢 | Null | 4 | 449 fps | 2.79 GB/s | |
|
|
239
|
+
| 🚀 | Null | 4 | 518 fps | 3.23 GB/s | 15.48% |
|
|
240
|
+
| 🌀 | Null | 4 | 614 fps | 3.82 GB/s | 36.83% |
|
|
241
|
+
| 🐢 | ultrafast | 4 | 262 fps | 1.64 GB/s | |
|
|
242
|
+
| 🚀 | ultrafast | 4 | 266 fps | 1.66 GB/s | 1.57% |
|
|
243
|
+
| 🌀 | ultrafast | 4 | 319 fps | 1.99 GB/s | 21.88% |
|
|
244
|
+
| 🐢 | slow | 4 | 119 fps | 0.74 GB/s | |
|
|
245
|
+
| 🚀 | slow | 4 | 121 fps | 0.76 GB/s | 2.46% |
|
|
246
|
+
| 🌀 | slow | 4 | 121 fps | 0.75 GB/s | 1.90% |
|
|
247
|
+
|
|
248
|
+
| 1440p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
249
|
+
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
250
|
+
| 🐢 | Null | 1 | 266 fps | 2.95 GB/s | |
|
|
251
|
+
| 🚀 | Null | 1 | 308 fps | 3.41 GB/s | 15.87% |
|
|
252
|
+
| 🌀 | Null | 1 | 402 fps | 4.45 GB/s | 51.22% |
|
|
253
|
+
| 🐢 | Null | 4 | 276 fps | 3.06 GB/s | |
|
|
254
|
+
| 🚀 | Null | 4 | 307 fps | 3.40 GB/s | 11.32% |
|
|
255
|
+
| 🌀 | Null | 4 | 427 fps | 4.73 GB/s | 54.86% |
|
|
256
|
+
| 🐢 | ultrafast | 4 | 152 fps | 1.68 GB/s | |
|
|
257
|
+
| 🚀 | ultrafast | 4 | 156 fps | 1.73 GB/s | 3.02% |
|
|
258
|
+
| 🌀 | ultrafast | 4 | 181 fps | 2.01 GB/s | 19.36% |
|
|
259
|
+
| 🐢 | slow | 4 | 77 fps | 0.86 GB/s | |
|
|
260
|
+
| 🚀 | slow | 4 | 79 fps | 0.88 GB/s | 3.27% |
|
|
261
|
+
| 🌀 | slow | 4 | 80 fps | 0.89 GB/s | 4.86% |
|
|
262
|
+
|
|
263
|
+
| 2160p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
264
|
+
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
265
|
+
| 🐢 | Null | 1 | 134 fps | 3.35 GB/s | |
|
|
266
|
+
| 🚀 | Null | 1 | 152 fps | 3.81 GB/s | 14.15% |
|
|
267
|
+
| 🌀 | Null | 1 | 221 fps | 5.52 GB/s | 65.44% |
|
|
268
|
+
| 🐢 | Null | 4 | 135 fps | 3.36 GB/s | |
|
|
269
|
+
| 🚀 | Null | 4 | 151 fps | 3.76 GB/s | 11.89% |
|
|
270
|
+
| 🌀 | Null | 4 | 220 fps | 5.49 GB/s | 63.34% |
|
|
271
|
+
| 🐢 | ultrafast | 4 | 66 fps | 1.65 GB/s | |
|
|
272
|
+
| 🚀 | ultrafast | 4 | 70 fps | 1.75 GB/s | 6.44% |
|
|
273
|
+
| 🌀 | ultrafast | 4 | 82 fps | 2.04 GB/s | 24.31% |
|
|
274
|
+
| 🐢 | slow | 4 | 40 fps | 1.01 GB/s | |
|
|
275
|
+
| 🚀 | slow | 4 | 43 fps | 1.09 GB/s | 9.54% |
|
|
276
|
+
| 🌀 | slow | 4 | 44 fps | 1.10 GB/s | 10.15% |
|
|
277
|
+
|
|
278
|
+
</details>
|
|
279
|
+
|
|
280
|
+
<details>
|
|
281
|
+
<summary><b>Laptop</b> • (Intel Core i7 11800H) • (NVIDIA RTX 3070) • (DDR4 2x16 GB 3200 MT/s) • (Windows 11)</summary>
|
|
282
|
+
<br>
|
|
283
|
+
|
|
284
|
+
<b>Note:</b> Must select NVIDIA GPU on their Control Panel instead of Intel iGPU
|
|
285
|
+
|
|
286
|
+
| 720p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
287
|
+
|:----:|:----------|:---------:|----------:|------------:|--------:|
|
|
288
|
+
| 🐢 | Null | 1 | 786 fps | 2.17 GB/s | |
|
|
289
|
+
| 🚀 | Null | 1 | 903 fps | 2.50 GB/s | 14.91% |
|
|
290
|
+
| 🌀 | Null | 1 | 1366 fps | 3.78 GB/s | 73.90% |
|
|
291
|
+
| 🐢 | Null | 4 | 739 fps | 2.04 GB/s | |
|
|
292
|
+
| 🚀 | Null | 4 | 855 fps | 2.37 GB/s | 15.78% |
|
|
293
|
+
| 🌀 | Null | 4 | 1240 fps | 3.43 GB/s | 67.91% |
|
|
294
|
+
| 🐢 | ultrafast | 4 | 484 fps | 1.34 GB/s | |
|
|
295
|
+
| 🚀 | ultrafast | 4 | 503 fps | 1.39 GB/s | 4.10% |
|
|
296
|
+
| 🌀 | ultrafast | 4 | 577 fps | 1.60 GB/s | 19.37% |
|
|
297
|
+
| 🐢 | slow | 4 | 143 fps | 0.40 GB/s | |
|
|
298
|
+
| 🚀 | slow | 4 | 145 fps | 0.40 GB/s | 1.78% |
|
|
299
|
+
| 🌀 | slow | 4 | 151 fps | 0.42 GB/s | 5.76% |
|
|
300
|
+
|
|
301
|
+
| 1080p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
302
|
+
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
303
|
+
| 🐢 | Null | 1 | 358 fps | 2.23 GB/s | |
|
|
304
|
+
| 🚀 | Null | 1 | 427 fps | 2.66 GB/s | 19.45% |
|
|
305
|
+
| 🌀 | Null | 1 | 566 fps | 3.53 GB/s | 58.31% |
|
|
306
|
+
| 🐢 | Null | 4 | 343 fps | 2.14 GB/s | |
|
|
307
|
+
| 🚀 | Null | 4 | 404 fps | 2.51 GB/s | 17.86% |
|
|
308
|
+
| 🌀 | Null | 4 | 465 fps | 2.89 GB/s | 35.62% |
|
|
309
|
+
| 🐢 | ultrafast | 4 | 191 fps | 1.19 GB/s | |
|
|
310
|
+
| 🚀 | ultrafast | 4 | 207 fps | 1.29 GB/s | 8.89% |
|
|
311
|
+
| 🌀 | ultrafast | 4 | 234 fps | 1.46 GB/s | 22.77% |
|
|
312
|
+
| 🐢 | slow | 4 | 62 fps | 0.39 GB/s | |
|
|
313
|
+
| 🚀 | slow | 4 | 67 fps | 0.42 GB/s | 8.40% |
|
|
314
|
+
| 🌀 | slow | 4 | 74 fps | 0.47 GB/s | 20.89% |
|
|
315
|
+
|
|
316
|
+
| 1440p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
317
|
+
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
318
|
+
| 🐢 | Null | 1 | 180 fps | 1.99 GB/s | |
|
|
319
|
+
| 🚀 | Null | 1 | 216 fps | 2.40 GB/s | 20.34% |
|
|
320
|
+
| 🌀 | Null | 1 | 264 fps | 2.92 GB/s | 46.74% |
|
|
321
|
+
| 🐢 | Null | 4 | 178 fps | 1.97 GB/s | |
|
|
322
|
+
| 🚀 | Null | 4 | 211 fps | 2.34 GB/s | 19.07% |
|
|
323
|
+
| 🌀 | Null | 4 | 250 fps | 2.77 GB/s | 40.48% |
|
|
324
|
+
| 🐢 | ultrafast | 4 | 98 fps | 1.09 GB/s | |
|
|
325
|
+
| 🚀 | ultrafast | 4 | 110 fps | 1.23 GB/s | 13.18% |
|
|
326
|
+
| 🌀 | ultrafast | 4 | 121 fps | 1.35 GB/s | 24.15% |
|
|
327
|
+
| 🐢 | slow | 4 | 40 fps | 0.45 GB/s | |
|
|
328
|
+
| 🚀 | slow | 4 | 41 fps | 0.46 GB/s | 4.90% |
|
|
329
|
+
| 🌀 | slow | 4 | 43 fps | 0.48 GB/s | 7.89% |
|
|
330
|
+
|
|
331
|
+
| 2160p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
332
|
+
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
333
|
+
| 🐢 | Null | 1 | 79 fps | 1.98 GB/s | |
|
|
334
|
+
| 🚀 | Null | 1 | 95 fps | 2.37 GB/s | 20.52% |
|
|
335
|
+
| 🌀 | Null | 1 | 104 fps | 2.60 GB/s | 32.15% |
|
|
336
|
+
| 🐢 | Null | 4 | 80 fps | 2.00 GB/s | |
|
|
337
|
+
| 🚀 | Null | 4 | 94 fps | 2.35 GB/s | 17.82% |
|
|
338
|
+
| 🌀 | Null | 4 | 108 fps | 2.70 GB/s | 35.40% |
|
|
339
|
+
| 🐢 | ultrafast | 4 | 41 fps | 1.04 GB/s | |
|
|
340
|
+
| 🚀 | ultrafast | 4 | 48 fps | 1.20 GB/s | 17.67% |
|
|
341
|
+
| 🌀 | ultrafast | 4 | 52 fps | 1.30 GB/s | 27.49% |
|
|
342
|
+
| 🐢 | slow | 4 | 17 fps | 0.43 GB/s | |
|
|
343
|
+
| 🚀 | slow | 4 | 19 fps | 0.48 GB/s | 13.16% |
|
|
344
|
+
| 🌀 | slow | 4 | 19 fps | 0.48 GB/s | 13.78% |
|
|
345
|
+
|
|
346
|
+
</details>
|
|
347
|
+
<br>
|
|
348
|
+
|
|
349
|
+
<div align="justify">
|
|
350
|
+
|
|
351
|
+
# 🌀 Conclusion
|
|
352
|
+
|
|
353
|
+
TurboPipe significantly increases the feeding speed of FFmpeg with data, especially at higher resolutions. However, if there's few CPU compute available, or the video is too hard to encode (/slow preset), the gains are insignificant over the other methods (bottleneck). Multi-buffering didn't prove to have an advantage, debugging shows that TurboPipe C++ is often starved of data to write (as the file stream is buffered on the OS most likely), and the context switching, or cache misses, might be the cause of the slowdown.
|
|
354
|
+
|
|
355
|
+
The theory supports the threaded method being faster, as writing to a file descriptor is a blocking operation for python, but a syscall under the hood, that doesn't necessarily lock the GIL, just the thread. TurboPipe speeds that even further by avoiding an unecessary copy of the buffer data, and writing directly to the file descriptor on a C++ thread. Linux shows a better performance than Windows in the same system after the optimizations, but Windows wins on the standard method.
|
|
356
|
+
|
|
357
|
+
Interestingly, due either Linux's scheduler on AMD Ryzen CPUs, or their operating philosophy, it was experimentally seen that Ryzen's frenetic thread switching degrades a bit the single thread performance, which can be _"fixed"_ with prepending the command with `taskset --cpu 0,2` (not recommended at all), comparatively speaking to Windows performance on the same system (Linux 🚀 = Windows 🐢). This can also be due the topology of tested CPUs having more than one Core Complex Die (CCD). Intel CPUs seem to stick to the same thread for longer, which makes the Python threaded method often slightly faster.
|
|
358
|
+
|
|
359
|
+
### Personal experience
|
|
360
|
+
|
|
361
|
+
On realistically loads, like [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow)'s default lightweight shader export, TurboPipe increases rendering speed from 1080p260 to 1080p360 on my system, with mid 80% CPU usage than low 60%s. For [**DepthFlow**](https://github.com/BrokenSource/ShaderFlow)'s default depth video export, no gains are seen, as the CPU is almost saturated encoding at 1080p130.
|
|
362
|
+
|
|
363
|
+
</div>
|
|
364
|
+
|
|
365
|
+
<br>
|
|
366
|
+
|
|
367
|
+
# 📚 Future work
|
|
368
|
+
|
|
369
|
+
- Disable/investigate performance degradation on Windows iGPUs
|
|
370
|
+
- Improve the thread synchronization and/or use a ThreadPool
|
|
371
|
+
- Maybe use `mmap` instead of chunks writing on Linux
|
|
372
|
+
- Test on macOS 🙈
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
turbopipe-1.1.0.dist-info/METADATA,sha256=Itv2IFMZrJ8xqux7KHkdOy4LbynPpE5mhyJ2--brLpY,21721
|
|
2
|
+
turbopipe-1.1.0.dist-info/WHEEL,sha256=8AdrFzOtKQ6LLJ-VyqCU3y1iN8N--fMXYqrdkeTKDn0,83
|
|
3
|
+
turbopipe-1.1.0.dist-info/License.md,sha256=s3HF089BzBa_7DenpGj5kPHBu-XhGLP6gRzhhhLXLls,1096
|
|
4
|
+
turbopipe/_turbopipe.cp39-win_amd64.pyd,sha256=c6bI_yZk7af4m93TKgz4bVbLC8WNeYt8Ex2L6SQE2IE,35328
|
|
5
|
+
turbopipe/_turbopipe.cp39-win_amd64.lib,sha256=jIUB80FXINot63UGgNIRw0Ugbe2TqV5_NH23M5i7px4,2052
|
|
6
|
+
turbopipe/__init__.py,sha256=Lo3flpn7uicWWUrZZiRt7oYGP33gZo8VyKll50yxTHA,1087
|
|
7
|
+
turbopipe-1.1.0.dist-info/RECORD,,
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: turbopipe
|
|
3
|
-
Version: 1.0.4
|
|
4
|
-
Summary: 🌀 Faster ModernGL Buffer inter process data transfers
|
|
5
|
-
Home-page: https://brokensrc.dev
|
|
6
|
-
Author-Email: Tremeschin <29046864+Tremeschin@users.noreply.github.com>
|
|
7
|
-
License: MIT License
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2024 Gabriel Tremeschin
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
Project-URL: Issues, https://github.com/BrokenSource/TurboPipe/issues
|
|
29
|
-
Project-URL: Repository, https://github.com/BrokenSource/TurboPipe
|
|
30
|
-
Project-URL: Documentation, https://github.com/BrokenSource/TurboPipe
|
|
31
|
-
Project-URL: Homepage, https://brokensrc.dev
|
|
32
|
-
Requires-Python: >=3.7
|
|
33
|
-
Requires-Dist: moderngl
|
|
34
|
-
Description-Content-Type: text/markdown
|
|
35
|
-
|
|
36
|
-
> [!IMPORTANT]
|
|
37
|
-
> <sub>Also check out [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow), where **TurboPipe** shines! 😉</sub>
|
|
38
|
-
|
|
39
|
-
<div align="center">
|
|
40
|
-
<a href="https://brokensrc.dev/"><img src="https://raw.githubusercontent.com/BrokenSource/TurboPipe/main/turbopipe/resources/images/turbopipe.png" width="200"></a>
|
|
41
|
-
<h1>TurboPipe</h1>
|
|
42
|
-
<br>
|
|
43
|
-
Faster <a href="https://github.com/moderngl/moderngl"><b>ModernGL</b></a> inter-process data transfers
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
<br>
|
|
47
|
-
|
|
48
|
-
# 🔥 Description
|
|
49
|
-
|
|
50
|
-
> TurboPipe speeds up sending raw bytes from `moderngl.Buffer` objects primarily to `FFmpeg` subprocess
|
|
51
|
-
|
|
52
|
-
The **optimizations** involved are:
|
|
53
|
-
|
|
54
|
-
- **Zero-copy**: Avoid unnecessary memory copies or allocation (intermediate `buffer.read()`)
|
|
55
|
-
- **C++**: The core of TurboPipe is written in C++ for speed, efficiency and low-level control
|
|
56
|
-
- **Chunks**: Write in chunks of 4096 bytes (RAM page size), so the hardware is happy
|
|
57
|
-
- **Threaded**:
|
|
58
|
-
- Doesn't block Python code execution, allows to render next frame
|
|
59
|
-
- Decouples the main thread from the I/O thread for performance
|
|
60
|
-
|
|
61
|
-
✅ Don't worry, there's proper **safety** in place. TurboPipe will block Python if a memory address is already queued for writing, and guarantees order of writes per file-descriptor. Just call `.sync()` when done 😉
|
|
62
|
-
|
|
63
|
-
<br>
|
|
64
|
-
|
|
65
|
-
# 📦 Installation
|
|
66
|
-
|
|
67
|
-
It couldn't be easier! Just install in your package manager:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
pip install turbopipe
|
|
71
|
-
poetry add turbopipe
|
|
72
|
-
pdm add turbopipe
|
|
73
|
-
rye add turbopipe
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
<br>
|
|
77
|
-
|
|
78
|
-
# 🚀 Usage
|
|
79
|
-
|
|
80
|
-
See also the [**Examples**](https://github.com/BrokenSource/TurboPipe/tree/main/examples) folder for more controlled usage, and [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow/blob/main/ShaderFlow/Scene.py) usage of it!
|
|
81
|
-
|
|
82
|
-
```python
|
|
83
|
-
import subprocess
|
|
84
|
-
import moderngl
|
|
85
|
-
import turbopipe
|
|
86
|
-
|
|
87
|
-
# Create ModernGL objects
|
|
88
|
-
ctx = moderngl.create_standalone_context()
|
|
89
|
-
buffer = ctx.buffer(reserve=1920*1080*3)
|
|
90
|
-
|
|
91
|
-
# Make sure resolution, pixel format matches!
|
|
92
|
-
ffmpeg = subprocess.Popen(
|
|
93
|
-
'ffmpeg -f rawvideo -pix_fmt rgb24 -s 1920x1080 -i - -f null -'.split(),
|
|
94
|
-
stdin=subprocess.PIPE
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
# Rendering loop of yours
|
|
98
|
-
for _ in range(100):
|
|
99
|
-
turbopipe.pipe(buffer, ffmpeg.stdin.fileno())
|
|
100
|
-
|
|
101
|
-
# Finalize writing
|
|
102
|
-
turbo.sync()
|
|
103
|
-
ffmpeg.stdin.close()
|
|
104
|
-
ffmpeg.wait()
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
<br>
|
|
108
|
-
|
|
109
|
-
# ⭐️ Benchmarks
|
|
110
|
-
|
|
111
|
-
> [!NOTE]
|
|
112
|
-
> **The tests conditions are as follows**:
|
|
113
|
-
> - The tests are the average of 3 runs to ensure consistency, with 3 GB of the same data being piped
|
|
114
|
-
> - The data is a random noise per-buffer between 128-135. So, multi-buffers runs are a noise video
|
|
115
|
-
> - All resolutions are wide-screen (16:9) and have 3 components (RGB) with 3 bytes per pixel (SDR)
|
|
116
|
-
> - Multi-buffer cycles through a list of buffer (eg. 1, 2, 3, 1, 2, 3... for 3-buffers)
|
|
117
|
-
> - All FFmpeg outputs are scrapped with `-f null -` to avoid any disk I/O bottlenecks
|
|
118
|
-
> - The `gain` column is the percentage increase over the standard method
|
|
119
|
-
> - When `x264` is Null, no encoding took place (passthrough)
|
|
120
|
-
> - The test cases emoji signifies:
|
|
121
|
-
> - 🐢: Standard `ffmpeg.stdin.write(buffer.read())` on just the main thread, pure Python
|
|
122
|
-
> - 🚀: Threaded `ffmpeg.stdin.write(buffer.read())` with a queue (similar to turbopipe)
|
|
123
|
-
> - 🌀: The magic of `turbopipe.pipe(buffer, ffmpeg.stdin.fileno())`
|
|
124
|
-
>
|
|
125
|
-
> Also see [`benchmark.py`](https://github.com/BrokenSource/TurboPipe/blob/main/examples/benchmark.py) for the implementation
|
|
126
|
-
|
|
127
|
-
✅ Check out benchmarks in a couple of systems below:
|
|
128
|
-
|
|
129
|
-
<details>
|
|
130
|
-
<summary><b>Desktop</b> • (AMD Ryzen 9 5900x) • (NVIDIA RTX 3060 12 GB) • (DDR4 2x32 GB 3200 MT/s) • (Arch Linux)</summary>
|
|
131
|
-
<br>
|
|
132
|
-
|
|
133
|
-
| 720p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
134
|
-
|:----:|:----------|:---------:|----------:|------------:|---------:|
|
|
135
|
-
| 🐢 | Null | 1 | 882 fps | 2.44 GB/s | |
|
|
136
|
-
| 🚀 | Null | 1 | 793 fps | 2.19 GB/s | -10.04% |
|
|
137
|
-
| 🌀 | Null | 1 | 1911 fps | 5.28 GB/s | 116.70% |
|
|
138
|
-
| 🐢 | Null | 4 | 818 fps | 2.26 GB/s | |
|
|
139
|
-
| 🚀 | Null | 4 | 684 fps | 1.89 GB/s | -16.35% |
|
|
140
|
-
| 🌀 | Null | 4 | 1494 fps | 4.13 GB/s | 82.73% |
|
|
141
|
-
| 🐢 | ultrafast | 4 | 664 fps | 1.84 GB/s | |
|
|
142
|
-
| 🚀 | ultrafast | 4 | 635 fps | 1.76 GB/s | -4.33% |
|
|
143
|
-
| 🌀 | ultrafast | 4 | 869 fps | 2.40 GB/s | 31.00% |
|
|
144
|
-
| 🐢 | slow | 4 | 204 fps | 0.57 GB/s | |
|
|
145
|
-
| 🚀 | slow | 4 | 205 fps | 0.57 GB/s | 0.58% |
|
|
146
|
-
| 🌀 | slow | 4 | 208 fps | 0.58 GB/s | 2.22% |
|
|
147
|
-
|
|
148
|
-
| 1080p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
149
|
-
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
150
|
-
| 🐢 | Null | 1 | 385 fps | 2.40 GB/s | |
|
|
151
|
-
| 🚀 | Null | 1 | 369 fps | 2.30 GB/s | -3.91% |
|
|
152
|
-
| 🌀 | Null | 1 | 641 fps | 3.99 GB/s | 66.54% |
|
|
153
|
-
| 🐢 | Null | 4 | 387 fps | 2.41 GB/s | |
|
|
154
|
-
| 🚀 | Null | 4 | 359 fps | 2.23 GB/s | -7.21% |
|
|
155
|
-
| 🌀 | Null | 4 | 632 fps | 3.93 GB/s | 63.40% |
|
|
156
|
-
| 🐢 | ultrafast | 4 | 272 fps | 1.70 GB/s | |
|
|
157
|
-
| 🚀 | ultrafast | 4 | 266 fps | 1.66 GB/s | -2.14% |
|
|
158
|
-
| 🌀 | ultrafast | 4 | 405 fps | 2.53 GB/s | 49.24% |
|
|
159
|
-
| 🐢 | slow | 4 | 117 fps | 0.73 GB/s | |
|
|
160
|
-
| 🚀 | slow | 4 | 122 fps | 0.76 GB/s | 4.43% |
|
|
161
|
-
| 🌀 | slow | 4 | 124 fps | 0.77 GB/s | 6.48% |
|
|
162
|
-
|
|
163
|
-
| 1440p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
164
|
-
|:-----:|:----------|:---------:|----------:|------------:|--------:|
|
|
165
|
-
| 🐢 | Null | 1 | 204 fps | 2.26 GB/s | |
|
|
166
|
-
| 🚀 | Null | 1 | 241 fps | 2.67 GB/s | 18.49% |
|
|
167
|
-
| 🌀 | Null | 1 | 297 fps | 3.29 GB/s | 45.67% |
|
|
168
|
-
| 🐢 | Null | 4 | 230 fps | 2.54 GB/s | |
|
|
169
|
-
| 🚀 | Null | 4 | 235 fps | 2.61 GB/s | 2.52% |
|
|
170
|
-
| 🌀 | Null | 4 | 411 fps | 4.55 GB/s | 78.97% |
|
|
171
|
-
| 🐢 | ultrafast | 4 | 146 fps | 1.62 GB/s | |
|
|
172
|
-
| 🚀 | ultrafast | 4 | 153 fps | 1.70 GB/s | 5.21% |
|
|
173
|
-
| 🌀 | ultrafast | 4 | 216 fps | 2.39 GB/s | 47.96% |
|
|
174
|
-
| 🐢 | slow | 4 | 73 fps | 0.82 GB/s | |
|
|
175
|
-
| 🚀 | slow | 4 | 78 fps | 0.86 GB/s | 7.06% |
|
|
176
|
-
| 🌀 | slow | 4 | 79 fps | 0.88 GB/s | 9.27% |
|
|
177
|
-
|
|
178
|
-
| 2160p | x264 | Buffers | Framerate | Bandwidth | Gain |
|
|
179
|
-
|:-----:|:----------|:---------:|----------:|------------:|---------:|
|
|
180
|
-
| 🐢 | Null | 1 | 81 fps | 2.03 GB/s | |
|
|
181
|
-
| 🚀 | Null | 1 | 107 fps | 2.67 GB/s | 32.26% |
|
|
182
|
-
| 🌀 | Null | 1 | 213 fps | 5.31 GB/s | 163.47% |
|
|
183
|
-
| 🐢 | Null | 4 | 87 fps | 2.18 GB/s | |
|
|
184
|
-
| 🚀 | Null | 4 | 109 fps | 2.72 GB/s | 25.43% |
|
|
185
|
-
| 🌀 | Null | 4 | 212 fps | 5.28 GB/s | 143.72% |
|
|
186
|
-
| 🐢 | ultrafast | 4 | 59 fps | 1.48 GB/s | |
|
|
187
|
-
| 🚀 | ultrafast | 4 | 67 fps | 1.68 GB/s | 14.46% |
|
|
188
|
-
| 🌀 | ultrafast | 4 | 95 fps | 2.39 GB/s | 62.66% |
|
|
189
|
-
| 🐢 | slow | 4 | 37 fps | 0.94 GB/s | |
|
|
190
|
-
| 🚀 | slow | 4 | 43 fps | 1.07 GB/s | 16.22% |
|
|
191
|
-
| 🌀 | slow | 4 | 44 fps | 1.11 GB/s | 20.65% |
|
|
192
|
-
|
|
193
|
-
</details>
|
|
194
|
-
|
|
195
|
-
<details>
|
|
196
|
-
<summary><b>Desktop</b> • (AMD Ryzen 9 5900x) • (NVIDIA RTX 3060 12 GB) • (DDR4 2x32 GB 3200 MT/s) • (Windows 11)</summary>
|
|
197
|
-
<br>
|
|
198
|
-
</details>
|
|
199
|
-
|
|
200
|
-
<br>
|
|
201
|
-
|
|
202
|
-
<div align="justify">
|
|
203
|
-
|
|
204
|
-
# 🌀 Conclusion
|
|
205
|
-
|
|
206
|
-
TurboPipe significantly increases the feeding speed of FFmpeg with data, especially at higher resolutions. However, if there's few CPU compute available, or the video is too hard to encode (slow preset), the gains are insignificant over the other methods (bottleneck). Multi-buffering didn't prove to have an advantage, debugging shows that TurboPipe C++ is often starved of data to write (as the file stream is buffered on the OS most likely), and the context switching, or cache misses, might be the cause of the slowdown.
|
|
207
|
-
|
|
208
|
-
Interestingly, due either Linux's scheduler on AMD Ryzen CPUs, or their operating philosophy, it was experimentally seen that Ryzen's frenetic thread switching degrades a bit the single thread performance, which can be _"fixed"_ with prepending the command with `taskset --cpu 0,2` (not recommended at all), comparatively speaking to Windows performance on the same system (Linux 🚀 = Windows 🐢). This can also be due the topology of tested CPUs having more than one Core Complex Die (CCD). Intel CPUs seem to stick to the same thread for longer, which makes the Python threaded method an unecessary overhead.
|
|
209
|
-
|
|
210
|
-
### Personal experience
|
|
211
|
-
|
|
212
|
-
On realistically loads, like [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow)'s default lightweight shader export, TurboPipe increases rendering speed from 1080p260 to 1080p330 on my system, with mid 80% CPU usage than low 60%s. For [**DepthFlow**](https://github.com/BrokenSource/ShaderFlow)'s default depth video export, no gains are seen, as the CPU is almost saturated encoding at 1080p130.
|
|
213
|
-
|
|
214
|
-
</div>
|
|
215
|
-
|
|
216
|
-
<br>
|
|
217
|
-
|
|
218
|
-
# 📚 Future work
|
|
219
|
-
|
|
220
|
-
- Add support for NumPy arrays, memoryviews, and byte-like objects
|
|
221
|
-
- Improve the thread synchronization and/or use a ThreadPool
|
|
222
|
-
- Maybe use `mmap` instead of chunks writing
|
|
223
|
-
- Test on MacOS 🙈
|
turbopipe-1.0.4.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
turbopipe-1.0.4.dist-info/METADATA,sha256=P8eRcxqq6J1_5Gm3RZkCkX9JglpQAYtxs7vXtkTIGcM,11456
|
|
2
|
-
turbopipe-1.0.4.dist-info/WHEEL,sha256=8AdrFzOtKQ6LLJ-VyqCU3y1iN8N--fMXYqrdkeTKDn0,83
|
|
3
|
-
turbopipe-1.0.4.dist-info/License.md,sha256=s3HF089BzBa_7DenpGj5kPHBu-XhGLP6gRzhhhLXLls,1096
|
|
4
|
-
turbopipe/_turbopipe.cp39-win_amd64.pyd,sha256=bpN8ia114uNKx9MkzHe5RNPqEmbYwJFpWDMEvAB4g64,35840
|
|
5
|
-
turbopipe/_turbopipe.cp39-win_amd64.lib,sha256=jIUB80FXINot63UGgNIRw0Ugbe2TqV5_NH23M5i7px4,2052
|
|
6
|
-
turbopipe/__init__.py,sha256=8aMUtfquTKmZl_D9liQ2gqGyHD_-z76oDzwIcZRWzu8,961
|
|
7
|
-
turbopipe-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|