Skip to content

Instantly share code, notes, and snippets.

@Paxa

Paxa/0. notes.md Secret

Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Paxa/ed01ea61db0fc789578a to your computer and use it in GitHub Desktop.
Save Paxa/ed01ea61db0fc789578a to your computer and use it in GitHub Desktop.
rbkit

Try to install on OS X 10.10 it fails, aftet brew install zeromq msgpack installed. Probably need to add it in README.md in Usage section


Lack of example, would be nice to have copy-paste simple code. Something like rack or sinatra app, or even WebRick app.


I add code

require "rbkit"
Rbkit.start_server

Connect via GUI and it's empty charts. It show it's connected, nothing happening After I add Rbkit.start_profiling it started to work


Charts have time moving now, but it's still zeros. No data. Even small sinatra app should have some memory usage


I stopped process, GUI still says "Currently profiling ruby application", time moving. Data still zeros


Try to disconnect and connect again, and got "Error connecting to Ruby application"

Re-open, press Cmd+Q, and go "Error connecting to Ruby application" again


Restarting process and it says "Rbkit server couldn't bind to socket, check if it is already running. Profiling data will not be available."

I think it will be better if we can know what socket it try to open (port and interface, eg 127.0.0.1:5555). I checked with netstat nothing uses 5555 and 5556. Try with telnet - also Connection refused

I try use different ports: Rbkit.start_server(pub_port: 30010, request_port: 30020) - still same

As I see network interface is not configurable

sprintf(zmq_endpoint, "tcp://127.0.0.1:%d", FIX2INT(pub_port));

It's possible to get info about connection error http://api.zeromq.org/2-1:zmq-bind, may be it will help to fix problem easier


Ok, version from ruby gems is outdated, there is alot of commits since january 15


Recompile from git, run it and got:

% ruby sinatra.rb 
[1]    34085 abort      ruby sinatra.rb

It caused by Rbkit.start_server(pub_port: 30010, request_port: 30020), with just Rbkit.start_server it give same "Rbkit server couldn't bind to socket, check if it is already running. Profiling data will not be available."


Try Rbkit.start_profiling(pub_port: 9999, request_port: 9998) from some pull request, it gives same message


Now I have ruby process using 86-70% CPU all the time, can not close with Ctrl+C, memory 23mb as expected


Try to run experiments/using_rbkit.rb from latest git, seems like it opened port, connection via GUI and GUI crashed.

/Users/pavel/.rbenv/versions/2.1.5/bin/ruby -r ./siteconf20150806-32478-onfn2e.rb extconf.rb
checking for rb_postponed_job_register_one()... yes
checking for rb_profile_frames()... yes
checking for rb_tracepoint_new()... yes
checking for RUBY_INTERNAL_EVENT_NEWOBJ... yes
checking for main() in -lzmq... no
checking for libtool... yes
checking for autoconf... yes
checking for automake... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/pavel/.rbenv/versions/2.1.5/bin/ruby
--with-zmqlib
--without-zmqlib
extconf.rb:33:in `block in download_and_install_zeromq_from_source': automake needed by zeromq not found. (RuntimeError)
from extconf.rb:32:in `each'
from extconf.rb:32:in `download_and_install_zeromq_from_source'
from extconf.rb:80:in `<main>'
extconf failed, exit code 1
have_func: checking for rb_postponed_job_register_one()... -------------------- yes
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
conftest.c:13:57: error: use of undeclared identifier 'rb_postponed_job_register_one'
int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_postponed_job_register_one; return 0; }
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_postponed_job_register_one; return 0; }
/* end */
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
conftest.c:13:15: warning: implicit declaration of function 'rb_postponed_job_register_one' is invalid in C99 [-Wimplicit-function-declaration]
int t(void) { rb_postponed_job_register_one(); return 0; }
^
1 warning generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { rb_postponed_job_register_one(); return 0; }
/* end */
--------------------
have_func: checking for rb_profile_frames()... -------------------- yes
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
conftest.c:13:57: error: use of undeclared identifier 'rb_profile_frames'
int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_profile_frames; return 0; }
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_profile_frames; return 0; }
/* end */
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
conftest.c:13:15: warning: implicit declaration of function 'rb_profile_frames' is invalid in C99 [-Wimplicit-function-declaration]
int t(void) { rb_profile_frames(); return 0; }
^
1 warning generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { rb_profile_frames(); return 0; }
/* end */
--------------------
have_func: checking for rb_tracepoint_new()... -------------------- yes
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
conftest.c:13:57: error: use of undeclared identifier 'rb_tracepoint_new'
int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_tracepoint_new; return 0; }
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_tracepoint_new; return 0; }
/* end */
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lpthread -ldl -lobjc "
conftest.c:13:15: warning: implicit declaration of function 'rb_tracepoint_new' is invalid in C99 [-Wimplicit-function-declaration]
int t(void) { rb_tracepoint_new(); return 0; }
^
1 warning generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { rb_tracepoint_new(); return 0; }
/* end */
--------------------
have_const: checking for RUBY_INTERNAL_EVENT_NEWOBJ... -------------------- yes
"clang -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: typedef int conftest_type;
5: conftest_type conftestval = (int)RUBY_INTERNAL_EVENT_NEWOBJ;
/* end */
--------------------
have_library: checking for main() in -lzmq... -------------------- no
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lzmq -lpthread -ldl -lobjc "
ld: library not found for -lzmq
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
/* end */
"clang -o conftest -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/x86_64-darwin13.0 -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0/ruby/backward -I/Users/pavel/.rbenv/versions/2.1.5/include/ruby-2.1.0 -I. -I/Users/pavel/.rbenv/versions/2.1.5/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -L. -L/Users/pavel/.rbenv/versions/2.1.5/lib -fstack-protector -lruby-static -framework CoreFoundation -lzmq -lpthread -ldl -lobjc "
conftest.c:13:20: error: too few arguments to function call, expected 2, have 0
int t(void) { main(); return 0; }
~~~~ ^
conftest.c:5:1: note: 'main' declared here
int main(int argc, char **argv)
^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: /*top*/
4: extern int t(void);
5: int main(int argc, char **argv)
6: {
7: if (argc > 1000000) {
8: printf("%p", &t);
9: }
10:
11: return 0;
12: }
13: int t(void) { main(); return 0; }
/* end */
--------------------
find_executable: checking for libtool... -------------------- yes
--------------------
find_executable: checking for autoconf... -------------------- yes
--------------------
find_executable: checking for automake... -------------------- no
--------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment