Skip to content

Instantly share code, notes, and snippets.

user system total real
sdk public_url 0.054114 0.000335 0.054449 ( 0.054802)
naive S3 public url 0.004575 0.000009 0.004584 ( 0.004582)
naive S3 public url with URI.escape 0.009892 0.000090 0.009982 ( 0.011209)
sdk presigned_url 0.756642 0.005855 0.762497 ( 0.789622)
re-use instantiated SDK Presigner 0.817595 0.005955 0.823550 ( 0.859270)
use inline instantiated Aws::Sigv4::Signer directly for presigned url (with escaping) 0.216338 0.001941 0.218279 ( 0.226991)
Re-use Aws::Sigv4::Signer for presigned url (with escaping) 0.185855 0.
@jrochkind
jrochkind / url_gen_benchmark.rb
Created August 25, 2020 20:12
Benchmarking different ways of creating presigned S3 URLs
# A local domain ActiveRecord, Asset#file is a shrine attachment
asset = Asset.last
# load outside of benchmarking
asset.file
s3_object = asset.file.storage.object(asset.file.id)
ITERATIONS = (ENV['ITERATIONS'] || "1200").to_i
$stderr.puts "#{ITERATIONS} iterations\n\n"
@jrochkind
jrochkind / s3_public_url_benchmark.rb
Created August 24, 2020 16:22
Comparing S3 public_url generation implementations for performance
# A local domain ActiveRecord, Asset#file is a shrine attachment
asset = Asset.last
asset.file # load outside of benchmarking
s3_object = asset.file.storage.object(asset.file.id) # Aws::S3::Object
require 'erb'
require 'escape_utils'
def naive_public_url(shrine_file)
expected Lu category: 1415
Lt (31)
Dž,Lj,Nj,Dz,ᾈ,ᾉ,ᾊ,ᾋ,ᾌ,ᾍ,ᾎ,ᾏ,ᾘ,ᾙ,ᾚ,ᾛ,ᾜ,ᾝ,ᾞ,ᾟ,ᾨ,ᾩ,ᾪ,ᾫ,ᾬ,ᾭ,ᾮ,ᾯ,ᾼ,ῌ,ῼ
no_categories_found (105)
Ϳ,Ԩ,Ԫ,Ԭ,Ԯ,Ᏽ,Ꚙ,Ꚛ,Ꞗ,Ꞙ,Ꞛ,Ꞝ,Ꞟ,Ɜ,Ɡ,Ɬ,Ʞ,Ʇ,Ʝ,Ꭓ,Ꞵ,Ꞷ,𐲀,𐲁,𐲂,𐲃,𐲄,𐲅,𐲆,𐲇,𐲈,𐲉,𐲊,𐲋,𐲌,𐲍,𐲎,𐲏,𐲐,𐲑,𐲒,𐲓,𐲔,𐲕,𐲖,𐲗,𐲘,𐲙,𐲚,𐲛,𐲜,𐲝,𐲞,𐲟,𐲠,𐲡,𐲢,𐲣,𐲤,𐲥,𐲦,𐲧,𐲨,𐲩,𐲪,𐲫,𐲬,𐲭,𐲮,𐲯,𐲰,𐲱,𐲲,𑢠,𑢡,𑢢,𑢣,𑢤,𑢥,𑢦,𑢧,𑢨,𑢩,𑢪,𑢫,𑢬,𑢭,𑢮,𑢯,𑢰,𑢱,𑢲,𑢳,𑢴,𑢵,𑢶,𑢷,𑢸,𑢹,𑢺,𑢻,𑢼,𑢽,𑢾,𑢿
Lo (85)
require 'twitter_cldr'
chars = "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮİIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŸŹŻŽƁƂƄƆƇƉƊƋƎƏƐƑƓƔƖƗƘƜƝƟƠƢƤƦƧƩƬƮƯƱƲƳƵƷƸƼDŽDžLJLjNJNjǍǏǑǓǕǗǙǛǞǠǢǤǦǨǪǬǮDZDzǴǶǷǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȠȢȤȦȨȪȬȮȰȲȺȻȽȾɁɃɄɅɆɈɊɌɎͰͲͶͿΆΈΉΊΌΎΏΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫϏϒϓϔϘϚϜϞϠϢϤϦϨϪϬϮϴϷϹϺϽϾϿЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҊҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӀӁӃӅӇӉӋӍӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӶӸӺӼӾԀԂԄԆԈԊԌԎԐԒԔԖԘԚԜԞԠԢԤԦԨԪԬԮԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅჇჍᎠᎡᎢᎣᎤᎥᎦᎧᎨᎩᎪᎫᎬᎭᎮᎯᎰᎱᎲᎳᎴᎵᎶᎷᎸᎹᎺᎻᎼᎽᎾᎿᏀᏁᏂᏃᏄᏅᏆᏇᏈᏉᏊᏋᏌᏍᏎᏏᏐᏑᏒᏓᏔᏕᏖᏗᏘᏙᏚᏛᏜᏝᏞᏟᏠᏡᏢᏣᏤᏥᏦᏧᏨᏩᏪᏫᏬᏭᏮᏯᏰᏱᏲᏳᏴᏵḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẞẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸỺỼỾἈἉἊἋἌἍἎἏἘἙἚἛἜἝἨἩἪἫἬἭἮἯἸἹἺἻἼἽἾἿὈὉὊὋὌὍὙὛὝὟὨὩὪὫὬὭὮὯᾈᾉᾊᾋᾌᾍᾎᾏᾘᾙᾚᾛᾜᾝᾞᾟᾨᾩᾪᾫᾬᾭᾮᾯᾸᾹᾺΆᾼῈΈῊΉῌῘῙῚΊῨῩῪΎῬῸΌῺΏῼℂℇℋℌℍℐℑℒℕℙℚℛℜℝℤΩℨKÅℬℭℰℱℲℳℾℿⅅⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮⱠⱢⱣⱤⱧⱩⱫⱭⱮⱯⱰⱲⱵⱾⱿⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢⳫⳭⳲꙀꙂꙄꙆꙈ
RuntimeError: Cannot load `Rails.application.database_configuration`:
Could not load database configuration. No such file - ["config/database.yml"]
/Users/jrochkind/.gem/ruby/2.4.2/gems/railties-5.2.0/lib/rails/application/configuration.rb:185:in `database_configuration'
/Users/jrochkind/.gem/ruby/2.4.2/gems/activerecord-5.2.0/lib/active_record/railtie.rb:133:in `block (2 levels) in <class:Railtie>'
/Users/jrochkind/.gem/ruby/2.4.2/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
/Users/jrochkind/.gem/ruby/2.4.2/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/Users/jrochkind/.gem/ruby/2.4.2/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/Users/jrochkind/.gem/ruby/2.4.2/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/Users/jrochkind/.gem/ruby/2.4.2/gems/activesupport-5.2.0/lib/active_support/lazy_load_hooks.rb:52:in `block in run_loa
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:119 :in `block in check_for_errors`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:117 :in `tap`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:117 :in `check_for_errors`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:53 :in `block in get`
[GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:166 :in `instrument`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:33 :in `get`
[GEM_ROOT]/gems/active-fedora-11.1.6/lib/active_fedora/caching_connection.rb:13 :in `get`
/usr/local/lib/ruby/2.3.0/delegate.rb:83 :in `method_missing`
[GEM_ROOT]/gems/active-fedora-11.1.6/lib/active_fedora/initializing_connection.rb:27 :in `get`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/resource.rb:54 :in `get`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:119 :in `block in check_for_errors`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:117 :in `tap`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:117 :in `check_for_errors`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:25 :in `block in head`
[GEM_ROOT]/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:166 :in `instrument`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/client/methods.rb:17 :in `head`
/usr/local/lib/ruby/2.3.0/delegate.rb:83 :in `method_missing`
[GEM_ROOT]/gems/active-fedora-11.1.6/lib/active_fedora/initializing_connection.rb:22 :in `head`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/resource.rb:59 :in `head`
[GEM_ROOT]/gems/ldp-0.6.4/lib/ldp/resource.rb:42 :in `new?`
{
"Exif": {
"PixelXDimension": 3100,
"DateTimeDigitized": "2014:01:28 10:58:59",
"PixelYDimension": 2488,
"ColorSpace": 65535
},
"Orientation": 1,
"Content-Type": "image/tiff",
"Output": {},
@jrochkind
jrochkind / overview.md
Created July 18, 2017 14:20
profiling slow sufia show page

Sufia 7.3 curation_concerns/base/show.html.erb

We’ve customized this page, but like the original, it lists all members (for the purpose of this profile all filesets), without pagination, with some metadata and hyperlink actions, along with some cancancan guards for some of them. I’m not sure if the original uncustomized would have exactly the same performance characteristics — it’s possible we’ve added more calls to metadata attributes and generation of hyperlinks than the original.

We have already implemented the Solr fetch n+1 workaround. Adapted from https://github.com/pulibrary/plum/blob/master/app/factories/efficient_member_presenter_factory.rb.

This profile is of a sample work with 200 file set members — with each page of a manuscript being a member, we do have works with 200-400+ members in our actual data. This profile was done with production-like config, and after a few requests were made to warm things up.

This profile is not of the whole action/render, but just wrapped around what I ident