Code Monkey home page Code Monkey logo

gctools's Introduction

gctools

gc profiler/logger and oobgc for rgengc in ruby 2.1

design

built on new apis and events offered in ruby 2.1:

  • rb_gc_stat()
  • rb_gc_latest_gc_info()
  • RUBY_INTERNAL_EVENT_GC_START
  • RUBY_INTERNAL_EVENT_GC_END_MARK
  • RUBY_INTERNAL_EVENT_GC_END_SWEEP

usage

logger

require 'gctools/logger'

oobgc

require 'gctools/oobgc'
GC::OOB.run # after every request
use(GC::OOB::UnicornMiddleware) # in config.ru for unicorn

gctools's People

Contributors

bkeepers avatar krasnoukhov avatar tmm1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gctools's Issues

Require 'gctools/oobgc'

What is this require referring to?:

https://github.com/tmm1/gctools/blob/master/lib/gctools/oobgc/unicorn_middleware.rb#L1

The documentation also says that to use the middleware you should add to config.ru:

require 'gctools/oobgc'
GC::OOB.run # after every request
use(GC::OOB::UnicornMiddleware) # in config.ru for unicorn

As far as I can tell this gctools/oobgc' file does not exist inside this library. Having the require in the middleware to a non-existent file makes it impossible for me to load this middleware... unless I am missing something.

wrong argument type Class (expected Module)

Added code snippet to config.ru:

# This file is used by Rack-based servers to start the application.

require 'gctools/oobgc'
if defined?(Unicorn::HttpRequest)
  use GC::OOB::UnicornMiddleware
end

require ::File.expand_path('../config/environment',  __FILE__)
run AwesomeApp::Application

When starting up, I get the following error:

.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/gctools-0.2.2/lib/gctools/oobgc/unicorn_middleware.rb:8:in `extend': wrong argument type Class (expected Module) (TypeError)

Any ideas on what I'm missing?

unicorn (4.5.0)
gctools (0.2.2)

Cut a release?

Noticed

/app/vendor/bundle/ruby/2.2.0/gems/gctools-0.2.3/lib/gctools/oobgc/unicorn_middleware.rb:14: warning: GC.stat keys were changed from Ruby 2.1. In this case, you refer to obsolete `total_allocated_object' (new key is `total_allocated_objects'). Please check <https://bugs.ruby-lang.org/issues/9924> for more information.

Looks already fixed on HEAD in #14, maybe cut a release?

Ruby 2.5 support

Tracking Ruby 2.5 support in this issue.

Running require 'gctools/oobgc/unicorn_middleware' in Ruby 2.5.0 generates the following error:

LoadError (/var/lib/gems/2.5.0/gems/gctools-0.2.4/lib/gctools/oobgc.so: undefined symbol: rb_autoload - /var/lib/gems/2.5.0/gems/gctools-0.2.4/lib/gctools/oobgc.so)

This might be fixed in the next published release of 2.5.x by f6631c30.

GC is never triggered

Using https://github.com/github/ruby/tree/2.1 w/ 4 unicorn workers on a rails app:

$ ab -n300 -c4 http://0.0.0.0:8080/

Workers are GC.disableed after forked. The GC settings are the default ones.

GC is never triggered even though GC::OOB.run is called. Yet memory peeks at 12gb after ~60reqs:

# after the 60th request
GC.stat
# => {:count=>32,
 :heap_used=>59478,
 :heap_length=>59682,
 :heap_increment=>204,
 :heap_live_slot=>24231036,
 :heap_free_slot=>12174,
 :heap_final_slot=>0,
 :heap_swept_slot=>180347,
 :heap_eden_page_length=>59478,
 :heap_tomb_page_length=>0,
 :total_allocated_object=>28445740,
 :total_freed_object=>4214704,
 :malloc_increase=>698054064,
 :malloc_limit=>14000000,
 :minor_gc_count=>25,
 :major_gc_count=>7,
 :remembered_shady_object=>5569,
 :remembered_shady_object_limit=>9834,
 :old_object=>357190,
 :old_object_limit=>589654,
 :oldmalloc_increase=>589477296,
 :oldmalloc_limit=>22319355}

After the 300th req:

GC.stat
# => {:count=>32,
 :heap_used=>277812,
 :heap_length=>277977,
 :heap_increment=>165,
 :heap_live_slot=>113224475,
 :heap_free_slot=>11710,
 :heap_final_slot=>0,
 :heap_swept_slot=>180355,
 :heap_eden_page_length=>277812,
 :heap_tomb_page_length=>0,
 :total_allocated_object=>117439030,
 :total_freed_object=>4214555,
 :malloc_increase=>3116922544,
 :malloc_limit=>14000000,
 :minor_gc_count=>25,
 :major_gc_count=>7,
 :remembered_shady_object=>5571,
 :remembered_shady_object_limit=>9834,
 :old_object=>357202,
 :old_object_limit=>589622,
 :oldmalloc_increase=>2613982896,
 :oldmalloc_limit=>22319355}

Also tried with a smaller MALLOC_LIMIT, no luck.

GCProf.after_gc_hook [BUG] object allocation during garbage collection phase

๐Ÿ’ฅ on 2.1.1 and trunk:

$ irb -rgctools/gcprof
>> RUBY_DESCRIPTION
=> "ruby 2.2.0dev (2014-03-29 trunk 45468) [x86_64-darwin13]"
>> GCProf.after_gc_hook = -> { puts 'foo' }
=> #<Proc:0x007ff8464a91d8@(irb):1 (lambda)>
>> GC.start
(irb):2: [BUG] object allocation during garbage collection phase
ruby 2.2.0dev (2014-03-29 trunk 45468) [x86_64-darwin13]

-- C level backtrace information -------------------------------------------
0   ruby                                0x0000000107460306 rb_vm_bugreport + 134
1   ruby                                0x00000001073131f3 report_bug + 307
2   ruby                                0x00000001073130ac rb_bug + 188
3   ruby                                0x000000010732f868 newobj_of + 1048
4   ruby                                0x000000010733cf38 rb_hash_new + 24
5   ruby                                0x0000000107339e44 gc_count_add_each_types + 36
6   ruby                                0x0000000107333695 gc_stat_internal + 3397
7   ruby                                0x0000000107332938 rb_gc_stat + 72
8   gcprof.bundle                       0x0000000107a28c1d gc_hook_i + 157
9   ruby                                0x00000001074638fb tp_call_trace + 43
10  ruby                                0x0000000107462e94 rb_threadptr_exec_event_hooks_orig + 468
11  ruby                                0x000000010733ab99 garbage_collect_body + 2681
12  ruby                                0x00000001073321b6 garbage_collect + 326
[...]

License file

Could you add a license file? We'd like to use this over at New Relic, and properly document and attribute the open source code we use.

Ruby 2.2 Support?

After I upgraded my Rails(4.1.8) to Ruby 2.2.0. I notice some error messages in my logs:

app web.1     - - E, [2015-01-02T04:19:12.265987 #12] ERROR -- : listen loop error: unknown key: old_object (ArgumentError)
app web.1     - - E, [2015-01-02T04:19:12.266103 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/gems/gctools-0.2.3/lib/gctools/oobgc/unicorn_middleware.rb:14:in `run'
app web.1     - - E, [2015-01-02T04:19:12.266146 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/gems/gctools-0.2.3/lib/gctools/oobgc/unicorn_middleware.rb:14:in `process_client'
app web.1     - - E, [2015-01-02T04:19:12.266177 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/gems/unicorn-worker-killer-0.4.2/lib/unicorn/worker_killer.rb:51:in `process_client'
app web.1     - - E, [2015-01-02T04:19:12.266207 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/gems/unicorn-worker-killer-0.4.2/lib/unicorn/worker_killer.rb:124:in `process_client'
app web.1     - - E, [2015-01-02T04:19:12.266237 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop'
app web.1     - - E, [2015-01-02T04:19:12.266267 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
app web.1     - - E, [2015-01-02T04:19:12.266296 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start'
app web.1     - - E, [2015-01-02T04:19:12.266324 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
app web.1     - - E, [2015-01-02T04:19:12.266354 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/bin/unicorn:23:in `load'
app web.1     - - E, [2015-01-02T04:19:12.266381 #12] ERROR -- : /app/vendor/bundle/ruby/2.2.0/bin/unicorn:23:in `<main>'

I was wondering do we still suppose to use it on Ruby 2.2? Or it should only be used on Ruby 2.1?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.