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

Revert "[Feature] use jemalloc as wasm global memory allocator" #593

Merged
merged 2 commits into from
Nov 1, 2021

Conversation

yun-yeo
Copy link
Contributor

@yun-yeo yun-yeo commented Oct 26, 2021

Reverts terra-money/core#586
close #592

Instead adopting jemalloc only for wasmvm, we need to replace whole memory allocator of terrad process.

for that,

  1. Install jemalloc.
JEMALLOC_VERSION=5.2.1
wget https://github.com/jemalloc/jemalloc/releases/download/$JEMALLOC_VERSION/jemalloc-$JEMALLOC_VERSION.tar.bz2 
tar -xf ./jemalloc-$JEMALLOC_VERSION.tar.bz2 
cd jemalloc-$JEMALLOC_VERSION

# for the node with high query rate or wasm cache size, recommend below config
# ./configure --with-malloc-conf=background_thread:true,dirty_decay_ms:5000,muzzy_decay_ms:5000
./configure --with-malloc-conf=background_thread:true,metadata_thp:auto,dirty_decay_ms:30000,muzzy_decay_ms:30000
make
sudo make install
  1. Restart the process with LD_PRELOAD=/usr/local/lib/libjemalloc.so terrad start.

If you are using systemd or another process manager to launch terrad, you might need to configure them. The following sample systemd file fixes the problem:

# /etc/systemd/system/terrad.service
[Unit]
Description=Terra Columbus Node
After=network.target

[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu
ExecStart=/home/ubuntu/go/bin/terrad start
Restart=on-failure
RestartSec=3
LimitNOFILE=4096
Environment="LD_PRELOAD=/usr/local/lib/libjemalloc.so"

[Install]
WantedBy=multi-user.target

@yun-yeo yun-yeo self-assigned this Oct 26, 2021
@codecov
Copy link

codecov bot commented Oct 26, 2021

Codecov Report

Merging #593 (afbb588) into main (6235f92) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #593   +/-   ##
=======================================
  Coverage   44.81%   44.81%           
=======================================
  Files         122      122           
  Lines        7016     7016           
=======================================
  Hits         3144     3144           
  Misses       3627     3627           
  Partials      245      245           

@yun-yeo yun-yeo requested a review from hanjukim October 27, 2021 03:27
@yun-yeo
Copy link
Contributor Author

yun-yeo commented Oct 28, 2021

hmm seeing huge wasm cache make the node's memory constantly increasing without this patch.
so maybe better to keep this?

I will do more testing.

@yun-yeo yun-yeo merged commit 3fcaa62 into main Nov 1, 2021
@yun-yeo yun-yeo deleted the revert-586-feature/wasm-jemalloc branch November 1, 2021 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] memory fragmentation
2 participants