Skip to content

Instantly share code, notes, and snippets.

View jeremyevans's full-sized avatar

Jeremy Evans jeremyevans

View GitHub Profile
require 'benchmark/ips'
n = (ARGV[0] || 1).to_i
eval <<CODE
def bg
#{'a = block_given?;' * n}
a
end
@jeremyevans
jeremyevans / output.txt
Created July 12, 2021 23:40
Rails PR 34068 benchmarks on Ruby 2.5-3.0
ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-openbsd]
Warming up --------------------------------------
new 164.570k i/100ms
old 139.420k i/100ms
Calculating -------------------------------------
new 3.893M (±13.6%) i/s - 18.926M in 5.039367s
old 2.791M (±15.5%) i/s - 13.384M in 5.038520s
Comparison:
new: 3893319.3 i/s
From 0bc589efb09312e67cd84c600fdd5e7540c04d11 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@jeremyevans.net>
Date: Tue, 22 Jun 2021 11:27:19 -0700
Subject: [PATCH] WIP on internal requests
---
README.rdoc | 2 +
doc/internal_request.rdoc | 144 ++++++++++
lib/rodauth.rb | 64 ++++-
lib/rodauth/features/base.rb | 4 +
DB.extend_datasets do
def literal_append(sql, v)
case v
when Numeric, Date, String
sql << '?'
else
super
end
end
end
diff --git a/lib/sequel/plugins/json_serializer.rb b/lib/sequel/plugins/json_serializer.rb
index 510923dbd..1e62bdc4c 100644
--- a/lib/sequel/plugins/json_serializer.rb
+++ b/lib/sequel/plugins/json_serializer.rb
@@ -133,10 +133,8 @@ module Sequel
end
end
- # Helper class used for making sure that cascading options
- # for model associations works correctly. Cascaded options
diff --git a/vm_method.c b/vm_method.c
index 5637251192..9b34ce17ae 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1769,7 +1769,7 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
* a keyword splat. It marks the method such that if the method is called
* with keyword arguments, the final hash argument is marked with a special
* flag such that if it is the final element of a normal argument splat to
- * another method call, and that method calls does not include explicit
+ * another method call, and that method call does not include explicit
@jeremyevans
jeremyevans / roda-cache-compiled-templates.diff
Created June 14, 2019 23:18
Compiled Templates Support for Roda
From 4b00364417def26dd5aa941dcbd0156bbfc4cdee Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@jeremyevans.net>
Date: Fri, 14 Jun 2019 15:17:51 -0700
Subject: [PATCH] Improve render performance up to 4x in the default case by
calling compiled template methods directly
This takes the UnboundMethods that Tilt prepares for templates,
and defines real methods using them in a module included in the
Roda class (so it works with frozen Roda apps).
@jeremyevans
jeremyevans / explain-10.json
Last active April 4, 2019 06:08
9000x Performance Regression Between PostgreSQL 9.6 and 10
[
{
"Plan": {
"Node Type": "Unique",
"Parallel Aware": false,
"Startup Cost": 1861.16,
"Total Cost": 1893.82,
"Plan Rows": 1,
"Plan Width": 8,
"Actual Startup Time": 304418.234,
gem 'activerecord', '4.0.4'
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
# Let's say you were stupid and used the postgres account for something you
# shouldn't have, so you have a database owned by postgres, with all objects
# inside owned by postgres. You regain sanity and want to transfer the
# ownership to an account that isn't a database superuser.
#
# In most cases, reassigning ownership is as simple as using
# REASSIGNED OWNED. However, that does not work if you are using the
# postgres account, so you have to alter the ownership manually.
#
# First, make sure you connect to the database using the postgres account.