diff --git a/samply-symbols/src/breakpad/index.rs b/samply-symbols/src/breakpad/index.rs index f4ab7627..5d31abad 100644 --- a/samply-symbols/src/breakpad/index.rs +++ b/samply-symbols/src/breakpad/index.rs @@ -431,7 +431,7 @@ impl<'a> StringListRef<'a> { pub fn as_slice(&self) -> &'a [StringLocation] { self.inner } - pub fn get>(&self, index: u32, data: R) -> Option<&'a [u8]> { + pub fn get<'d, R: ReadRef<'d>>(&self, index: u32, data: R) -> Option<&'d [u8]> { let location = *self.inner.get(usize::try_from(index).ok()?)?; location.get(data) } diff --git a/samply-symbols/src/breakpad/symbol_map.rs b/samply-symbols/src/breakpad/symbol_map.rs index ca1b1218..02d2025d 100644 --- a/samply-symbols/src/breakpad/symbol_map.rs +++ b/samply-symbols/src/breakpad/symbol_map.rs @@ -202,18 +202,6 @@ impl<'a> BreakpadSymbolMapSymbolCache<'a> { } } -// let file_offset = entry.offset.get(); -// let line_length = entry.line_len.get(); -// let line = self -// .data -// .read_bytes_at(file_offset, line_length.into()) -// .map_err(|e| { -// Error::HelperErrorDuringFileReading( -// "Breakpad FILE or INLINE_ORIGIN record".to_string(), -// e, -// ) -// })?; - impl<'object, T: FileContents> SymbolMapTrait for BreakpadSymbolMapInner<'object, T> { fn debug_id(&self) -> debugid::DebugId { self.index.debug_id diff --git a/samply/src/shared/presymbolicate.rs b/samply/src/shared/presymbolicate.rs index 122a6cd5..5497c0d7 100644 --- a/samply/src/shared/presymbolicate.rs +++ b/samply/src/shared/presymbolicate.rs @@ -8,8 +8,7 @@ use fxprof_processed_profile::symbol_info::{ }; use fxprof_processed_profile::LibraryHandle; use rustc_hash::FxHashMap; -use wholesym::samply_symbols::SourceFilePathHandle; -use wholesym::{SymbolManager, SymbolMap}; +use wholesym::{SourceFilePathHandle, SymbolManager, SymbolMap}; use crate::symbols::create_symbol_manager_and_quota_manager; diff --git a/samply/src/shared/symbol_precog.rs b/samply/src/shared/symbol_precog.rs index adc3e949..de328f60 100644 --- a/samply/src/shared/symbol_precog.rs +++ b/samply/src/shared/symbol_precog.rs @@ -5,10 +5,7 @@ use std::{borrow::Cow, fs::File}; use serde::de::{Deserialize, Deserializer}; use serde_derive::Deserialize; -use wholesym::{ - samply_symbols::{SourceFilePathHandle, SourceFilePathIndex, SymbolMapGeneration}, - SourceFilePath, -}; +use wholesym::{SourceFilePath, SourceFilePathHandle, SourceFilePathIndex, SymbolMapGeneration}; #[derive(Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)] struct StringTableIndex(usize); diff --git a/wholesym/src/breakpad.rs b/wholesym/src/breakpad.rs index 31ced0b1..7f2666da 100644 --- a/wholesym/src/breakpad.rs +++ b/wholesym/src/breakpad.rs @@ -1,3 +1,4 @@ +use std::io::Read; use std::path::{Path, PathBuf}; use std::sync::Arc; @@ -284,25 +285,28 @@ impl BreakpadSymbolDownloaderInner { &self, sym_path: &Path, ) -> Result { - let mut sym_file = tokio::fs::File::open(sym_path) - .await - .map_err(SymindexGenerationError::SymReading)?; - let mut parser = BreakpadIndexCreator::new(); - const CHUNK_SIZE: usize = 2 * 1024 * 1024; // 2 MiB - let mut buffer = vec![0; CHUNK_SIZE]; - loop { - let read_len = sym_file - .read(&mut buffer) - .await - .map_err(SymindexGenerationError::SymReading)?; - if read_len == 0 { - break; + let sym_path = sym_path.to_path_buf(); + tokio::task::spawn_blocking(|| { + let mut sym_file = + std::fs::File::open(sym_path).map_err(SymindexGenerationError::SymReading)?; + let mut parser = BreakpadIndexCreator::new(); + const CHUNK_SIZE: usize = 64 * 1024; // 64 KiB + let mut buffer = vec![0; CHUNK_SIZE]; + loop { + let read_len = sym_file + .read(&mut buffer) + .map_err(SymindexGenerationError::SymReading)?; + if read_len == 0 { + break; + } + parser.consume(&buffer[..read_len]); } - parser.consume(&buffer[..read_len]); - } - parser - .finish() - .map_err(SymindexGenerationError::BreakpadParsing) + parser + .finish() + .map_err(SymindexGenerationError::BreakpadParsing) + }) + .await + .unwrap() } } diff --git a/wholesym/src/lib.rs b/wholesym/src/lib.rs index 65d41ad5..ec60e453 100644 --- a/wholesym/src/lib.rs +++ b/wholesym/src/lib.rs @@ -153,8 +153,8 @@ pub use samply_symbols; pub use samply_symbols::{ AddressInfo, CodeId, ElfBuildId, Error, ExternalFileAddressInFileRef, ExternalFileAddressRef, ExternalFileRef, ExternalFileSymbolMap, FrameDebugInfo, FramesLookupResult, LibraryInfo, - LookupAddress, MappedPath, MultiArchDisambiguator, PeCodeId, SourceFilePath, SymbolInfo, - SyncAddressInfo, + LookupAddress, MappedPath, MultiArchDisambiguator, PeCodeId, SourceFilePath, + SourceFilePathHandle, SourceFilePathIndex, SymbolInfo, SymbolMapGeneration, SyncAddressInfo, }; pub use symbol_manager::{SymbolFileOrigin, SymbolManager, SymbolMap}; pub use symbol_manager_observer::SymbolManagerObserver;