[BUG]: iterators are needlessly slow / need an exception-free way of finishing.
Maintainer antworten meist innerhalb von 4 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Bug
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Bereich
- backend-api-design, performance
Rechercherichtung
Das Issue nennt keine Quelldateien oder Tests. Beginne damit, das dokumentierte Verhalten von pybind11 in Bezug auf Iteratoren und stop_iteration zu prüfen, und reproduziere anschließend den gemeldeten Benchmark für verschachtelte Verzeichnisiteratoren. Als erledigt gilt die Implementierung eines abgestimmten Ansatzes zum Abschluss von Iteratoren ohne Exceptions sowie die Validierung seiner Performance-Auswirkungen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.13.1
Problem description
Currently, the only way to have an iterator finish is by throwing py::stop_iteration{}. While this is "pythonic", it also incurs huge overhead, especially on short-lived iterators.
I was benchmarking an utility I wrote in C++ that iterates over a lot of files and parses text fields from each file. The files are organized in a specific directory structure that is reflected as three layers of directory iterators, leading to a total of ~25k iterators being created.
The C++ program took 0.8s to execute, 0.47s of which were spent waiting on IO.
The equivalent Python code exposed via pybind took 4s to execute.
When profiling, I saw that 15% of time was spent in exception handling (or up to 40% when using libunwind or llvm-libunwind, bumping execution time to 6s). This seems like a low-hanging fruit compared to all the other pybind-induced overhead.
Sadly, I couldn't come up with a good way how to solve this just yet. Perhaps pybind could add a std::optional-esque container that wraps the iterator return type + a tag on whether the iterator is at it's end?
I also found no way to signal the iterator end without going throw py::stop_iteration, if I missed something obvious please yell at me.
Reproducible example code
No response
Is this a regression? Put the last known working version here if it is.
Not a regression
- Vorherrschende Sprache
- C++
- Sterne
- 18k
- Forks
- 2.3k
- Ø Merge
- 5 T. 7 Std.
- Gemergte PRs (30 T.)
- 53
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus pybind/pybind11
-
triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 4 Tagen
-
triage
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
pybind/pybind11#5604 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 4 Tagen
-
triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 4 Tagen
-
docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 60/100
pybind/pybind11#747 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 4 Tagen
-
array_t::at() returns a misaligned reference when the stride is not a multiple of alignof(T)Evtl. vergeben @henryiii hat das heute übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 4 Tagen
Alle Issues in pybind/pybind11
Ähnliche Issues
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
type:bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
tenstorrent/tt-umd#4084 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
ToffelsKater/X4_VR#34 ·
-
difficulty:easy prio:low refactor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
NatronGitHub/openfx-supportext#220 ·
Maintainer antworten meist innerhalb von 1 Tag