Skip to content

perf: avoid redundant result checks in file upload directives - #2102

Open
He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:fix/remove-redundant-upload-io-result-checks
Open

He-Pin wants to merge 1 commit into
apache:mainfrom
He-Pin:fix/remove-redundant-upload-io-result-checks

Conversation

@He-Pin

@He-Pin He-Pin commented Dec 6, 2026

Copy link
Copy Markdown
Member

Motivation

The upload directives always use FileIO.toPath. On the supported Pekko Streams implementation the materialized Future already fails on file and upstream I/O errors, so repeating the IOResult check adds an unnecessary callback.

Modification

Use the materialized result directly for single and multiple file uploads. Keep existing failure propagation, cleanup and ordering, and cover file-open failures at the actual routing entry points.

Result

The real FileUploadDirectivesSpec passed 33/33 on each of Scala 2.13.18 and 3.3.9 (JDK 17, Pekko Core 2.0.0). The original implementation passed the same suite, and a negative control that swallowed file-open failures failed both new cases. Checked formatting; no public API change or benchmark claim. Targeted ScalaTest runs recompiled the changed source and suite against the local module classpath; a complete sbt run is not claimed.

References

Pekko Streams FileIO.toPath and FileOutputStage.

Motivation: The upload directives always use FileIO.toPath. On the supported Pekko Streams implementation the materialized Future already fails on file and upstream I/O errors, so repeating the IOResult check adds an unnecessary callback.

Modification: Use the materialized result directly for single and multiple file uploads. Keep existing failure propagation, cleanup and ordering, and cover file-open failures at the actual routing entry points.

Result: Focused FileUploadDirectivesSpec tests pass 33/33 on each Scala axis. Failed file opens still reach the exception handler with the original I/O cause without entering the application route. No public API change or throughput claim.

References: Pekko Streams FileIO.toPath and FileOutputStage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant