diff --git a/pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm b/pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm index 2141bfa3..12123cb7 100644 Binary files a/pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm and b/pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm differ diff --git a/pyroscope/pprof-bin/src/lib.rs b/pyroscope/pprof-bin/src/lib.rs index bd5e84e8..02605ce0 100644 --- a/pyroscope/pprof-bin/src/lib.rs +++ b/pyroscope/pprof-bin/src/lib.rs @@ -365,8 +365,8 @@ impl TrieReader { let uleb = read_uleb128(&self.bytes[self.offs..]); self.offs += uleb.1; let _size = uleb.0; - let string = &self.bytes[self.offs..self.offs + size]; - self.offs += size; + let string = &self.bytes[self.offs..self.offs + _size]; + self.offs += _size; res.push(string); } res diff --git a/pyroscope/pprof-bin/src/merge.rs b/pyroscope/pprof-bin/src/merge.rs index 9fa3ac86..7425f506 100644 --- a/pyroscope/pprof-bin/src/merge.rs +++ b/pyroscope/pprof-bin/src/merge.rs @@ -92,7 +92,7 @@ impl ProfileMerge { for i in 0..self.tmp.len() { let idx = self.tmp[i]; let dst = &mut self.sample_table.as_mut().unwrap().s[idx as usize].value; - let src = p.sample[self.tmp[i] as usize].value.clone(); + let src = p.sample[i as usize].value.clone(); for j in 0..src.len() { dst[j] += src[j]; } diff --git a/pyroscope/pyroscope.js b/pyroscope/pyroscope.js index 999bb3d3..0795f765 100644 --- a/pyroscope/pyroscope.js +++ b/pyroscope/pyroscope.js @@ -345,10 +345,11 @@ const selectMergeStacktracesV2 = async (req, res) => { ofs += profLen } start = process.hrtime?.bigint ? process.hrtime.bigint() : BigInt(0) - pprofBin.merge_tree(_ctxIdx, Uint8Array.from(profiles.data.slice(ofs))) + pprofBin.merge_tree(_ctxIdx, Uint8Array.from(profiles.data.slice(ofs)), + typeRegex.sampleType + ':' + typeRegex.sampleUnit) const mergeTreeLat = (process.hrtime?.bigint ? process.hrtime.bigint() : BigInt(0)) - start start = process.hrtime?.bigint ? process.hrtime.bigint() : BigInt(0) - const resp = pprofBin.export_tree(_ctxIdx) + const resp = pprofBin.export_tree(_ctxIdx, typeRegex.sampleType + ':' + typeRegex.sampleUnit) const exportTreeLat = (process.hrtime?.bigint ? process.hrtime.bigint() : BigInt(0)) - start req.log.debug(`merge_pprof: ${mergePprofLat / BigInt(1000000)}ms`) req.log.debug(`merge_tree: ${mergeTreeLat / BigInt(1000000)}ms`)