Skip to content

Instantly share code, notes, and snippets.

View mintuhouse's full-sized avatar
👋

Hasan Kumar mintuhouse

👋
View GitHub Profile
@mintuhouse
mintuhouse / 1-README.md
Last active November 10, 2021 20:03
Benchmark to see if ruby IO follows amdahl's law with s=num_of_threads

While going through https://www.speedshop.co/2020/05/11/the-ruby-gvl-and-scaling.html, I read

Amdahl's Law is simply 1 / (1 - p + p/s), where p is the percentage of the task that could be done in parallel, and s is the speedup factor from the part of the task that gained improved resources (the parallel part).

So, in our example, let's say that half of SatelliteDataProcessorJob is GVL-bound and half is IO-bound. In this case, p is 0.5 and s is 10, because we can wait for IO in parallel and there are 10 threads. In this case, Amdahl's Law shows that a Sidekiq process would go through our jobs up to 1.81x faster than a single-threaded Resque or DelayedJob process.

Question: In this case, shouldn’t speed up be 2x as IO-bound portion takes practically zero CPU time rather than p/s i.e., s = ♾️. Wondering what I am missing here? 🤔

// ==UserScript==
// @name GitHub PR Add Merge Description
// @version 1.0.0
// @description A userscript that adds merge commit description
// @license MIT
// @author Hasan Kumar
// @namespace https://github.com/mintuhouse
// @include https://github.com/*
// @run-at document-idle
// @grant none
@mintuhouse
mintuhouse / config_inititializers_ckeditor.rb
Created April 16, 2014 20:00
Ckeditor Custom Authorization Hook
Ckeditor.setup do |config|
config.current_user_method do
current_user
end
config.authorize_with :chronus
end
@mintuhouse
mintuhouse / net_ldap_overrides.rb
Created April 2, 2014 10:51
Verify the certificate of secure LDAP server using net-ldap ruby gem
class Net::LDAP
def initialize(args = {})
@host = args[:host] || DefaultHost
@port = args[:port] || DefaultPort
@verbose = false # Make this configurable with a switch on the class.
@auth = args[:auth] || DefaultAuth
@base = args[:base] || DefaultTreebase
encryption args[:encryption] # may be nil