You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "kunwp1 (via GitHub)" <gi...@apache.org> on 2026/05/03 21:53:21 UTC
[PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
kunwp1 opened a new pull request, #4876:
URL: https://github.com/apache/texera/pull/4876
<!--
Thanks for sending a pull request (PR)! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
[Contributing to Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
2. Ensure you have added or run the appropriate tests for your PR
3. If the PR is work in progress, mark it a draft on GitHub.
4. Please write your PR title to summarize what this PR proposes, we
are following Conventional Commits style for PR titles as well.
5. Be sure to keep the PR description updated to reflect all changes.
-->
### What changes were proposed in this PR?
<!--
Please clarify what changes you are proposing. The purpose of this section
is to outline the changes. Here are some tips for you:
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
3. If it is a refactoring, clarify what has been changed.
3. It would be helpful to include a before-and-after comparison using
screenshots or GIFs.
4. Please consider writing useful notes for better and faster reviews.
-->
`byteArrayToHexString` in `ExecutionResultService` was called on the full byte array before truncating the result string, causing ~3× the blob size in temporary string allocations (e.g. a 50 MB blob -> ~150 MB hex string). For workflows producing large binary fields, this caused the web server to take a very long time to fetch results for the result panel, making it appear empty to the user, while the computing master showed no errors. The fix slices the byte array to at most 13 bytes before hex-encoding, making the display conversion O(1) regardless of blob size.
### Any related issues, documentation, discussions?
<!--
Please use this section to link other resources if not mentioned already.
1. If this PR fixes an issue, please include `Fixes #1234`, `Resolves #1234`
or `Closes #1234`. If it is only related, simply mention the issue number.
2. If there is design documentation, please add the link.
3. If there is a discussion in the mailing list, please add the link.
-->
Closes #4875
### How was this PR tested?
<!--
If tests were added, say they were added here. Or simply mention that if the PR
is tested with existing test cases. Make sure to include/update test cases that
check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how
you tested step by step, ideally copy and paste-able, so that other reviewers can
test and check, and descendants can verify in the future. If tests were not added,
please describe why they were not added and/or why it was difficult to add.
-->
Test by running this workflow and check if the result appears almost immediately
[Untitled workflow (11).json](https://github.com/user-attachments/files/27325256/Untitled.workflow.11.json)
### Was this PR authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this PR,
please include the phrase: 'Generated-by: ' followed by the name of the tool
and its version. If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
Claude Code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "chenlica (via GitHub)" <gi...@apache.org>.
chenlica commented on PR #4876:
URL: https://github.com/apache/texera/pull/4876#issuecomment-4368050891
Great job!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #4876:
URL: https://github.com/apache/texera/pull/4876#issuecomment-4367380738
looks good!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "chenlica (via GitHub)" <gi...@apache.org>.
chenlica commented on code in PR #4876:
URL: https://github.com/apache/texera/pull/4876#discussion_r3178868637
##########
amber/src/main/scala/org/apache/texera/web/service/ExecutionResultService.scala:
##########
@@ -98,17 +98,15 @@ object ExecutionResultService {
value match {
case byteArray: Array[Byte] =>
val totalSize = byteArray.length
- val hexString = byteArrayToHexString(byteArray)
-
- // 39 = 30 (leading bytes) + 9 (trailing bytes)
- // 30 bytes = space for 10 hex values (each hex value takes 2 chars + 1 space)
- // 9 bytes = space for 3 hex values at the end (2 chars each + 1 space)
- if (hexString.length < 39) {
- s"bytes'$hexString' (length: $totalSize)"
+ // Slice the byte array before hex-encoding to avoid materializing
+ // an O(N) string for large blobs (e.g. 50 MB -> ~150 MB hex string).
+ // 13 bytes is the threshold: hex length = 3*N-1, so 13 bytes = 38 chars < 39.
+ if (totalSize <= 13) {
Review Comment:
When we have a constant in the codebase, it will be good to show how it's computed, and make some of the numbers configurable and meaningful.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #4876:
URL: https://github.com/apache/texera/pull/4876#issuecomment-4367332470
we had an offline discussion, the backend optimization is good.
but for frontend, maybe better to display non-HEX.
here is a suggested format:
`<binary: abfas12312...adj 52,428,800 bytes>`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #4876:
URL: https://github.com/apache/texera/pull/4876#issuecomment-4368058357
forgot to ask, does this need to be back ported to release/1.1?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 merged PR #4876:
URL: https://github.com/apache/texera/pull/4876
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #4876:
URL: https://github.com/apache/texera/pull/4876#discussion_r3178848706
##########
amber/src/main/scala/org/apache/texera/web/service/ExecutionResultService.scala:
##########
@@ -98,17 +98,15 @@ object ExecutionResultService {
value match {
case byteArray: Array[Byte] =>
val totalSize = byteArray.length
- val hexString = byteArrayToHexString(byteArray)
-
- // 39 = 30 (leading bytes) + 9 (trailing bytes)
- // 30 bytes = space for 10 hex values (each hex value takes 2 chars + 1 space)
- // 9 bytes = space for 3 hex values at the end (2 chars each + 1 space)
- if (hexString.length < 39) {
- s"bytes'$hexString' (length: $totalSize)"
+ // Slice the byte array before hex-encoding to avoid materializing
+ // an O(N) string for large blobs (e.g. 50 MB -> ~150 MB hex string).
+ // 13 bytes is the threshold: hex length = 3*N-1, so 13 bytes = 38 chars < 39.
+ if (totalSize <= 13) {
Review Comment:
we used to use 39 bytes. why drop to 13?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "kunwp1 (via GitHub)" <gi...@apache.org>.
kunwp1 commented on code in PR #4876:
URL: https://github.com/apache/texera/pull/4876#discussion_r3178882635
##########
amber/src/main/scala/org/apache/texera/web/service/ExecutionResultService.scala:
##########
@@ -98,17 +98,15 @@ object ExecutionResultService {
value match {
case byteArray: Array[Byte] =>
val totalSize = byteArray.length
- val hexString = byteArrayToHexString(byteArray)
-
- // 39 = 30 (leading bytes) + 9 (trailing bytes)
- // 30 bytes = space for 10 hex values (each hex value takes 2 chars + 1 space)
- // 9 bytes = space for 3 hex values at the end (2 chars each + 1 space)
- if (hexString.length < 39) {
- s"bytes'$hexString' (length: $totalSize)"
+ // Slice the byte array before hex-encoding to avoid materializing
+ // an O(N) string for large blobs (e.g. 50 MB -> ~150 MB hex string).
+ // 13 bytes is the threshold: hex length = 3*N-1, so 13 bytes = 38 chars < 39.
+ if (totalSize <= 13) {
Review Comment:
The number of bytes previewed (10 leading + 3 trailing) is unchanged from the original code. If we want to revisit the byte count defaults, better to track that in a follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: avoid O(N) memory allocation when displaying large binary blobs in result panel [texera]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #4876:
URL: https://github.com/apache/texera/pull/4876#issuecomment-4367291430
## [Codecov](https://app.codecov.io/gh/apache/texera/pull/4876?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 47.58%. Comparing base ([`fdffdda`](https://app.codecov.io/gh/apache/texera/commit/fdffddab766078ee83eb352f637c7eb8bd036947?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`c3e5f32`](https://app.codecov.io/gh/apache/texera/commit/c3e5f3247f6881d6c040d43ef51ac886dd61fb72?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #4876 +/- ##
=========================================
Coverage 47.57% 47.58%
- Complexity 2149 2150 +1
=========================================
Files 817 817
Lines 25980 25980
Branches 2343 2343
=========================================
+ Hits 12361 12363 +2
+ Misses 12869 12868 -1
+ Partials 750 749 -1
```
| [Flag](https://app.codecov.io/gh/apache/texera/pull/4876/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [amber](https://app.codecov.io/gh/apache/texera/pull/4876/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `42.78% <ø> (+0.01%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/texera/pull/4876?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org