turbopipe 1.2.2__cp39-cp39-win_amd64.whl → 1.2.3__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 -25
- turbopipe/_turbopipe.cp39-win_amd64.lib +0 -0
- turbopipe/_turbopipe.cp39-win_amd64.pyd +0 -0
- {turbopipe-1.2.2.dist-info → turbopipe-1.2.3.dist-info}/METADATA +52 -47
- turbopipe-1.2.3.dist-info/RECORD +6 -0
- turbopipe-1.2.2.dist-info/License.md +0 -21
- turbopipe-1.2.2.dist-info/RECORD +0 -7
- {turbopipe-1.2.2.dist-info → turbopipe-1.2.3.dist-info}/WHEEL +0 -0
turbopipe/__init__.py
CHANGED
|
@@ -4,33 +4,21 @@ from moderngl import Buffer
|
|
|
4
4
|
|
|
5
5
|
from turbopipe import _turbopipe
|
|
6
6
|
|
|
7
|
+
__all__ = [
|
|
8
|
+
"pipe",
|
|
9
|
+
"sync",
|
|
10
|
+
"close"
|
|
11
|
+
]
|
|
7
12
|
|
|
8
13
|
def pipe(buffer: Union[Buffer, memoryview], fileno: int) -> None:
|
|
9
|
-
"""
|
|
10
|
-
Pipe the content of a moderngl.Buffer or memoryview to a file descriptor, fast, threaded and
|
|
11
|
-
blocking when needed. Call `sync(buffer)` before this, and `sync()` when done for
|
|
12
|
-
|
|
13
|
-
Usage:
|
|
14
|
-
```python
|
|
15
|
-
# Assuming `buffer = ctx.buffer(...)`
|
|
16
|
-
# Note: Use as `fbo.read_into(buffer)`
|
|
17
|
-
|
|
18
|
-
# As a open() file
|
|
19
|
-
with open("file.bin", "wb") as file:
|
|
20
|
-
turbopipe.pipe(buffer, file)
|
|
21
|
-
|
|
22
|
-
# As a subprocess
|
|
23
|
-
child = subprocess.Popen(..., stdin=subprocess.PIPE)
|
|
24
|
-
turbopipe.pipe(buffer, child.stdin.fileno())
|
|
25
|
-
```
|
|
26
|
-
"""
|
|
14
|
+
"""Pipe a buffer contents to a file descriptor, fast and threaded"""
|
|
27
15
|
if isinstance(buffer, Buffer):
|
|
28
16
|
buffer = memoryview(buffer.mglo)
|
|
29
17
|
_turbopipe.pipe(buffer, fileno)
|
|
30
18
|
del buffer
|
|
31
19
|
|
|
32
20
|
def sync(buffer: Optional[Union[Buffer, memoryview]]=None) -> None:
|
|
33
|
-
"""
|
|
21
|
+
"""Wait for pending operations on a buffer to finish"""
|
|
34
22
|
if isinstance(buffer, Buffer):
|
|
35
23
|
buffer = memoryview(buffer.mglo)
|
|
36
24
|
_turbopipe.sync(buffer)
|
|
@@ -39,9 +27,3 @@ def sync(buffer: Optional[Union[Buffer, memoryview]]=None) -> None:
|
|
|
39
27
|
def close() -> None:
|
|
40
28
|
"""Syncs and deletes objects"""
|
|
41
29
|
_turbopipe.close()
|
|
42
|
-
|
|
43
|
-
__all__ = [
|
|
44
|
-
"pipe",
|
|
45
|
-
"sync",
|
|
46
|
-
"close"
|
|
47
|
-
]
|
|
Binary file
|
|
Binary file
|
|
@@ -1,41 +1,18 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: turbopipe
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.3
|
|
4
4
|
Summary: 🌀 Faster ModernGL Buffers inter-process data transfers for subprocesses
|
|
5
5
|
Author-Email: Tremeschin <29046864+Tremeschin@users.noreply.github.com>
|
|
6
|
-
License: MIT
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
SOFTWARE.
|
|
27
|
-
|
|
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
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: GitHub, https://github.com/BrokenSource/TurboPipe
|
|
8
|
+
Project-URL: Changelog, https://brokensrc.dev/about/changelog
|
|
9
|
+
Project-URL: Funding, https://brokensrc.dev/about/sponsors
|
|
10
|
+
Project-URL: Contact, https://brokensrc.dev/about/contact
|
|
11
|
+
Project-URL: Homepage, https://brokensrc.dev
|
|
32
12
|
Requires-Python: >=3.7
|
|
33
13
|
Requires-Dist: moderngl
|
|
34
14
|
Description-Content-Type: text/markdown
|
|
35
15
|
|
|
36
|
-
> [!IMPORTANT]
|
|
37
|
-
> <sub>Also check out [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow), where **TurboPipe** shines! 😉</sub>
|
|
38
|
-
<!-- PyPI -->
|
|
39
16
|
<div align="center">
|
|
40
17
|
<a href="https://brokensrc.dev/"><img src="https://raw.githubusercontent.com/BrokenSource/TurboPipe/main/turbopipe/resources/images/turbopipe.png" width="200"></a>
|
|
41
18
|
<h1>TurboPipe</h1>
|
|
@@ -57,15 +34,17 @@ Description-Content-Type: text/markdown
|
|
|
57
34
|
|
|
58
35
|
The **optimizations** involved are:
|
|
59
36
|
|
|
60
|
-
- **Zero-copy**: Avoid unnecessary memory copies or allocation (intermediate `buffer.read
|
|
37
|
+
- **Zero-copy**: Avoid unnecessary memory copies or allocation (intermediate `buffer.read`)
|
|
61
38
|
- **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
39
|
- **Threaded**:
|
|
64
40
|
- Doesn't block Python code execution, allows to render next frame
|
|
65
41
|
- Decouples the main thread from the I/O thread for performance
|
|
42
|
+
- **Chunks**: Write in chunks of 4096 bytes (RAM page size), so the hardware is happy (Unix)
|
|
66
43
|
|
|
67
44
|
✅ 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
45
|
|
|
46
|
+
<sub>Also check out [**ShaderFlow**](https://github.com/BrokenSource/ShaderFlow), where **TurboPipe** shines! 😉</sub>
|
|
47
|
+
|
|
69
48
|
<br>
|
|
70
49
|
|
|
71
50
|
# 📦 Installation
|
|
@@ -90,7 +69,7 @@ rye add turbopipe
|
|
|
90
69
|
|
|
91
70
|
# 🚀 Usage
|
|
92
71
|
|
|
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/
|
|
72
|
+
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/Exporting.py)'s usage of it!
|
|
94
73
|
|
|
95
74
|
```python
|
|
96
75
|
import subprocess
|
|
@@ -98,27 +77,53 @@ import subprocess
|
|
|
98
77
|
import moderngl
|
|
99
78
|
import turbopipe
|
|
100
79
|
|
|
101
|
-
# Create ModernGL objects
|
|
80
|
+
# Create ModernGL objects and proxy buffers
|
|
102
81
|
ctx = moderngl.create_standalone_context()
|
|
103
|
-
|
|
82
|
+
width, height, duration, fps = (1920, 1080, 10, 60)
|
|
83
|
+
buffers = [
|
|
84
|
+
ctx.buffer(reserve=(width*height*3))
|
|
85
|
+
for _ in range(nbuffers := 2)
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
# Create your FBO, Textures, Shaders, etc.
|
|
104
89
|
|
|
105
90
|
# Make sure resolution, pixel format matches!
|
|
106
|
-
ffmpeg = subprocess.Popen(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
91
|
+
ffmpeg = subprocess.Popen((
|
|
92
|
+
"ffmpeg",
|
|
93
|
+
"-f", "rawvideo",
|
|
94
|
+
"-pix_fmt", "rgb24",
|
|
95
|
+
"-r", str(fps),
|
|
96
|
+
"-s", f"{width}x{height}",
|
|
97
|
+
"-i", "-",
|
|
98
|
+
"-f", "null",
|
|
99
|
+
"output.mp4"
|
|
100
|
+
), stdin=subprocess.PIPE)
|
|
101
|
+
|
|
102
|
+
# Rendering loop of yours
|
|
103
|
+
for frame in range(duration*fps):
|
|
104
|
+
buffer = buffers[frame % nbuffers]
|
|
105
|
+
|
|
106
|
+
# Wait queued writes before copying
|
|
114
107
|
turbopipe.sync(buffer)
|
|
115
108
|
fbo.read_into(buffer)
|
|
109
|
+
|
|
110
|
+
# Doesn't lock the GIL, writes in parallel
|
|
116
111
|
turbopipe.pipe(buffer, ffmpeg.stdin.fileno())
|
|
117
112
|
|
|
118
|
-
#
|
|
113
|
+
# Wait for queued writes, clean memory
|
|
114
|
+
for buffer in buffers:
|
|
115
|
+
turbopipe.sync(buffer)
|
|
116
|
+
buffer.release()
|
|
117
|
+
|
|
118
|
+
# Signal stdin stream is done
|
|
119
119
|
ffmpeg.stdin.close()
|
|
120
|
-
|
|
120
|
+
|
|
121
|
+
# wait for encoding to finish
|
|
121
122
|
ffmpeg.wait()
|
|
123
|
+
|
|
124
|
+
# Warn: Albeit rare, only call close when no other data
|
|
125
|
+
# write is pending, as it might skip a frame or halt
|
|
126
|
+
turbopipe.close()
|
|
122
127
|
```
|
|
123
128
|
|
|
124
129
|
<br>
|
|
@@ -370,5 +375,5 @@ On realistically loads, like [**ShaderFlow**](https://github.com/BrokenSource/Sh
|
|
|
370
375
|
# 📚 Future work
|
|
371
376
|
|
|
372
377
|
- Disable/investigate performance degradation on Windows iGPUs
|
|
373
|
-
- Improve the thread synchronization and/or use a ThreadPool
|
|
374
378
|
- Maybe use `mmap` instead of chunks writing on Linux
|
|
379
|
+
- Split the code into a libturbopipe? Not sure where it would be useful 😅
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
turbopipe-1.2.3.dist-info/METADATA,sha256=MdldXjJ_g4d1H7thMGPxOrXbTYj3LiWFE3KaMJTACUw,21140
|
|
2
|
+
turbopipe-1.2.3.dist-info/WHEEL,sha256=8AdrFzOtKQ6LLJ-VyqCU3y1iN8N--fMXYqrdkeTKDn0,83
|
|
3
|
+
turbopipe/_turbopipe.cp39-win_amd64.pyd,sha256=rbkw-oQErmmzkev2gb64I56Ihym8jFSgNvqISr_0gVI,35328
|
|
4
|
+
turbopipe/_turbopipe.cp39-win_amd64.lib,sha256=IlfSQHen9PesR7TShHNTpDYm0JdiZkUKEvBG5n6r9wA,2052
|
|
5
|
+
turbopipe/__init__.py,sha256=-dDOggd5gJ67k7Mv_GowhRegxEZFV4qzTvEPJOCTE-A,774
|
|
6
|
+
turbopipe-1.2.3.dist-info/RECORD,,
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Gabriel Tremeschin
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
turbopipe-1.2.2.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
turbopipe-1.2.2.dist-info/METADATA,sha256=wOFE8tKTn_jt4GJJVbWkrIGfJZSQbGUuq-vyMA4z2_E,21819
|
|
2
|
-
turbopipe-1.2.2.dist-info/WHEEL,sha256=8AdrFzOtKQ6LLJ-VyqCU3y1iN8N--fMXYqrdkeTKDn0,83
|
|
3
|
-
turbopipe-1.2.2.dist-info/License.md,sha256=s3HF089BzBa_7DenpGj5kPHBu-XhGLP6gRzhhhLXLls,1096
|
|
4
|
-
turbopipe/_turbopipe.cp39-win_amd64.pyd,sha256=4FdM75NT5jscGGeW64X306klC4lygiv8PIXHbyjKgvw,35840
|
|
5
|
-
turbopipe/_turbopipe.cp39-win_amd64.lib,sha256=q3cpTY96pvOAJVAaG6LWkTBdOvMBFSp2G0QyqCE5jIc,2052
|
|
6
|
-
turbopipe/__init__.py,sha256=D0FP-CR87qJeLGv_VYCGRcwdONFhBYt02D2bm4Xdax4,1346
|
|
7
|
-
turbopipe-1.2.2.dist-info/RECORD,,
|
|
File without changes
|