-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-53972][SS] Fix streaming query recentProgress regression in classic pyspark #52688
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
Closed
Conversation
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
anishshri-db
approved these changes
Oct 22, 2025
Contributor
anishshri-db
left a comment
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.
nice finding. Thanks !
micheal-o
approved these changes
Oct 22, 2025
Contributor
micheal-o
left a comment
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.
Thanks for RCA'ing and fixing this. Nice work!
anishshri-db
pushed a commit
that referenced
this pull request
Oct 23, 2025
…assic pyspark ### What changes were proposed in this pull request? See #52688 for details. This PR is to backport the changes to Spark 4.0 ### Why are the changes needed? See #52688 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? See #52688 ### Was this patch authored or co-authored using generative AI tooling? No Closes #52698 from zifeif2/recent-progress-bug-4.0. Authored-by: Ubuntu <[email protected]> Signed-off-by: Anish Shrigondekar <[email protected]>
huangxiaopingRD
pushed a commit
to huangxiaopingRD/spark
that referenced
this pull request
Nov 25, 2025
…assic pyspark ### What changes were proposed in this pull request? We found a performance regression in recentProgress in pyspark in assigned cluster after version 4.0. The direct cause of the regression in this [commit](apache@22eb6c4#diff-4d4ed29d139877b160de444add7ee63cfa7a7577d849ab2686f1aa2d5b4aae64), it changes how we load recentProgress `fromJson` to `fromJObject`, and this commit is only included in 4.0. However, when constructing a dict from `JObject`, py4j needs to make multiple RPCs to JVM which result in a long time ### Proposed Fix: Use fromJson to load StraemingQueryProgress instead. This will be aligned with the [recentProgress in pyConnect](https://github.com/apache/spark/blob/master/python/pyspark/sql/connect/streaming/query.py#L114-L130) as well We are also fixing `lastProgress` to load StreamingQueryProgress from json. ### Why are the changes needed? Otherwise there is a performance regression in recentProgress. Here is the log of the time it takes to load 70 recent progress: ``` [2025-10-22 06:28:37]Total Time: 0.12269 seconds for getting 1 progress [2025-10-22 06:28:38]Total Time: 0.199387 seconds for getting 2 progress [2025-10-22 06:28:39]Total Time: 0.384784 seconds for getting 4 progress ... [2025-10-22 06:29:27]Total Time: 4.089001 seconds for getting 48 progress [2025-10-22 06:29:32]Total Time: 4.571433 seconds for getting 53 progress [2025-10-22 06:29:38]Total Time: 5.024825 seconds for getting 58 progress [2025-10-22 06:29:45]Total Time: 5.520222 seconds for getting 64 progress [2025-10-22 06:29:52]Total Time: 6.071674 seconds for getting 71 progress ``` This is generated by adding the following test to test_streaming.py locally ``` def test_recent_progress_regression(self): df = self.spark.readStream.format("rate").option("rowsPerSecond", 10).load() q = df.writeStream.format("noop").start() print("begin waiting for progress") numProgress = len(q.recentProgress) while numProgress < 70 and q.exception() is None: time.sleep(1) beforeTime = datetime.now() rep = q.recentProgress numProgress = len(rep) afterTime = datetime.now() print("[" + afterTime.strftime("%Y-%m-%d %H:%M:%S") + "]" + "Total Time: " + str((afterTime - beforeTime).total_seconds()) + " seconds for getting " + str(numProgress) + " progress") q.stop() q.awaitTermination() assert(q.exception() is None) assert(numProgress == 300) # wrong statement so that we can see the logs ``` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Run local script with the changes and here is the output log. ``` 2025-10-22 06:23:35]Total Time: 0.001411 seconds for getting 1 progress [2025-10-22 06:23:36]Total Time: 0.002293 seconds for getting 2 progress [2025-10-22 06:23:37]Total Time: 0.003163 seconds for getting 3 progress [2025-10-22 06:23:38]Total Time: 0.003583 seconds for getting 4 progress [2025-10-22 06:23:39]Total Time: 0.004025 seconds for getting 5 progress [2025-10-22 06:23:40]Total Time: 0.004954 seconds for getting 6 progress ... [2025-10-22 06:24:43]Total Time: 0.012729 seconds for getting 69 progress [2025-10-22 06:24:44]Total Time: 0.01289 seconds for getting 70 progress ``` ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#52688 from zifeif2/recent-progress-bug. Authored-by: Ubuntu <[email protected]> Signed-off-by: Anish Shrigondekar <[email protected]>
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.
What changes were proposed in this pull request?
We found a performance regression in recentProgress in pyspark in assigned cluster after version 4.0. The direct cause of the regression in this commit, it changes how we load recentProgress
fromJsontofromJObject, and this commit is only included in 4.0. However, when constructing a dict fromJObject, py4j needs to make multiple RPCs to JVM which result in a long timeProposed Fix:
Use fromJson to load StraemingQueryProgress instead. This will be aligned with the recentProgress in pyConnect as well
We are also fixing
lastProgressto load StreamingQueryProgress from json.Why are the changes needed?
Otherwise there is a performance regression in recentProgress. Here is the log of the time it takes to load 70 recent progress:
This is generated by adding the following test to test_streaming.py locally
Does this PR introduce any user-facing change?
No
How was this patch tested?
Run local script with the changes and here is the output log.
Was this patch authored or co-authored using generative AI tooling?
No