Repository navigation
Parallel streams: move the results into the list without reference counting - #14
Merged
Merged
Conversation
…unting The calling thread copied the results of each chunk into its list (one Py_NewRef per result), then dropped the chunk's list (one Py_DECREF per result). Other threads own these objects, so each change was atomic, and the calling thread did it alone after the workers had finished: 2.2 million results took a large share of a run on 64 threads. Chunks now keep their results in a vector and the list takes the references. map_many with fields on 7.6 GB of GH Archive events, mapped once, big4 (Xeon Gold 6548N), 3.14.10t: 56.6 to 62.9 GB/s with 64 threads, 65.9 to 73.7 GB/s with 128.
This was referenced Nov 14, 2026
lemire
added a commit
that referenced
this pull request
Nov 14, 2026
- Streams read read-only memoryviews of bytes and of read-only mmaps in place (#13). - Parallel streams move their results into the list without reference counting (#14). - fields= reads the documents with On-Demand (#15). - map_many(..., drop_none=True) leaves out the results that are None (#16). - Wheels for Pyodide (WebAssembly), Python 3.13 to 3.15; fixes for targets without SSE2 or NEON (dumps with ensure_ascii=False on strings of 16 bytes or more) and for parse_many under Pyodide (#17).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a parallel run, the calling thread copied each chunk's results into its list (one
Py_NewRefper result), then dropped the chunk's list (onePy_DECREFper result). Other threads own these objects, so on free-threaded Python each change is atomic, and the calling thread did all of it alone after the workers had finished. perf showed only 41 of 64 CPUs busy on average.Chunks now keep their results in a
std::vector, and the final list takes the references (PyList_SET_ITEMwithout incref). On a failure, the results past the failing chunk are released as before.map_manywith two fields on 7.6 GB of GH Archive events (file mapped once), big4 (Xeon Gold 6548N), 3.14.10t:Full suite passes on 3.14.10t (with #13 applied).