Skip to content

Instantly share code, notes, and snippets.

@enebo
enebo / a.txt
Created January 28, 2020 21:47
sh -x ./test.sh
+ MAKE_ARCHIVE=-J-XX:ArchiveClassesAtExit=ir.jsa
+ READ_ARCHIVE=-J-XX:SharedArchiveFile=ir.jsa
+ CACHE=-Xcompile.cache.classes=true
+ DONT_CACHE=-Xcompile.cache.classes=true
+ DEV=--dev
+ COMPILE=-X+C
+ GC=-J-XX:+UseParallelGC
+ TIME=15
+ java -version
system ~/work/jruby/frogger master # 1048% time echo exit | CLASSPATH=/home/enebo/.ir JRUBY_OPTS="-d -Xcompile.cache.classes=true --dev -J-XX:+UseParallelGC" jruby -S rails c
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
/home/enebo/work/jruby/lib/ruby/stdlib/rubygems/text.rb:2: warning: loading in progress, circular require considered harmful - /home/enebo/work/jruby/lib/ruby/stdlib/rubygems.rb require at org/jruby/RubyKernel.java:974
<main> at /home/enebo/work/jruby/lib/ruby/stdlib/rubygems/text.rb:2
require at org/jruby/RubyKernel.java:974
<main> at /home/enebo/work/jruby/lib/ruby/stdlib/rubygems/user_interaction.rb:10
require at org/jruby/RubyKernel.java:974
<main> at /home/enebo/work/jruby/lib/ruby/stdlib/rubygems/config_file.rb:8
<main> at /home/enebo/work/jruby/lib/ruby/stdlib/rubygems/defaults/jruby_native.rb:1
require at org/jruby/RubyKernel.java:974

Note: I ran each of the timed runs multiple times but picked the lowest number of each

Only first rails spawn -X+C

Generate ~/.ir fresh:

time echo exit | CLASSPATH=/home/enebo/.ir JRUBY_OPTS="-Xcompile.cache.classes=true -J-XX:+UseParallelGC" jruby -X+C -S rails c
system ~/Applications/jdks 908% cd ~/work/jruby/frogger/
system ~/work/jruby/frogger master # 909% java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
system ~/work/jruby/frogger master # 910% time echo exit | CLASSPATH=/home/enebo/.ir JRUBY_OPTS="-Xcompile.cache.classes --dev -J-XX:+UseParallelGC" jruby --dev -S rails c >/dev/null 2>&1
real 0m10.769s
user 0m14.634s
sys 0m0.885s
diff --git a/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java b/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
index a00a77e164..74d65ab3fc 100644
--- a/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
+++ b/core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
@@ -100,13 +100,13 @@ public class JVMVisitor extends IRVisitor {
lastLine = -1;
Class result = jrubyClassLoader.defineClass(c(JVM.scriptToClass(file)), code);
- for (Map.Entry<String, StaticScope> entry : staticScopeMap.entrySet()) {
- try {
@enebo
enebo / a.txt
Created January 23, 2020 15:59
system ~/work/jruby jit_irscope_removal 337% jrake test:jruby
mkdir -p test/target/test-classes
/home/enebo/Applications/jdks/jdk1.8.0_172/bin/javac -cp lib/jruby.jar:test/target/junit.jar -d test/target/test-classes spec/java_integration/fixtures/ClassWithMultipleSignaturesWithPrimitiveArgs.java spec/java_integration/fixtures/DescendantOfSingleMethodInterface.java spec/java_integration/fixtures/PackageStaticMethod.java spec/java_integration/fixtures/BooleanReturningInterfaceConsumer.java spec/java_integration/fixtures/ClassWithVarargs.java spec/java_integration/fixtures/MethodNames.java spec/java_integration/fixtures/ArrayReturningInterfaceConsumer.java spec/java_integration/fixtures/GenericComparable.java spec/java_integration/fixtures/ProtectedConstructor.java spec/java_integration/fixtures/PackageField.java spec/java_integration/fixtures/MethodAnnotations.java spec/java_integration/fixtures/JavaIterable.java spec/java_integration/fixtures/ScalaSingleton.java spec/java_integration/fixtures/PublicField.java
class Object
# include the class specified by +include_class+ into the current namespace,
# using either its base name or by using a name returned from an optional block,
# passing all specified classes in turn and providing the block package name
# and base class name.
# @deprecated use {Object#java_import}
def include_class(include_class, &block)
warn "#{__method__} is deprecated. Use java_import."
java_import(include_class, &block)
end
  1. edit similar to: https://gist.github.com/enebo/94d39d94dabcfe9fadbb1aa5ac050528 (appropriate per which db you end up using)
  2. cp config/database.yml.example config/database.yml
  3. edit config/database.yml for db
  4. jruby -S bundle install --without development test rmagick
  5. jruby -S bundler exec rake generate_secret_token
  6. jruby -S bundler exec rake db:migrate RAILS_ENV="production"
  7. RAILS_ENV=production jruby -S rake db:fixtures:load

= Postgres Database Configuration

@enebo
enebo / gsub1.rb
Last active November 7, 2019 19:55
# coding: utf-8
require 'benchmark/ips'
STR1 = 'white chocolate あand white xmas and white bread'
STR2 = 'a1'
STR3 = 'dog'
REGEXP2 = /\d/
REGEXP3 = /\w+/
jruby -Xcompile.invokedynamic -Xjit.threshold=0 -Xjit.logging -Xjit.logging.verbose -e 'def foo; end; foo'
2019-11-01T15:54:39.359-05:00 [main] ERROR Ruby : failed to compile target script: -e
org.jruby.compiler.NotCompilableException: failed to compile script -e
at org.jruby.ir.Compiler.execute(Compiler.java:61)
at org.jruby.ir.Compiler.execute(Compiler.java:30)
at org.jruby.ir.IRTranslator.execute(IRTranslator.java:42)
at org.jruby.Ruby.tryCompile(Ruby.java:838)
at org.jruby.Ruby.precompileCLI(Ruby.java:807)
at org.jruby.Ruby.runNormally(Ruby.java:769)
at org.jruby.Ruby.runNormally(Ruby.java:798)