rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.77k stars 12.76k forks source link

AIX: bootstrap investigate efficient way of reading archive #133268

Open mustartt opened 1 day ago

mustartt commented 1 day ago

Currently in the bootstrap we are reading the entire archive into memory inorder to read the members:

 fn is_aix_shared_archive(path: &Path) -> bool {
      // reading the entire file as &[u8] into memory seems excessive
      // look into either mmap it or use the &CacheReader
      let data = match fs::read(path) {
          Ok(data) => data,
          Err(_) => return false,
      };
      let file = match ArchiveFile::parse(&*data) {
          Ok(file) => file,
          Err(_) => return false,
      };

      file.members()
          .filter_map(Result::ok)
          .any(|entry| String::from_utf8_lossy(entry.name()).contains(".so"))
 }

Find an easy way to either memory map the file or something else. Because currently this can take up to a second or two to read the larger dylibs into memory.

mustartt commented 1 day ago

@rustbot label: +C-cleanup