Skip to content

Instantly share code, notes, and snippets.

View headius's full-sized avatar

Charles Oliver Nutter headius

View GitHub Profile
`curl -OL https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.3.3.0/jruby-dist-9.3.3.0-bin.tar.gz` unless File.exist?('jruby-dist-9.3.3.0-bin.tar.gz')
`tar -zxf jruby-dist-9.3.3.0-bin.tar.gz` unless Dir.exist?('jruby-9.3.3.0')
`curl -OL https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz` unless File.exist?('graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz')
`tar -zxf graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz` unless Dir.exist?('graalvm-ce-java17-22.0.0.2')
`gem install seafoam`
IO.popen({'JAVA_HOME' => 'graalvm-ce-java17-22.0.0.2/Contents/Home'}, ['jruby-9.3.3.0/bin/jruby', '-J-XX:CompileOnly=DashE::RUBY$method$foo$1', '-J-XX:+PrintCompilation', '-J-Dgraal.Dump=', '-e', 'def foo(a, b); a + b; end; loop { foo(rand(100), rand(100)) }']) do |pipe|
puts 'Running...'
@mtortonesi
mtortonesi / profile_all.sh
Created June 19, 2020 20:41
Profiling script for sisfc
#!/bin/sh
TIME_BASED_ID=$(date +%Y%m%d%H%M%S)
rbenv local jruby-9.2.11.1
export JRUBY_OPTS="-Xcompile.invokedynamic=true"
time bundle exec ./bin/sisfc examples/simulator.conf examples/vm_allocation.conf 2>&1 | tee log_sisfc_jruby_${TIME_BASED_ID}.txt
rbenv local 2.7.1
time bundle exec ./bin/sisfc examples/simulator.conf examples/vm_allocation.conf 2>&1 | tee log_sisfc_mri_${TIME_BASED_ID}.txt

The problem:

For an HTTP 1.1 request. JRuby's packet sequence goes like this:

  1. The request is sent from the client
  2. The server sends a packet back with the 200 OK, headers, and ack of the request
  3. The client sends an ack of the headers
  4. The server sends the body of the request

On Linux with delayed ACK, there's around 0.04 seconds between (2) and (3), which drastically reduces throughput.

#!/usr/bin/env jruby
require 'rubygems'
require 'fileutils'
require 'optparse'
ENV['RAILS_ENV'] = "development"
launcher, options = "jruby", ""
OptionParser.new do |opt|
opt.banner = "Usage: runner [OPTIONS]"
@nateberkopec
nateberkopec / gist:11dbcf0ee7f2c08450ea
Last active March 24, 2023 21:59
RubySpec is dead, long live RubySpec!

Last night, Brian Shirai unilaterally "ended" the RubySpec project, a sub-project of Rubinius (the alternative Ruby implementation which Brian was paid to work on full-time from 2007 to 2013). The blog post describing his reasons for "ending" the project led to a big discussion on Hacker News.

When a single, competing Ruby implementation tells that you its test suite is the One True Way, you should be skeptical. Charles Nutter, Ruby core committer and JRuby head honcho, spent a lot of time last night on Twitter talking to people about what this decision means. He's probably too busy and certainly too nice of a guy to write about what is a political issue in the Ruby community, so I'm going to do it on behalf of all the new or intermediate Rubyists out there that are confused by Brian's decision and what it me

[subbu@earth ir] cat !$
cat ~/bin/runspecs
#!/bin/sh
if [ $1 ]
then
echo "Running all specs with passes $1"
jruby -J-ea -X-CIR -Xir.passes=$1 -J-Djruby.launch.inproc=true -S spec/mspec/bin/mspec ci -B spec/jruby.1.9.spec -V -T -J-Djruby.compile.mode=OFFIR -T -J-Djruby.ir.passes=$1
else
echo "Running all specs with default passes"
@headius
headius / ffi-jep.md
Last active January 26, 2016 00:57
JDK Enhancement Proposal: FFI

Title: Foreign Function Interface Author: Charles Oliver Nutter Organization: Red Hat Owner: Charles Oliver Nutter Created: 2014/01/28 Type: Feature State: Draft Exposure: Open Component: --/-- Scope: JDK

@headius
headius / fiber_fix.rb
Created November 1, 2011 17:59
Workaround for broken 'fiber' library load on 1.6.5
# I merged across a change in the package name for FiberExtLibrary but did
# not merge across a subsequent change to load the library from that package.
# The following change loads the extension associated with the 'fiber'
# library directly.
# If you are using the 'fiber' library, rescue that require with this code.
# My apologies on such a stupid regression :)
require 'jruby'
@headius
headius / gist:1234935
Created September 22, 2011 14:38
OS X 'pickjdk' command with single-command selection and updated JDK location
#!/bin/bash
#
# Provides a function that allows you to choose a JDK. Just set the environment
# variable JDKS_ROOT to the directory containing multiple versions of the JDK
# and the function will prompt you to select one. JAVA_HOME and PATH will be cleaned
# up and set appropriately.
_macosx()
{
if [ $(uname -s) = Darwin ]; then
@headius
headius / build.sh
Created August 16, 2011 02:27
Building the Hotspot compiler team's Hotspot branch alone
#!/bin/sh
# This script is for building the hsx/hotspot-comp branch in isolation.
#
# Prerequisites:
# * appropriate build tools
# * a working Sun Java 6 build (i.e. JDK6) is available at:
# HOME/java/re/j2se/1.6.0/latest/binaries/linux-[i586/amd64]
# * a working Sun Java 7 build (i.e. JDK7) is available at:
# HOME/java/re/j2se/1.7.0/latest/binaries/linux-[i586/amd64]
# HOME/java/re/j2se/1.7.0/promoted/latest/binaries/linux-[i586/amd64]