Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Browning bbrowning

  • Red Hat
  • Brevard, NC
View GitHub Profile
View ChunkedStreamSinkConduit.diff
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
View ServletInputStreamTestCase.diff
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() {
@bbrowning
bbrowning / README
Last active Aug 29, 2015
Simple comparison of vanilla Rails app on TorqueBox vs Trinidad
View README
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.
View explanation
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 / json_contention.rb
Created Dec 16, 2014
Simple script to demonstrate the json gem's multithreaded contention problem.
View json_contention.rb
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 Dec 16, 2014
Simple script to demonstrate the json gem's multithreaded contention problem.
View json_contention.rb
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 / output.txt
Last active Aug 29, 2015
RubyGems 2.4.5 triggers JRuby logic error when loading Java extensions from absolute paths
View output.txt
$ bin/jruby -S gem install atomic
Fetching: atomic-1.1.16-java.gem (100%)
Successfully installed atomic-1.1.16-java
1 gem installed
$ bin/jruby ~/tmp/rubygems_java_ext_broken.rb
absolute paths are broken
relative paths work
@bbrowning
bbrowning / double_load.rb
Created Jan 23, 2015
JRuby 9k double loading file if explicit require and autoload are used
View double_load.rb
autoload :ProxyObject, 'proxy_object.rb'
require 'proxy_object'
@bbrowning
bbrowning / indexed_queue.diff
Created May 18, 2015
These are benchmark results of an implementation of async.queue based on maintaining an index into the queue as items are processed instead of shifting items off the queue. The new implementation is shown as "indexed async.queue" in the benchmark results, with the old one shown as "upstream async.queue". For larger queues, the performance differ…
View indexed_queue.diff
diff --git a/lib/async.js b/lib/async.js
index 394c41c..8d91ab5 100644
--- a/lib/async.js
+++ b/lib/async.js
@@ -832,6 +832,120 @@
return q;
};
+ async.indexedQueue = function (worker, concurrency) {
+ if (concurrency === undefined) {
View jruby_selector_leak.rb
num_runtimes = 10
puts "Creating runtimes..."
num_runtimes.times do
instance = org.jruby.Ruby.newInstance
instance.evalScriptlet <<-EOS
require "socket"
server = TCPServer.new(0)
Thread.new do
begin