| 95 | |
| 96 | impl Drop for ColumnMmap { |
| 97 | fn drop(&mut self) { |
| 98 | let BackingStore::Mmap { ref mmap, ref file } = self.backing else { |
| 99 | return; |
| 100 | }; |
| 101 | let len = mmap.len(); |
| 102 | if len == 0 { |
| 103 | return; |
| 104 | } |
| 105 | let rc = unsafe { |
| 106 | libc::posix_fadvise( |
| 107 | file.as_raw_fd(), |
| 108 | 0, |
| 109 | len as libc::off_t, |
| 110 | libc::POSIX_FADV_DONTNEED, |
| 111 | ) |
| 112 | }; |
| 113 | if rc == 0 { |
| 114 | observability::FADV_DONTNEED_COUNT.fetch_add(1, Ordering::Relaxed); |
| 115 | } else { |
| 116 | tracing::warn!( |
| 117 | path = %self.path.display(), |
| 118 | errno = rc, |
| 119 | "posix_fadvise(DONTNEED) failed on columnar mmap drop", |
| 120 | ); |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /// Advise `MADV_SEQUENTIAL` on a freshly-mapped column region. |