-
Notifications
You must be signed in to change notification settings - Fork 113
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
LD_PRELOAD Causes Error on Deployment #6
Comments
Good catch. Are you setting If so, change If not, set that instead of using |
Actually, I'm wrong. Which stack are you using? |
@mojodna I am using the cedar-14 stack with Ruby 2.3.3. I had set the LD_PREPOLOAD via Heroku config. I had originally thought it was a typo as well, but I connected via bash and was able to verify the libjemalloc.so.1 does exist. Exact commands executed: heroku config -s | grep LD_PRELOAD Please let me know if I can provide any other details/info. Thanks, |
I was able to reproduce the error by running Try reconnecting to the dyno via ldd /app/vendor/jemalloc/lib/libjemalloc.so.1 Output should be (and there should be no error when connecting): ~ $ ldd /app/vendor/jemalloc/lib/libjemalloc.so.1
linux-vdso.so.1 => (0x00007ffc5dffb000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f53da66d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f53da2a8000)
/lib64/ld-linux-x86-64.so.2 (0x00007f53daacb000) |
I get the following: ~ $ ldd /app/vendor/jemalloc/lib/libjemalloc.so.1 I did a bit more testing. On a brand new/empty rails project (4.2.7.1), I get the error ERROR: ld.so: object '/app/vendor/jemalloc/lib/libjemalloc.so.1' from LD_PRELOAD cannot be preloaded (cannot open shared object file, but the build is still deployed. In my app, looking through more of the output I also see a JSON:ParseError (see http://d.pr/n/2bZd) I tried to play around with some of the gem versions of sprockets (3.7.0) and sprocket-rails (3.2.0), but I have not been able to narrow down the issue. Thanks, |
Can you share access with me so I can do some poking around? mojodna / seth at mojodna dot net |
Hi @mojodna I'm having the same issue with a Heroku app :
I'm using the same buildpack/configuration on Scalingo without any specific issues. If you want, I could add you on the open-source project we run with this lib on Heroku. |
Curious about this if it still exists, I am wanting to use this in production on Heroku, rails 5, ruby 2.4.1, I'm hesitant to pull the trigger though. |
Let's try and get it fixed if it is an issue. Can everyone using LD_PRELOAD as an env variable (like in your "config settings" in Heroku or whatever) in this thread please try removing that and just use i.e.:
|
I havent tried using it yet, but I could try now. I did have one other question, do you know how I might do this if I'm using pgbouncer? It's
|
@9mm I think |
I ran into this issue a while back setting LD_PRELOAD but just prefixing |
It works with the script, but it makes the Procfile strongly environment-dependent. |
I too was unable to get LD_PRELOAD to work. Using jemalloc.sh in the Procfile did work, and reduced my overall memory usage significantly, but increased my swap memory usage. Some days, after nearly a full day's uptime, I'd see ~17MB of swap memory when my total memory usage was under 70%. With the stock allocator, those numbers are more like 2-6MB at 80-85% usage. I bring it up here in case this sort of misbehavior is the result of having the script prepended only to processes in the Procfile, rather than all commands run on the dyno, making the Procfile option less viable. Has anyone else seen this? This behavior was consistent on both the Cedar-14 and Heroku-16 stacks, running Rails 5.0 with Ruby 2.4.1 on a Hobby web dyno. |
@brian-kephart 17mb of swap is nothing to worry about. If anything, it indicates the allocator is being more efficient because it's grouping memory pages in such a way that the operating system can swap larger portions out of the resident set. |
I managed to fix this problem by setting I think that the problem we're having is a result of having the environment variable present before the buildpack scripts pull in the binaries. Setting the variable within the buildpack seems to solve it. Before I submit a pull request, is there any reason not to set |
@brian-kephart I believe the issue with |
@brian-kephart another option , ugly as it may is to wrap your and run:
This should remove all build log errors and apply it to the environment in full. |
I can confirm @ohaddahan's experience with it no longer causing a build error. I had read @nateberkopec's recent blog post and tried again yesterday. I still see many errors during the deploy, but it is successful. If there is an easy way to test that it is properly and working/active that would be really helpful. |
@scottwater you can log into your machine and check either: If it exists and set, all Linux process must load the shared library before they start running. |
@ohaddahan Yes, you can check that the LD_PRELOAD value is correct as you described, but follow mojodna's instructions in this thread from 12/27/16 to make sure the specified file is actually there. If the LD_PRELOAD value is correct, the file is present, and you see no runtime errors, all should be well. There might be better checks in the jemalloc documentation, though. |
@brian-kephart basically if |
Xavier Noria asked me a similar question once - is it possible to be completely sure jemalloc was running in the Ruby process. As you mentioned @ohaddahan, I think trying to use a jemalloc specific feature or symbol would be the only way to be totally sure. |
@nateberkopec actually I think it can be simpler , attaching to the ruby process with gdb or running collect / strace / ltrace on the process. |
I believe this would be fixed by #18 when using JEMALLOC_ENABLED as LD_PRELOAD is being set in |
how do i verify if jemalloc is running on heroku/dokku (im running RoR) |
@wongy91 Here's one way: $ ruby -r rbconfig -e "puts RbConfig::CONFIG['LIBS']"
-lpthread -ljemalloc -lgmp -ldl -lobjc |
@citizen428 I'm not OP, but running
But I can confirm it shows
This is all to ask, am I right in believing that jemalloc is likely running despite not seeing it built when running the command you've provided? I just installed jemalloc onto my server so I'm not entirely sure if I've done everything right. |
@k5o you can try this CheckJEMalloc , this actually tries using a symbol from JEMalloc. |
@ohaddahan that script is a great idea. However, like @k5o, my irb(main):001:0> CheckJEMalloc.je_malloc_exists?
FFI::NotFoundError : Function 'je_malloc' not found in [/app/vendor/jemalloc/lib/libjemalloc.so.2]
=> false
irb(main):002:0> ENV['LD_PRELOAD']
=> "/app/vendor/jemalloc/lib/libjemalloc.so.2"
irb(main):003:0> puts `file ENV['LD_PRELOAD']`
/app/vendor/jemalloc/lib/libjemalloc.so.2: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=78d9b314f3040553f25655f32de403fa5f472f97, with debug_info, not stripped
=> nil Now, I wonder if that script only works with older jemalloc (I have |
I am seeing the same result as @bjeanes, @ohaddahan |
You can try and use a different symbol from Also, run |
Unfortunately, on Heroku:
I tried linking directly to
Yeah I realise that. That was just context for why I was using the Ruby script you posted instead.
No warnings |
I'm able to run |
Ah perhaps we are on different stacks then or |
I am investing using this buildpack.
Durning my deployment to heroku, the build is rejected do to an error (cannot open shared object file).
Some of the output (same error over and over) is below.
Any suggestions for a next step? Any other info I could provide?
Thanks,
Scott
kickoff:jemal g push staging jemal:master
Counting objects: 12, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (12/12), 931 bytes | 0 bytes/s, done.
Total 12 (delta 9), reused 2 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Deleting 1 files matching .slugignore patterns.
remote: -----> jemalloc app detected
remote: -----> Vendoring binaries
remote: Fetching https://github.com/mojodna/heroku-buildpack-jemalloc/releases/download/4.2.1/jemalloc-4.2.1-1.tar.gz
remote: -----> Configuring build environment
remote: -----> Building runtime environment
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.3
remote: -----> Installing dependencies using bundler 1.13.6
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: ERROR: ld.so: object '/app/vendor/jemalloc/lib/libjemalloc.so.1' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
The text was updated successfully, but these errors were encountered: