... HUGE release in terms of (compatibility and some performance) fixes
... invokedynamic disabled by default on Java 7 (otherwise -Xcompile.invokedynamics=false)
| require 'logger' | |
| Class.new do | |
| LOGGER = Logger.new(STDOUT) | |
| # Logger.new File.open('jmx.log', File::WRONLY | File::APPEND) | |
| def initialize; @done = nil end | |
| def start |
| if JRUBY_VERSION < '1.7.19' | |
| require 'thread'; require 'java' | |
| org.jruby.RubyThreadGroup.field_reader :rubyThreadList | |
| ThreadGroup.class_eval do | |
| def list | |
| threads = [] | |
| list = to_java.rubyThreadList | |
| list.synchronized do # iterator must be sync-ed | |
| list.each { |t| threads << t if t } | |
| end |
| # Copyright 2012-2013 Barry Allard <[email protected]> | |
| # All rights reserved. | |
| # | |
| # Redistribution and use in source and binary forms, with or without modification, | |
| # are permitted provided that the following conditions are met: | |
| # | |
| # 1. Redistributions of source code must retain the above copyright notice, this | |
| # list of conditions and the following disclaimer. | |
| # | |
| # 2. Redistributions in binary form must reproduce the above copyright notice, |
| require 'jruby' | |
| class CurrentThreadAwareFormatter < Logger::Formatter | |
| FORMAT = "%s [%5s] {%s} -- %s\n".freeze | |
| def call(severity, time, progname, msg) | |
| thread = Thread.current | |
| thread_id = JRuby.reference(thread).getNativeThread.to_s | |
| thread_id << ' ' << ( thread[:name] || thread.to_s ) | |
| FORMAT % [format_datetime(time), severity, thread_id, msg2str(msg)] | |
| end | |
| end |
| ::ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do | |
| def release_connection(with_id = current_connection_id) | |
| #synchronize do | |
| conn = @reserved_connections.delete(with_id) | |
| checkin conn, true if conn | |
| #end | |
| end | |
| def checkin(conn, on_release = nil) |
| require 'celluloid/internal_pool' | |
| # NOTE: this also avoids JRuby bug with ThreadGroup#list ! | |
| # require 'celluloid' likely happened already : | |
| if Celluloid.internal_pool | |
| Celluloid.internal_pool.shutdown | |
| Celluloid.internal_pool = nil | |
| end |
| require 'logging' | |
| module Logging | |
| # require 'logging/repository' | |
| # class Repository | |
| # # include Singleton | |
| # | |
| # def initialize; require 'thread_safe' | |
| # # @h = {:root => ::Logging::RootLogger.new} | |
| # @h = ThreadSafe::Cache.new |
| require 'celluloid/stack_dump' | |
| module Celluloid | |
| class StackDump | |
| class ActorState | |
| attr_accessor :thread_name, :thread_id | |
| def dump |
| require 'benchmark' | |
| TIMES = 10_000 | |
| Benchmark.bmbm do |x| | |
| x.report("java.lang.System.get_property [#{TIMES}x]") do | |
| TIMES.times do | |
| java.lang.System.get_property('jars.skip') == 'true' | |
| end |
... HUGE release in terms of (compatibility and some performance) fixes
... invokedynamic disabled by default on Java 7 (otherwise -Xcompile.invokedynamics=false)