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

use HTTP to enable jemalloc profile #4600

Merged
merged 25 commits into from Jun 7, 2019
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a432961
tikv_alloc/*: Add Mem Prof Error type.
YangKeao Apr 29, 2019
98ff4fa
tikv_alloc/*: Add `(de)activate_prof` functions
YangKeao Apr 29, 2019
5e2d9eb
server/status_server: Add new entry "/jeprof" to get jemalloc profile
YangKeao Apr 29, 2019
7f16a83
server/status_server: Add `dump_prof` and `dump_prof_to_resp` functions
YangKeao May 6, 2019
33d178b
tikv_alloc/*, server/status_server: Add FutureMutex to guarantee only…
YangKeao May 7, 2019
533230c
tikv_alloc/*: Add guard for profiler
YangKeao May 7, 2019
4a38e58
tikv_alloc/*,server/status_server: Change name of `Profiler*` to `Prof*`
YangKeao May 8, 2019
838d555
tikv_alloc/profiler_guard: lock before activate prof
YangKeao May 8, 2019
994bd89
tikv_alloc/*, server/status_server: move profiler_guard to tikv server
YangKeao May 8, 2019
2978747
tikv_alloc/default: Return `MemProfilingNotEnabled` error.
YangKeao May 9, 2019
1b6a7e2
tikv_alloc/error: Remove JemallocNotEnabled error
YangKeao May 10, 2019
5cd3853
tikv_alloc/error: impl std::error::Error for ProfError
YangKeao May 10, 2019
a6c100e
tikv_alloc/*, tikv/status_server: use lower-case in log
YangKeao May 10, 2019
fbc4b1e
tikv_alloc/error: impl Display for ProfError
YangKeao May 10, 2019
56b781d
server/status_server: Handle io::Error when creating TempDir
YangKeao May 10, 2019
ed798e4
server/status_server, tikv_alloc/error: Handle error for into_string()
YangKeao May 10, 2019
7fe8e8d
server/status_server: Parse query in a better way.
YangKeao May 10, 2019
73a73d2
server/status_server: Add several HTTP headers for response
YangKeao May 11, 2019
d19e129
server/status_server: Use a better way to handle Error
YangKeao May 13, 2019
667919c
server/status_server: Return error as http response
YangKeao May 13, 2019
095b7ce
tikv_alloc/*, util/signal_handler: Remove Option in `dump_prof`
YangKeao May 13, 2019
5b60d0f
tikv_alloc/*, server/status_server: handle error in dump_prof
YangKeao May 13, 2019
2ca9bb2
Merge remote-tracking branch 'origin/master' into http-prof
brson Jun 3, 2019
629a118
server/status_server: Set default value of `seconds`
YangKeao Jun 5, 2019
814b68b
Merge branch 'master' into 4272-jemalloc-profile-http-interface
siddontang Jun 7, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

tikv_alloc/*, server/status_server: handle error in dump_prof

Handle error in dump_prof function by returning it.

Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  • Loading branch information...
YangKeao committed May 13, 2019
commit 5b60d0f4d6fa98ca7f7bd2c810929cd85acb9551
@@ -5,7 +5,9 @@ use std::io;
pub fn dump_stats() -> String {
String::new()
}
pub fn dump_prof(_path: &str) {}
pub fn dump_prof(_path: &str) -> ProfResult<()> {
Err(ProfError::MemProfilingNotEnabled)
}

pub fn fetch_stats() -> io::Result<Option<AllocStats>> {
Ok(None)
@@ -117,14 +117,18 @@ mod profiling {
/// Dump the profile to the `path`.
///
/// If `path` is `None`, will dump it in the working directory with an auto-generated name.
pub fn dump_prof(path: &str) {
pub fn dump_prof(path: &str) -> ProfResult<()> {
// TODO: return errors in this function
let mut c_path = DumpPathGuard::from_cstring(Some(CString::new(path).unwrap()));
let res = unsafe { jemallocator::mallctl_set(PROF_DUMP, c_path.get_mut_ptr()) };
match res {
Err(e) => error!("failed to dump the profile to {:?}: {}", path, e),
Err(e) => {
error!("failed to dump the profile to {:?}: {}", path, e);
Err(ProfError::JemallocError(e))
}
Ok(_) => {
info!("dump profile to {}", path);
Ok(())
}
}
}
@@ -201,7 +205,9 @@ mod profiling {
mod profiling {
use super::{ProfError, ProfResult};

pub fn dump_prof(_path: &str) {}
pub fn dump_prof(_path: &str) -> ProfResult<()> {
Err(ProfError::MemProfilingNotEnabled)
}
pub fn activate_prof() -> ProfResult<()> {
Err(ProfError::MemProfilingNotEnabled)
}
@@ -110,7 +110,9 @@ impl StatusServer {
Err(path) => return Box::new(err(ProfError::PathError(path))),
};

tikv_alloc::dump_prof(&path);
if let Err(e) = tikv_alloc::dump_prof(&path) {
return Box::new(err(e));
}
drop(guard);
Box::new(
tokio_fs::file::File::open(path)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.