Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anoopprasad/a86cc6ec917b7a2a126cdc68bf2c7c5b to your computer and use it in GitHub Desktop.
Save anoopprasad/a86cc6ec917b7a2a126cdc68bf2c7c5b to your computer and use it in GitHub Desktop.

Revisions

  1. @toshimaru toshimaru revised this gist Nov 18, 2021. 2 changed files with 2 additions and 0 deletions.
    1 change: 1 addition & 0 deletions check-server-process-using-jemalloc.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # Check server process is using jemalloc
    # ref. [Japanese] https://tech.studyplus.co.jp/entry/2019/09/09/094140
    class AppController < ActionController::Base
    def show
    r = `strings /proc/#{Process.pid}/maps | grep jemalloc`
    1 change: 1 addition & 0 deletions enable-jemalloc-for-alpine.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@ RUN wget -O - https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemal
    make && \
    make install


    FROM ruby:2.7-alpine

    COPY --from=builder /usr/local/lib/libjemalloc.so.2 /usr/local/lib/
  2. @toshimaru toshimaru revised this gist Nov 16, 2021. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion check-server-process-using-jemalloc.rb
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # check server process is using jemalloc
    # Check server process is using jemalloc
    class AppController < ActionController::Base
    def show
    r = `strings /proc/#{Process.pid}/maps | grep jemalloc`
    2 changes: 1 addition & 1 deletion enable-jemalloc-for-alpine.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ## Dockefile
    ## Dockerfile

    ```dockerfile
    FROM ruby:2.7-alpine AS builder
  3. @toshimaru toshimaru created this gist Nov 16, 2021.
    7 changes: 7 additions & 0 deletions check-server-process-using-jemalloc.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # check server process is using jemalloc
    class AppController < ActionController::Base
    def show
    r = `strings /proc/#{Process.pid}/maps | grep jemalloc`
    render plain: "<h1>#{ENV['LD_PRELOAD'].presence || 'empty'}</h1><pre>#{r}</pre>"
    end
    end
    21 changes: 21 additions & 0 deletions enable-jemalloc-for-alpine.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    ## Dockefile

    ```dockerfile
    FROM ruby:2.7-alpine AS builder

    RUN apk add build-base
    RUN wget -O - https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2 | tar -xj && \
    cd jemalloc-5.2.1 && \
    ./configure && \
    make && \
    make install

    FROM ruby:2.7-alpine

    COPY --from=builder /usr/local/lib/libjemalloc.so.2 /usr/local/lib/
    ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so.2
    ```

    ## Reference

    - https://github.com/jemalloc/jemalloc/issues/1443#issuecomment-624142451