rroelke commented on code in PR #15861:
URL: https://github.com/apache/datafusion/pull/15861#discussion_r2060445809


##########
datafusion/common/src/error.rs:
##########
@@ -59,7 +59,7 @@ pub enum DataFusionError {
     ParquetError(ParquetError),
     /// Error when reading Avro data.
     #[cfg(feature = "avro")]
-    AvroError(AvroError),
+    AvroError(Box<AvroError>),

Review Comment:
   I don't have the specific numbers but here's a verbose explanation of what 
(the 
lint)[https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err]
 is trying to tell us about:
   
   ```
   enum MyErrorType {
       Something,
       SomethingElse([u8; 4096])
   }
   ```
   We can see here that the size of `MyErrorType` is 4096 (ish)
   
   ```
   fn try_thing() -> Result<usize, MyErrorType> {
       ...
   }
   ```
   Consequently the size of `Result<T, MyErrorType>` is always at least 4096.  
`Result<usize, MyErrorType>` has size 4096.  To call `try_thing` we have to 
allocate memory to hold that size of result.  We don't return the `usize` in a 
register.  And most of the time we expect to see `Ok` rather than `Err` so this 
makes the common case a lot worse.
   
   Boxing the large variants fixes the issue since it reduces the size of the 
variant to a pointer, which fits in a register.



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to