Feature: Stream.pmap, parallele map for streaming data#7
Open
dboyliao wants to merge 3 commits intod2207197:masterfrom
Open
Feature: Stream.pmap, parallele map for streaming data#7dboyliao wants to merge 3 commits intod2207197:masterfrom
dboyliao wants to merge 3 commits intod2207197:masterfrom
Conversation
d2207197
reviewed
Jun 26, 2018
carriage/stream.py
Outdated
| [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
| ''' | ||
| if processes is None: | ||
| processes = os.cpu_count() |
Owner
There was a problem hiding this comment.
這應該是 mp.Pool 內建就會做的事。應該維持 None 即可
carriage/stream.py
Outdated
| ''' | ||
| if processes is None: | ||
| processes = os.cpu_count() | ||
| pool_chunk_size = max(chunk_size // processes, 1) |
Owner
There was a problem hiding this comment.
看不懂爲何要除以 processes 數量。系統容許的 queue 大小應該跟 processes 個數無關。
Contributor
Author
There was a problem hiding this comment.
我怕 queue 爆掉而已~
所以加了個每個 chunk 會是多少這件事~
carriage/stream.py
Outdated
| if not data: | ||
| break | ||
| yield from pool.imap(f, data, pool_chunk_size) | ||
| return Stream(iter(gen())) |
Owner
There was a problem hiding this comment.
要用 @as_stream 包裝比較好。
@as_stream 處理了不少事情,包含 StreamTable 與 Stream 的相容。這樣可以保證 Stream 所有 method 都可以在 StreamTable使用。
另外 iter() 應該是多餘的。
Owner
|
@dboyliao ☝️ 👆 |
Contributor
Author
|
Orz 我現在才看到~ |
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.
Testing script updated and pass