diff --git a/.ruby-version b/.ruby-version index 72b3400..89104b5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-3.2.1 +ruby-3.3.0-rc1 diff --git a/Gemfile b/Gemfile index aa61588..e5f7fc3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -ruby "3.2.1" +ruby "3.3.0.rc1" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem "rails", "~> 7.1.2" @@ -8,9 +8,6 @@ gem "rails", "~> 7.1.2" # The modern asset pipeline for Rails [https://github.com/rails/propshaft] gem "propshaft" -# Use sqlite3 as the database for Active Record -gem "sqlite3", "~> 1.4" - # Use the Puma web server [https://github.com/puma/puma] gem "puma", ">= 5.0" @@ -44,6 +41,11 @@ gem "bootsnap", require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" +# SQLite +gem "activerecord-enhancedsqlite3-adapter", git: "https://github.com/dbackeus/activerecord-enhancedsqlite3-adapter.git", branch: "extralite" +gem "sqlite3" +gem "extralite" + group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri windows ] diff --git a/Gemfile.lock b/Gemfile.lock index c50b23c..4f5c546 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,12 @@ +GIT + remote: https://github.com/dbackeus/activerecord-enhancedsqlite3-adapter.git + revision: 77b3d6b4d55b553d9cf681e7605144ee585f66ac + branch: extralite + specs: + activerecord-enhancedsqlite3-adapter (0.4.0) + activerecord (>= 7.1) + sqlite3 (~> 1.6) + GEM remote: https://rubygems.org/ specs: @@ -75,10 +84,10 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) - addressable (2.8.5) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) base64 (0.2.0) - bigdecimal (3.1.4) + bigdecimal (3.1.5) bindex (0.8.1) bootsnap (1.17.0) msgpack (~> 1.2) @@ -99,20 +108,21 @@ GEM cssbundling-rails (1.3.3) railties (>= 6.0.0) date (3.3.4) - debug (1.8.0) - irb (>= 1.5.0) - reline (>= 0.3.1) + debug (1.9.0) + irb (~> 1.10) + reline (>= 0.3.8) drb (2.2.0) ruby2_keywords erubi (1.12.0) + extralite (2.3) faker (3.2.2) i18n (>= 1.8.11, < 2) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.1) concurrent-ruby (~> 1.0) - io-console (0.6.0) - irb (1.10.1) + io-console (0.7.1) + irb (1.11.0) rdoc reline (>= 0.3.8) jsbundling-rails (1.2.1) @@ -128,10 +138,11 @@ GEM marcel (1.0.2) matrix (0.4.2) mini_mime (1.1.5) + mini_portile2 (2.8.5) minitest (5.20.0) msgpack (1.7.2) mutex_m (0.2.0) - net-imap (0.4.7) + net-imap (0.4.8) date net-protocol net-pop (0.1.2) @@ -141,11 +152,8 @@ GEM net-smtp (0.4.0) net-protocol nio4r (2.7.0) - nokogiri (1.15.5-aarch64-linux) - racc (~> 1.4) - nokogiri (1.15.5-arm64-darwin) - racc (~> 1.4) - nokogiri (1.15.5-x86_64-linux) + nokogiri (1.15.5) + mini_portile2 (~> 2.8.2) racc (~> 1.4) pg (1.5.4) propshaft (0.8.0) @@ -153,7 +161,7 @@ GEM activesupport (>= 7.0.0) rack railties (>= 7.0.0) - psych (5.1.1.1) + psych (5.1.2) stringio public_suffix (5.0.4) puma (6.4.0) @@ -197,11 +205,11 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rake (13.1.0) - rdoc (6.6.1) + rdoc (6.6.2) psych (>= 4.0.0) redis (5.0.8) redis-client (>= 0.17.0) - redis-client (0.18.0) + redis-client (0.19.0) connection_pool regexp_parser (2.8.3) reline (0.4.1) @@ -213,12 +221,11 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - sqlite3 (1.6.9-aarch64-linux) - sqlite3 (1.6.9-arm64-darwin) - sqlite3 (1.6.9-x86_64-linux) + sqlite3 (1.6.9) + mini_portile2 (~> 2.8.0) stimulus-rails (1.3.0) railties (>= 6.0.0) - stringio (3.1.0) + stringio (3.1.1) thor (1.3.0) timeout (0.4.1) turbo-rails (1.5.0) @@ -244,14 +251,17 @@ GEM PLATFORMS aarch64-linux arm64-darwin-21 + arm64-darwin-23 x86_64-linux DEPENDENCIES + activerecord-enhancedsqlite3-adapter! bootsnap browser (~> 5.3) capybara cssbundling-rails debug + extralite faker (~> 3.2) jsbundling-rails pg (~> 1.5) @@ -260,14 +270,14 @@ DEPENDENCIES rails (~> 7.1.2) redis (>= 4.0.1) selenium-webdriver - sqlite3 (~> 1.4) + sqlite3 stimulus-rails turbo-rails tzinfo-data web-console RUBY VERSION - ruby 3.2.1p31 + ruby 3.3.0.rc1 BUNDLED WITH 2.4.19 diff --git a/app/controllers/benchmarking_controller.rb b/app/controllers/benchmarking_controller.rb index 2f6d006..7e6e6e4 100644 --- a/app/controllers/benchmarking_controller.rb +++ b/app/controllers/benchmarking_controller.rb @@ -1,8 +1,7 @@ class BenchmarkingController < ApplicationController - skip_before_action :verify_authenticity_token before_action :set_user_update_last_seen_at - # POST /benchmarking/read_heavy + # GET /benchmarking/read_heavy def read_heavy act_and_respond( post_create: 0.10, @@ -15,7 +14,7 @@ def read_heavy ) end - # POST /benchmarking/write_heavy + # GET /benchmarking/write_heavy def write_heavy act_and_respond( post_create: 0.25, @@ -28,7 +27,7 @@ def write_heavy ) end - # POST /benchmarking/balanced + # GET /benchmarking/balanced def balanced act_and_respond( post_create: 0.17, @@ -41,6 +40,25 @@ def balanced ) end + # GET /benchmarking/long_running + def long_running + ActiveRecord::Base.connection_pool.with_connection do |conn| + # Since SQLite doesn't have a sleep function, we'll use a recursive CTE + # which takes approximately 1 second to execute. + conn.raw_connection.execute <<~SQL + WITH RECURSIVE r(i) AS ( + VALUES(0) + UNION ALL + SELECT i FROM r + LIMIT 10000000 + ) + SELECT i FROM r WHERE i = 1; + SQL + end + + head :ok + end + private def set_user_update_last_seen_at @@ -89,7 +107,7 @@ def act_and_respond(actions_with_weighted_distribution) head :created when :comment_create head :created - when :comment_destroy + when :comment_destroy, :post_destroy head :no_content when :post_show render "posts/show", status: :ok diff --git a/config/database.yml b/config/database.yml index 796466b..03bf2aa 100644 --- a/config/database.yml +++ b/config/database.yml @@ -8,6 +8,8 @@ default: &default adapter: sqlite3 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> timeout: 5000 + client: <%= ENV["DB_CLIENT"] %> + strict: false development: <<: *default diff --git a/config/environments/production.rb b/config/environments/production.rb index d9541af..1c3bd2b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -88,4 +88,6 @@ # ] # Skip DNS rebinding protection for the default health check endpoint. # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } + + config.active_record.sqlite3_production_warning = false end diff --git a/config/routes.rb b/config/routes.rb index d7628a4..43c5a87 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,9 +19,10 @@ # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check - post "benchmarking/read_heavy" => "benchmarking#read_heavy" - post "benchmarking/write_heavy" => "benchmarking#write_heavy" - post "benchmarking/balanced" => "benchmarking#balanced" + get "benchmarking/read_heavy" + get "benchmarking/write_heavy" + get "benchmarking/balanced" + get "benchmarking/long_running" # Defines the root path route ("/") root to: "posts#index"