-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix sequential bottleneck in parallel parsing #21291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3472f39
98ead81
2877475
4b84a57
bc0d231
68def94
6941a1a
b0cac68
5d8d544
bc0fd49
1068116
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -360,6 +360,8 @@ class FileRawData: | |
| "ignored_lines", | ||
| "is_partial_stub_package", | ||
| "uses_template_strings", | ||
| "source_hash", | ||
| "mypy_comments", | ||
| ) | ||
|
|
||
| defs: bytes | ||
|
|
@@ -368,6 +370,8 @@ class FileRawData: | |
| ignored_lines: dict[int, list[str]] | ||
| is_partial_stub_package: bool | ||
| uses_template_strings: bool | ||
| source_hash: str | ||
| mypy_comments: list[tuple[int, str]] | ||
|
|
||
| def __init__( | ||
| self, | ||
|
|
@@ -377,13 +381,17 @@ def __init__( | |
| ignored_lines: dict[int, list[str]], | ||
| is_partial_stub_package: bool, | ||
| uses_template_strings: bool, | ||
| source_hash: str = "", | ||
| mypy_comments: list[tuple[int, str]] | None = None, | ||
| ) -> None: | ||
| self.defs = defs | ||
| self.imports = imports | ||
| self.raw_errors = raw_errors | ||
| self.ignored_lines = ignored_lines | ||
| self.is_partial_stub_package = is_partial_stub_package | ||
| self.uses_template_strings = uses_template_strings | ||
| self.source_hash = source_hash | ||
| self.mypy_comments = mypy_comments if mypy_comments is not None else [] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these two (or at least the second one) need to be sent to the worker, i.e. you will need to handle them in
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added serialiation back (I had it removed since I thought it's not needed). |
||
|
|
||
| def write(self, data: WriteBuffer) -> None: | ||
| write_bytes(data, self.defs) | ||
|
|
@@ -399,6 +407,12 @@ def write(self, data: WriteBuffer) -> None: | |
| write_str_list(data, codes) | ||
| write_bool(data, self.is_partial_stub_package) | ||
| write_bool(data, self.uses_template_strings) | ||
| write_str(data, self.source_hash) | ||
| write_tag(data, LIST_GEN) | ||
| write_int_bare(data, len(self.mypy_comments)) | ||
| for line, text in self.mypy_comments: | ||
| write_int(data, line) | ||
| write_str(data, text) | ||
|
|
||
| @classmethod | ||
| def read(cls, data: ReadBuffer) -> FileRawData: | ||
|
|
@@ -408,8 +422,20 @@ def read(cls, data: ReadBuffer) -> FileRawData: | |
| raw_errors = [read_parse_error(data) for _ in range(read_int_bare(data))] | ||
| assert read_tag(data) == DICT_INT_GEN | ||
| ignored_lines = {read_int(data): read_str_list(data) for _ in range(read_int_bare(data))} | ||
| is_partial_stub_package = read_bool(data) | ||
| uses_template_strings = read_bool(data) | ||
| source_hash = read_str(data) | ||
| assert read_tag(data) == LIST_GEN | ||
| mypy_comments = [(read_int(data), read_str(data)) for _ in range(read_int_bare(data))] | ||
| return FileRawData( | ||
| defs, imports, raw_errors, ignored_lines, read_bool(data), read_bool(data) | ||
| defs, | ||
| imports, | ||
| raw_errors, | ||
| ignored_lines, | ||
| is_partial_stub_package, | ||
| uses_template_strings, | ||
| source_hash, | ||
| mypy_comments, | ||
| ) | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to (conditionally) remove the same call in
State.parse_file(), otherwise the worker will call it when loading the tree (look forstate.parse_file(raw_data=raw_data)inworker.py).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.