Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bbrowning's full-sized avatar

Ben Browning bbrowning

  • Red Hat
  • Ashburn, VA
View GitHub Profile
@bbrowning
bbrowning / json_contention.rb
Created December 16, 2014 15:09
Simple script to demonstrate the json gem's multithreaded contention problem.
require 'benchmark'
require 'json/ext'
NUM_THREADS = 40
NUM_PARSES = 20_000
def run_test(json)
puts Benchmark.measure {
threads = NUM_THREADS.times.map do
Thread.new do
@bbrowning
bbrowning / json_contention.rb
Created December 16, 2014 15:08
Simple script to demonstrate the json gem's multithreaded contention problem.
require 'benchmark'
require 'json/ext'
NUM_THREADS = 40
NUM_PARSES = 20_000
def run_test(json)
puts Benchmark.measure {
threads = NUM_THREADS.times.map do
Thread.new do
I've added more comments to this code to make it more clear what
everything does.
ActiveSupport::Testing::Isolation runs its tests in parallel, and
JRuby has real multithreading. So, what happens under JRuby is
the first test executes, sets the environment variables, and
spawns a child process. In parallel, a second test executes, sets
the environment variables to different values, and spawns another
child process. It's this setting of environment variables that is
a problem - the second test is being run in parallel and sets the
@bbrowning
bbrowning / README
Last active August 29, 2015 14:00
Simple comparison of vanilla Rails app on TorqueBox vs Trinidad
This is in reference to https://plus.google.com/105596541985629444566/posts/27y819XoT2V
to show simple steps I took to try and reproduce the described issue based upon the
information available. This is very simple benchmarking with an almost vanilla Rails 4
application using sqlite as the database so is not useful other than to demonstrate the
out of the box performance with TorqueBox and Trinidad under these situations is very
close.
diff --git a/servlet/src/test/java/io/undertow/servlet/test/streams/ServletInputStreamTestCase.java b/servlet/src/test/java/io/undertow/servlet/test/streams/ServletInputStreamTestCase.java
index fb00498..d423189 100644
--- a/servlet/src/test/java/io/undertow/servlet/test/streams/ServletInputStreamTestCase.java
+++ b/servlet/src/test/java/io/undertow/servlet/test/streams/ServletInputStreamTestCase.java
@@ -95,6 +95,16 @@ public class ServletInputStreamTestCase {
//}
}
+ @Test
+ public void testAsyncServletInputStreamWithEmptyRequestBody() {
diff --git a/core/src/main/java/io/undertow/conduits/ChunkedStreamSinkConduit.java b/core/src/main/java/io/undertow/conduits/ChunkedStreamSinkConduit.java
index 1e70155..b5fb6b4 100644
--- a/core/src/main/java/io/undertow/conduits/ChunkedStreamSinkConduit.java
+++ b/core/src/main/java/io/undertow/conduits/ChunkedStreamSinkConduit.java
@@ -82,7 +82,8 @@ public class ChunkedStreamSinkConduit extends AbstractStreamSinkConduit<StreamSi
private int state;
private int chunkleft = 0;
- private final ByteBuffer chunkingBuffer = ByteBuffer.allocate(14); //14 is the most
+ private final ByteBuffer chunkingBuffer = ByteBuffer.allocate(12); //12 is the most
@bbrowning
bbrowning / jubilee
Created January 3, 2014 19:18
jubilee vs torqbox performance on techempower json benchmark after warmup period
# Jubille started with:
# jubilee -p 8080 -e production
#
# Note that the Jubilee console outputs quite a few errors like below during
# the test:
#
# Jan 03, 2014 2:15:31 PM org.vertx.java.core.logging.impl.JULLogDelegate error
# SEVERE: Unhandled exception
# java.nio.channels.ClosedChannelException
@bbrowning
bbrowning / config.ru
Created November 8, 2013 21:49
Poor Puma performance with keepalives enabled on JRuby. For both 'ab' runs, Puma was warmed up before running the actual test shown.
run lambda { |env|
[200, { 'Content-Type' => 'text/plain' }, ["hello world\n"]]
}
source 'https://rubygems.org'
gem 'jruby-openssl', '0.9.3'
@bbrowning
bbrowning / instructions.md
Last active December 20, 2015 23:49
OpenShift pre_build hook to allow Windows developers to deploy to OpenShift
  1. Make sure your Gemfile.lock is not committed to your OpenShift git repository.

  2. Copy the pre_build file to .openshift/action_hooks/pre_build

  3. Add .openshift/action_hooks/pre_build to git, set the executable bit, and push your changes

    git add .openshift/action_hooks/pre_build git update-index --chmod=+x .openshift/action_hooks/pre_build git commit -m "Add bundle_install in pre_build hook" git push