Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gaffneyc/heroku-buildpack-tcmalloc

Easily install and use Google's TCMalloc on Heroku
https://github.com/gaffneyc/heroku-buildpack-tcmalloc

heroku heroku-buildpack tcmalloc

Last synced: about 1 month ago
JSON representation

Easily install and use Google's TCMalloc on Heroku

Awesome Lists containing this project

README

        

# heroku-buildpack-tcmalloc

[TCMalloc](https://github.com/gperftools/gperftools) is a thread-caching malloc
implementation designed to reduce fragmentation in multithreaded applications.
This buildpack makes it easy to install and use TCMalloc on Heroku and
compatible platforms.

## Install

```console
heroku buildpacks:add https://github.com/gaffneyc/heroku-buildpack-tcmalloc.git
git push heroku master
```

## Made possible by Dead Man's Snitch

Continued development and support of the tcmalloc buildpack is sponsored by
[Dead Man's Snitch](https://deadmanssnitch.com).

Ever been surprised that a critical recurring job was silently failing to run?
Whether it's backups, cache clearing, sending invoices, or whatever your
application depends on, Dead Man's Snitch makes it easy to
[monitor heroku scheduler](https://deadmanssnitch.com/docs/heroku) tasks or to add
[cron job monitoring](https://deadmanssnitch.com/docs/cron-job-monitoring) to
your other services.

Get started for free today with [Dead Man's Snitch on Heroku](https://elements.heroku.com/addons/deadmanssnitch)

## Usage

### Recommended

Set the TCMALLOC_ENABLED config option to true and tcmalloc will be used for
all commands run inside of your dynos.

```console
heroku config:set TCMALLOC_ENABLED=true
```

### Per dyno

To control when tcmalloc is configured on a per dyno basis use
`tcmalloc.sh ` and ensure that TCMALLOC_ENABLED is unset.

Example Procfile:
```yaml
web: tcmalloc.sh bundle exec puma -C config/puma.rb
```

## Configuration

### TCMALLOC_ENABLED

Set this to true to automatically enable tcmalloc.

```console
heroku config:set TCMALLOC_ENABLED=true
```

To disable tcmalloc set the option to false. This will cause the application to
restart disabling tcmalloc.

```console
heroku config:set TCMALLOC_ENABLED=false
```

### TCMALLOC_VERSION

Set this to select or pin to a specific version of tcmalloc. The default is to
use the latest stable version if this is not set. You will receive an error
mentioning tar if the version does not exist.

**Default**: `2.7`

**note:** This setting is only used during slug compilation. Changing it will
require a code change to be deployed in order to take affect.

```console
heroku config:set TCMALLOC_VERSION=2.7
```

#### Available Versions

| Version | Released |
| ------------------------------------------------------------------------------- | ---------- |
| [2.7](https://github.com/gperftools/gperftools/releases/tag/gperftools-2.7) | 2018-04-30 |
| [2.8](https://github.com/gperftools/gperftools/releases/tag/gperftools-2.8) | 2020-07-06 |
| [2.8.1](https://github.com/gperftools/gperftools/releases/tag/gperftools-2.8.1) | 2020-12-21 |
| [2.9](https://github.com/gperftools/gperftools/releases/tag/gperftools-2.9) | 2021-02-21 |
| [2.9.1](https://github.com/gperftools/gperftools/releases/tag/gperftools-2.9.1) | 2021-03-02 |

The complete and most up to date list of supported versions and stacks is
available on the [releases page.](https://github.com/gaffneyc/heroku-buildpack-tcmalloc/releases)

## Building

This uses Docker to build against Heroku
[stack-image](https://github.com/heroku/stack-images)-like images.

```console
make VERSION=2.7
```

Artifacts will be dropped in `dist/` based on Heroku stack and tcmalloc version.

### Deploying New Versions

- `make VERSION=X.Y.Z`
- `open dist`
- Go to [releases](https://github.com/gaffneyc/heroku-buildpack-tcmalloc/releases)
- Edit the release corresponding to each heroku Stack
- Drag and drop the new build to attach

### Creating a New Stack
- Go to [releases](https://github.com/gaffneyc/heroku-buildpack-tcmalloc/releases)
- Click "Draft a new release"
- Tag is the name of the Stack (e.g. `heroku-18`)
- Target is `release-master`
- Title is `Builds for the [stack] stack`