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
Commits on May 13, 2019
  1. tikv_alloc/*: Add Mem Prof Error type.

    YangKeao committed Apr 29, 2019
    Add `ProfError` and `ProfResult<T>` type for profile related functions
    to return.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  2. tikv_alloc/*: Add `(de)activate_prof` functions

    YangKeao committed Apr 29, 2019
    Add `activate_prof` and `deactivate_prof` functions to start and stop
    jemalloc mem profiling.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  3. server/status_server: Add new entry "/jeprof" to get jemalloc profile

    YangKeao committed Apr 29, 2019
    Add new entry "/jeprof" to status_server and start jemalloc profiler for
    several seconds (according to `seconds` in query), and return the profile.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  4. server/status_server: Add `dump_prof` and `dump_prof_to_resp` functions

    YangKeao committed May 6, 2019
    1. Modify entry for profile from `/jeprof` to `/pprof/profile`
    
    2. Abstract the dumping process to two functions. Maybe `dump_prof`
    function can be added to `tikv_alloc` crates ( but a global timer is
    needed )
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  5. tikv_alloc/*, server/status_server: Add FutureMutex to guarantee only…

    YangKeao committed May 7, 2019
    … one profiler is running
    
    Add ProfilerLock to guarantee only one profiler is running. Actually jemalloc
    has only one global profiler so I cannot handle several requests at the same
    time.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  6. tikv_alloc/*: Add guard for profiler

    YangKeao committed May 7, 2019
    Impl drop for ProfilerGuard to deactivate_prof, but not use Drop for ProfilerLock.
    With this approach once we drop the guard, the lock was released.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  7. tikv_alloc/*,server/status_server: Change name of `Profiler*` to `Prof*`

    YangKeao committed May 8, 2019
    Change name of several structs and functions from `Profiler*` to `Prof*`
    to keep the same as `ProfResult`
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  8. tikv_alloc/profiler_guard: lock before activate prof

    YangKeao committed May 8, 2019
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  9. tikv_alloc/*, server/status_server: move profiler_guard to tikv server

    YangKeao committed May 8, 2019
    Move profiler_guard from tikv_alloc/profiler_guard to
    server/status_server to remove Futures from tikv_alloc dependencies.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  10. tikv_alloc/default: Return `MemProfilingNotEnabled` error.

    YangKeao committed May 9, 2019
    Return `MemProfilingNotEnabled` error but not `JemallocNotEnabled` error
    because tcmalloc profiling may alse be supported in the future.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  11. tikv_alloc/error: Remove JemallocNotEnabled error

    YangKeao committed May 10, 2019
    Remove JemallocNotEnabled error. It's not used in this crate.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  12. tikv_alloc/error: impl std::error::Error for ProfError

    YangKeao committed May 10, 2019
    impl std::error::Error for ProfError (with default implementation)
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  13. tikv_alloc/*, tikv/status_server: use lower-case in log

    YangKeao committed May 10, 2019
    Use lower-case rather than upper-case in several info log to keep
    consistent with other logs in tikv
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  14. tikv_alloc/error: impl Display for ProfError

    YangKeao committed May 10, 2019
    For impl `std::error::Error` for ProfError, impl `Display` for ProfError
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  15. server/status_server: Handle io::Error when creating TempDir

    YangKeao committed May 10, 2019
    TempDir::new() may return io::Error. Handle this error by returning out.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  16. server/status_server, tikv_alloc/error: Handle error for into_string()

    YangKeao committed May 10, 2019
    OsString.into_string() may cause error when directory path contains
    non-unicode letter.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  17. server/status_server: Parse query in a better way.

    YangKeao committed May 10, 2019
    Parse query part in URI in a better way. The previous method is too
    hacky :(
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  18. server/status_server: Add several HTTP headers for response

    YangKeao committed May 11, 2019
    Add `X-Content-Type-Options`, `Content-Disposition`, `Content-Type` and
    `Content-Length` to keep the same with net/http/pprof in golang.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  19. server/status_server: Use a better way to handle Error

    YangKeao committed May 13, 2019
    Return Error in one closure without use `then` several times.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  20. server/status_server: Return error as http response

    YangKeao committed May 13, 2019
    Return the description of error as HTTP response
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  21. tikv_alloc/*, util/signal_handler: Remove Option in `dump_prof`

    YangKeao committed May 13, 2019
    Remove existing code of handling `SIGUSR2`. It's no longer needed with
    support of dumping profile with HTTP request.
    
    Remove Option in `dump_prof` arguments because all usage of it is pass a
    `Some`.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
  22. tikv_alloc/*, server/status_server: handle error in dump_prof

    YangKeao committed May 13, 2019
    Handle error in dump_prof function by returning it.
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
Commits on Jun 3, 2019
  1. Merge remote-tracking branch 'origin/master' into http-prof

    brson committed Jun 3, 2019
Commits on Jun 5, 2019
  1. server/status_server: Set default value of `seconds`

    YangKeao committed Jun 5, 2019
    Set default value of `seconds` parameter according to TiDB
    status_server. (10 seconds)
    
    Signed-off-by: Yang Keao <keao.yang@yahoo.com>
Commits on Jun 7, 2019
You can’t perform that action at this time.