ccat3z commented on issue #7860:
URL:
https://github.com/apache/incubator-gluten/issues/7860#issuecomment-2466135240
> @marin-ma see if we can have any way to call madvise(MADV_SEQUENTIAL), it
should be able to release physical memory quickly.
I tested the following patch on arrow, it seems that it will not be released
immediately. It might still require explicit 'MADV_DONTNEED' in this case.
```
diff -ru apache-arrow-15.0.0.orig/cpp/src/arrow/io/file.cc
apache-arrow-15.0.0/cpp/src/arrow/io/file.cc
--- apache-arrow-15.0.0.orig/cpp/src/arrow/io/file.cc 2024-11-09
11:39:58.497266369 +0800
+++ apache-arrow-15.0.0/cpp/src/arrow/io/file.cc 2024-11-09
14:50:37.035869206 +0800
@@ -41,6 +41,7 @@
#include <sstream>
#include <string>
#include <utility>
+#include <iostream>
// ----------------------------------------------------------------------
// Other Arrow includes
@@ -575,6 +576,12 @@
return Status::IOError("Memory mapping file failed: ",
::arrow::internal::ErrnoMessage(errno));
}
+ int madv_res = madvise(result, mmap_length, MADV_SEQUENTIAL);
+ if (madv_res != 0) {
+ return Status::IOError("madvise failed: ",
+ ::arrow::internal::ErrnoMessage(errno));
+ }
+ std::cerr << "madvise success: " << result << " " << mmap_length <<
std::endl;
map_len_ = mmap_length;
offset_ = offset;
region_ = std::make_shared<Region>(shared_from_this(),
static_cast<uint8_t*>(result),
@@ -720,6 +727,27 @@
return ::arrow::internal::MemoryAdviseWillNeed(regions);
}
```
--
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]