comphead commented on code in PR #6098:
URL: https://github.com/apache/datafusion-comet/pull/6098#discussion_r4074021470


##########
native/shuffle/src/ipc.rs:
##########
@@ -120,6 +123,29 @@ fn cache_schema(
     schema_message: &[u8],
     schema: SchemaRef,
 ) {
+    // Admission only affects reuse. Large valid schemas still decode, without 
evicting useful
+    // entries or retaining their serialized and parsed copies for the 
lifetime of the thread.
+    if schema_message.len() > SCHEMA_CACHE_ENTRY_RETAIN_LIMIT {
+        return;
+    }
+    let mut retained_size = schema_message
+        .len()
+        .saturating_add(std::mem::size_of_val(schema.as_ref()))
+        .saturating_add(schema.fields().size())
+        .saturating_add(
+            schema
+                .metadata()
+                .capacity()
+                .saturating_mul(std::mem::size_of::<(String, String)>()),
+        );
+    for (key, value) in schema.metadata() {
+        retained_size = retained_size

Review Comment:
   does it makes sense to 
   ```
   retained_size = retained_size.saturating_add(key.capacity() + 
value.capacity());
   ```
   ?
   
   Or the key+value can overflow too?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to