... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
| Thank you for extending an invitation to speak at HighLoad++. I | |
| sincerely appreciate your consideration. | |
| I am an outspoken advocate for LGBTQ equality; this position is deeply | |
| woven into my work. Clojure From The Ground Up is adamantly | |
| LGBT-inclusive. Jepsen is named after a gay pop anthem and includes | |
| dozens of references to same-sex relationships and trans identities. My | |
| talk slides are populated with bearded nuns, genderqueer punks, and | |
| trans hackers. My twitter feed is about as gay as it is possible to get. |
... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
| # Summary: In MRI 1.9, if you keep threads in an array in a local variable, the threads may outlive the local variable. | |
| # I have not yet been able to produce a scenario in which the threads are ever garbage-collected. | |
| # You have to remove the thread from the array before it goes out of scope, e.g. using #pop or #clear. | |
| # INPUT DESIRED: If anyone can demonstrate a condition in which a local array keeps threads and those threads are eventually GC'd. | |
| # INPUT DESIRED: Is this expected behavior or a bug? | |
| # NOTE: This test will not work as expected in JRuby, because its garbage collection works differently. Whether the same behavior exists in JRuby is an exercise for someone smarter than I am. | |
| class Foo | |
| THREAD_PROC = lambda{ (0..10).to_a.map do Foo.new end } |
| # It appears that when I perform a query with AR via multiple threads, | |
| # the instantiated objects do not get released when a GC is performed. | |
| threads = Array.new(5) { Thread.new { Foo.where(:status => 2).all.first(100).each { |f| f.owner.first_name } } } | |
| threads.each(&:join) | |
| threads = nil | |
| GC.start | |
| ObjectSpace.each_object(Foo).count # => instances still exist |
| # This makefile will let the Android NDK build a | |
| # libchipmunk.so to go with your 2D Android game. | |
| # download the Chipmunk sources and do | |
| # $ cd <chipmunk-physics> | |
| # $ git checkout Chipmunk-6.0.3 # if you downloaded from source | |
| # $ mkdir -p modules/chipmunk && cd modules/chipmunk | |
| # $ cat >Android.mk <<EOF | |
| LOCAL_HOME := $(dir $(lastword $(MAKEFILE_LIST))) |