Hello community,

here is the log from the commit of package yast2-ruby-bindings for 
openSUSE:Factory checked in at 2016-07-07 15:09:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-ruby-bindings (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-ruby-bindings.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-ruby-bindings"

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-ruby-bindings/yast2-ruby-bindings.changes  
2016-06-02 12:49:39.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.yast2-ruby-bindings.new/yast2-ruby-bindings.changes 
    2016-07-07 15:09:56.000000000 +0200
@@ -1,0 +2,15 @@
+Thu Jun 30 09:24:32 UTC 2016 - [email protected]
+
+- Fix segfault when running rspec tests caused by added ruby
+  profiler (bnc#986649 comment2)
+- 3.1.50
+
+-------------------------------------------------------------------
+Tue Jun 28 14:21:55 UTC 2016 - [email protected]
+
+- Added support for running the Ruby profiler
+- Improve performance of code by specialized `caller` call
+  (bnc#986649)
+- 3.1.49
+
+-------------------------------------------------------------------

Old:
----
  yast2-ruby-bindings-3.1.48.tar.bz2

New:
----
  yast2-ruby-bindings-3.1.50.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-ruby-bindings.spec ++++++
--- /var/tmp/diff_new_pack.shHv45/_old  2016-07-07 15:09:57.000000000 +0200
+++ /var/tmp/diff_new_pack.shHv45/_new  2016-07-07 15:09:57.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ruby-bindings
-Version:        3.1.48
+Version:        3.1.50
 Release:        0
 Url:            https://github.com/yast/yast-ruby-bindings
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-ruby-bindings-3.1.48.tar.bz2 -> yast2-ruby-bindings-3.1.50.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.48/package/yast2-ruby-bindings.changes 
new/yast2-ruby-bindings-3.1.50/package/yast2-ruby-bindings.changes
--- old/yast2-ruby-bindings-3.1.48/package/yast2-ruby-bindings.changes  
2016-05-31 09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/package/yast2-ruby-bindings.changes  
2016-06-30 14:15:47.000000000 +0200
@@ -1,4 +1,19 @@
 -------------------------------------------------------------------
+Thu Jun 30 09:24:32 UTC 2016 - [email protected]
+
+- Fix segfault when running rspec tests caused by added ruby
+  profiler (bnc#986649 comment2)
+- 3.1.50
+
+-------------------------------------------------------------------
+Tue Jun 28 14:21:55 UTC 2016 - [email protected]
+
+- Added support for running the Ruby profiler
+- Improve performance of code by specialized `caller` call
+  (bnc#986649)
+- 3.1.49
+
+-------------------------------------------------------------------
 Mon May 30 14:38:02 UTC 2016 - [email protected]
 
 - Improve the debugger support - use the same code also at run
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-ruby-bindings-3.1.48/package/yast2-ruby-bindings.spec 
new/yast2-ruby-bindings-3.1.50/package/yast2-ruby-bindings.spec
--- old/yast2-ruby-bindings-3.1.48/package/yast2-ruby-bindings.spec     
2016-05-31 09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/package/yast2-ruby-bindings.spec     
2016-06-30 14:15:47.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-ruby-bindings
-Version:        3.1.48
+Version:        3.1.50
 Url:            https://github.com/yast/yast-ruby-bindings
 Release:        0
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.48/src/binary/CMakeLists.txt 
new/yast2-ruby-bindings-3.1.50/src/binary/CMakeLists.txt
--- old/yast2-ruby-bindings-3.1.48/src/binary/CMakeLists.txt    2016-05-31 
09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/src/binary/CMakeLists.txt    2016-06-30 
14:15:47.000000000 +0200
@@ -99,7 +99,10 @@
 target_link_libraries( builtinx ${YAST_PLUGIN_SCR_LIBRARY} )
 target_link_libraries( builtinx ${YAST_PLUGIN_WFM_LIBRARY} )
 target_link_libraries( builtinx ${YAST_PLUGIN_UI_LIBRARY} )
-target_link_libraries( builtinx crypt )
+find_library( CRYPT_LIBRARY crypt )
+if ( CRYPT_LIBRARY )
+  target_link_libraries( builtinx ${CRYPT_LIBRARY} )
+endif()
 find_library( OWCRYPT_LIBRARY owcrypt )
 if ( OWCRYPT_LIBRARY )
   target_link_libraries( builtinx ${OWCRYPT_LIBRARY} )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.48/src/binary/YRuby.cc 
new/yast2-ruby-bindings-3.1.50/src/binary/YRuby.cc
--- old/yast2-ruby-bindings-3.1.48/src/binary/YRuby.cc  2016-05-31 
09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/src/binary/YRuby.cc  2016-06-30 
14:15:47.000000000 +0200
@@ -53,6 +53,7 @@
 
 YRuby * YRuby::_yRuby = 0;
 bool YRuby::_y_ruby_finalized = false;
+bool YRuby::_y_in_yast = false;
 
 YRuby::YRuby()
 {
@@ -62,22 +63,28 @@
   // so the ruby interpreter can set the external string encoding properly
   setlocale (LC_ALL, "");
 
+  // re-init of ruby is not nice, but ruby handle it. We need it for detection 
if ruby is initialized
+  // as ruby itself currently to not allow to check if VM is initialized
   RUBY_INIT_STACK;
   ruby_init();
   ruby_init_loadpath();
 
-  // FIX for setup gem load path. Embedded ruby initialization mixes up gem
-  // initialization (which we want) with option processing (which we don't 
want).
-  // Copying only needed parts of `ruby_options` here.
-  // See http://subforge.org/blogs/show/1
-  // Note that the solution is different to not touch internal ruby
-  rb_define_module("Gem");
-  y2_require("rubygems");
-
-  // encoding initialization
-  y2_require("enc/encdb.so");
-  y2_require("enc/trans/transdb.so");
-  rb_enc_find_index("encdb");
+  if (rb_eval_string("defined? Gem") == Qnil) // Dirty hack to recognize we 
run from YaST and not ruby
+  {
+    _y_in_yast = true;
+    // FIX for setup gem load path. Embedded ruby initialization mixes up gem
+    // initialization (which we want) with option processing (which we don't 
want).
+    // Copying only needed parts of `ruby_options` here.
+    // See http://subforge.org/blogs/show/1
+    // Note that the solution is different to not touch internal ruby
+    rb_define_module("Gem");
+    y2_require("rubygems");
+
+    // encoding initialization
+    y2_require("enc/encdb.so");
+    y2_require("enc/trans/transdb.so");
+    rb_enc_find_index("encdb");
+  }
 
   VALUE ycp_references = Data_Wrap_Struct(rb_cObject, gc_mark, gc_free, & 
value_references_from_ycp);
   rb_global_variable(&ycp_references);
@@ -108,7 +115,10 @@
 YRuby::~YRuby()
 {
     y2milestone( "Shutting down ruby interpreter." );
-    //ruby_finalize(); Do not finalize to allow clear work inside ruby
+
+    if (_y_in_yast)
+      ruby_finalize(); // finalize only when embedded by yast
+
     _y_ruby_finalized = true;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.48/src/binary/YRuby.h 
new/yast2-ruby-bindings-3.1.50/src/binary/YRuby.h
--- old/yast2-ruby-bindings-3.1.48/src/binary/YRuby.h   2016-05-31 
09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/src/binary/YRuby.h   2016-06-30 
14:15:47.000000000 +0200
@@ -97,6 +97,7 @@
 public:
     static YRuby *     _yRuby;
     static bool  _y_ruby_finalized;
+    static bool  _y_in_yast;
     refcount_map_t value_references_from_ycp;
 };
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.48/src/ruby/yast/logger.rb 
new/yast2-ruby-bindings-3.1.50/src/ruby/yast/logger.rb
--- old/yast2-ruby-bindings-3.1.48/src/ruby/yast/logger.rb      2016-05-31 
09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/src/ruby/yast/logger.rb      2016-06-30 
14:15:47.000000000 +0200
@@ -34,8 +34,8 @@
 
     res = Builtins.sformat(*safe_args)
     res.gsub!(/%/, "%%") # reescape all %
-    caller[caller_frame] =~ /(.+):(\d+):in `([^']+)'/
-    y2_logger(level, "Ruby", Regexp.last_match(1), Regexp.last_match(2).to_i, 
Regexp.last_match(3), res)
+    matches = caller(caller_frame + 1, 1).first.match(/(.+):(\d+):in 
`([^']+)'/)
+    y2_logger(level, "Ruby", matches[1], matches[2].to_i, matches[3], res)
 
     return unless backtrace
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.48/src/ruby/yast/profiler.rb 
new/yast2-ruby-bindings-3.1.50/src/ruby/yast/profiler.rb
--- old/yast2-ruby-bindings-3.1.48/src/ruby/yast/profiler.rb    1970-01-01 
01:00:00.000000000 +0100
+++ new/yast2-ruby-bindings-3.1.50/src/ruby/yast/profiler.rb    2016-06-30 
14:15:47.000000000 +0200
@@ -0,0 +1,72 @@
+
+require "yast"
+
+module Yast
+  class Profiler
+    class << self
+      include Yast::Logger
+
+      RESULT_PATH = "/var/log/YaST2/profiler_result.txt"
+
+      # Start the Ruby Profiler. It start profilling. It also disables ruby VM
+      # optimizations, so code execution will be slower.
+      def start
+        raise "multiple profiller start detected" if @started
+        @original_compile_options = RubyVM::InstructionSequence.compile_option
+        @started = true
+        require "profiler"
+
+        # turn on tracing and turn off specialized instruction which replace
+        # some core ruby methods with its optimized variant to get complete
+        # profiling. More info in book "Ruby Under a Microscope: Learning Ruby
+        # Internals Through Experiment". Code is taken from ruby/lib/profile.rb
+        RubyVM::InstructionSequence.compile_option = {
+          trace_instruction:       true,
+          specialized_instruction: false
+        }
+
+        at_exit { stop }
+        Profiler__.start_profile
+      end
+
+      # Stops profiling
+      # @param output [IO] an IO stream to print the profile to; if nil, uses 
a file at RESULT_PATH
+      def stop(output = nil)
+        return File.open(RESULT_PATH, "w") { |f| stop(f) } unless output
+
+        Profiler__.print_profile(output)
+
+        RubyVM::InstructionSequence.compile_option = @original_compile_options
+        @started = false
+      end
+
+      # start the Ruby profiler if "Y2PROFILER" environment
+      # variable is set to "1" or "true"(the test is case
+      # insensitive, "y2profiler" variable can be also used)
+      def start_from_env
+        # do not evaluate again for each client started, run the evaluation 
only once
+        return if @profiler_handled
+        @profiler_handled = true
+
+        return unless env_value
+
+        log.info "profiler enabled"
+        start
+      end
+
+    private
+
+      # read the Y2PROFILER environment variable,
+      # do case insensitive match
+      # @return [Boolean] true if enabled
+      def env_value
+        # sort the keys to have a deterministic behavior and to prefer 
Y2PROFILER
+        # over the other variants, then do a case insensitive search
+        key = ENV.keys.sort.find { |k| k.match(/\AY2PROFILER\z/i) }
+        return false unless key
+
+        "1" == ENV[key]
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.48/src/ruby/yast/scr.rb 
new/yast2-ruby-bindings-3.1.50/src/ruby/yast/scr.rb
--- old/yast2-ruby-bindings-3.1.48/src/ruby/yast/scr.rb 2016-05-31 
09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/src/ruby/yast/scr.rb 2016-06-30 
14:15:47.000000000 +0200
@@ -107,9 +107,9 @@
 
     # @private wrapper to C bindings
     def self.call_builtin_wrapper(*args)
-      # caller[0] is one of the functions above
-      caller[1].match BACKTRACE_REGEXP
-      call_builtin(Regexp.last_match(1), Regexp.last_match(2).to_i, *args)
+      # caller(1) is one of the functions above
+      res = caller(2, 1).first.match(BACKTRACE_REGEXP)
+      call_builtin(res[1], res[2].to_i, *args)
     end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.48/src/ruby/yast/wfm.rb 
new/yast2-ruby-bindings-3.1.50/src/ruby/yast/wfm.rb
--- old/yast2-ruby-bindings-3.1.48/src/ruby/yast/wfm.rb 2016-05-31 
09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/src/ruby/yast/wfm.rb 2016-06-30 
14:15:47.000000000 +0200
@@ -2,6 +2,7 @@
 require "yast/builtins"
 require "yast/ops"
 require "yast/debugger"
+require "yast/profiler"
 
 # @private we need it as clients is called in global contenxt
 GLOBAL_WFM_CONTEXT = proc {}
@@ -179,9 +180,9 @@
 
     # @private wrapper to C code
     def self.call_builtin_wrapper(*args)
-      # caller[0] is one of the functions above
-      caller[1].match BACKTRACE_REGEXP
-      call_builtin(Regexp.last_match(1), Regexp.last_match(2).to_i, *args)
+      # caller(1) is one of the functions above
+      res = caller(2, 1).first.match(BACKTRACE_REGEXP)
+      call_builtin(res[1], res[2].to_i, *args)
     end
 
     def self.ask_to_run_debugger?
@@ -204,6 +205,7 @@
       code = File.read client
       begin
         Debugger.start_from_env
+        Profiler.start_from_env
         result = eval(code, GLOBAL_WFM_CONTEXT.binding, client)
 
         allowed_types = Ops::TYPES_MAP.values.flatten
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-ruby-bindings-3.1.48/src/ruby/yast/yast.rb 
new/yast2-ruby-bindings-3.1.50/src/ruby/yast/yast.rb
--- old/yast2-ruby-bindings-3.1.48/src/ruby/yast/yast.rb        2016-05-31 
09:44:05.000000000 +0200
+++ new/yast2-ruby-bindings-3.1.50/src/ruby/yast/yast.rb        2016-06-30 
14:15:47.000000000 +0200
@@ -183,7 +183,7 @@
       if (stype == :function)
         m.module_eval <<-"END"
           def self.#{sname}(*args)
-            caller[0].match BACKTRACE_REGEXP
+            caller(1,1).first.match BACKTRACE_REGEXP
             return Yast::call_yast_function("#{mname}", :#{sname}, $1, 
$2.to_i, *args)
           end
         END


Reply via email to