Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana profiles plugin feature #547

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pyroscope/merge_stack_traces.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ const importStackTraces = async (typeRegex, sel, fromTimeSec, toTimeSec, log, _c
ofs += profLen
}
start = process.hrtime?.bigint ? process.hrtime.bigint() : BigInt(0)
save && require('fs').writeFileSync(`/home/hromozeka/QXIP/qryn/data.${Date.now()}.bin`,
Buffer.from(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
Expand Down
Binary file modified pyroscope/pprof-bin/pkg/pprof_bin_bg.wasm
Binary file not shown.
5 changes: 5 additions & 0 deletions pyroscope/pprof-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use std::vec::Vec;
use wasm_bindgen::prelude::*;
use std::sync::Arc;

//TODO: REMOVE
use std::fs;

pub mod pprof_pb {

Expand Down Expand Up @@ -80,6 +82,9 @@ struct Tree {
impl Tree {
pub fn total(&self) -> i64 {
let mut total: i64 = 0;
if !self.nodes.contains_key(&0) {
return 0 as i64;
}
for c in 0..self.nodes.get(&0).unwrap().len() {
let _c = &self.nodes.get(&0).unwrap()[c];
total += _c.total[0];
Expand Down
3 changes: 0 additions & 3 deletions pyroscope/pprof.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,15 @@ const bfs = (t) => {
* @param {string} sampleType
*/
const createFlameGraph = (pprofBinaries, sampleType) => {
console.log(`got ${pprofBinaries.length} profiles`)
const tree = new Tree()
tree.sampleType = sampleType
let start = Date.now()
for (const p of pprofBinaries) {
const prof = messages.Profile.deserializeBinary(p)
tree.merge(prof)
}
console.log(`ds + merge took ${Date.now() - start} ms`)
start = Date.now()
const levels = bfs(tree)
console.log(`bfs took ${Date.now() - start} ms`)
return { levels: levels, names: tree.names, total: parseInt(tree.root.total), maxSelf: parseInt(tree.maxSelf) }
}

Expand Down
1 change: 0 additions & 1 deletion pyroscope/pyroscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ const analyzeQuery = async (req, res) => {
const toTimeSec = Math.floor(req.getEnd && req.getEnd()
? parseInt(req.getEnd()) / 1000
: Date.now() / 1000)
console.log(query)

const scope = new messages.QueryScope()
scope.setComponentType('store')
Expand Down
1 change: 0 additions & 1 deletion pyroscope/select_series.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ const selectSeriesImpl = async (fromTimeSec, toTimeSec, payload) => {

const resp = new messages.SelectSeriesResponse()
resp.setSeriesList(seriesList)
console.log(`Queried ${seriesList.length} series`)
return resp
}

Expand Down
Loading