Skip to content

Instantly share code, notes, and snippets.

This is a proof-of-concept of a couple of concurrent data structures written in Ruby.

The implementations are heavily commented for those interested. There are benchmarks (with results) included below. The results are interesting, but, as always, take with a grain of salt.

Data structures

AtomicLinkedQueue is a lock-free queue, built on atomic CAS operations.

class Foo
def self.foo; end
def foo; end
end
tp = TracePoint.new("call") do |trace|
p [trace.defined_class, trace.method_id, trace.event, trace.lineno]
end
tp.enable
TracePoint:
disable 1
enable 1
Object:
require 1983
load_dependency 485
[] 18
hash 15
initialize 6
@andhapp
andhapp / proxy.rb
Created November 24, 2013 23:50 — forked from torsten/proxy.rb
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009 Torsten Becker <torsten.becker@gmail.com>
require 'socket'
require 'uri'
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Server Software: SimpleHTTP/0.6
Server Hostname: 127.0.0.1
Server Port: 5000
class Foo
public def my_public_method
1 + 2
end
protected def my_protected_method
3 + 4
end
private def my_private_method

This is a proof-of-concept of a couple of concurrent data structures written in Ruby.

The implementations are heavily commented for those interested. There are benchmarks (with results) included below. The results are interesting, but, as always, take with a grain of salt.

Data structures

AtomicLinkedQueue is a lock-free queue, built on atomic CAS operations.

module CheapStrings
def `(str)
str
end
end
module A
extend CheapStrings
def self.make_lots_of_strings
#!/usr/bin/env ruby
gem "parser", "~> 1.4"
require "parser"
require "parser/ruby19"
require "set"
class ConstantDeclarationAndUseProcessor < Parser::AST::Processor
attr_reader :declared, :used
def initialize
/*
* more helpful links
* http://www.w3.org/TR/CSS2/generate.html#scope
* http://quirksmode.org/css/css2/counter.html
* http://www.impressivewebs.com/css-counter-increment/
*/
/* decimal counters (basic, default) */