{"id":15151482,"url":"https://github.com/juplutonic/profiling-masterclass","last_synced_at":"2026-02-20T16:01:29.621Z","repository":{"id":40007712,"uuid":"406916656","full_name":"JuPlutonic/profiling-masterclass","owner":"JuPlutonic","description":"ruby-prof, stackprof, memory profiling(self-written/derailed_benchmarks/PigCI) +json import +Minitest/Rspec","archived":false,"fork":false,"pushed_at":"2024-07-29T10:20:35.000Z","size":300,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T17:53:58.346Z","etag":null,"topics":["performance","profiling","rails6","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuPlutonic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-15T20:32:40.000Z","updated_at":"2024-07-29T10:20:34.000Z","dependencies_parsed_at":"2025-03-13T04:00:07.607Z","dependency_job_id":null,"html_url":"https://github.com/JuPlutonic/profiling-masterclass","commit_stats":{"total_commits":64,"total_committers":3,"mean_commits":"21.333333333333332","dds":0.34375,"last_synced_commit":"9c23034c57d6df1ecc0cb1c4675dad2700d3b500"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuPlutonic%2Fprofiling-masterclass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuPlutonic%2Fprofiling-masterclass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuPlutonic%2Fprofiling-masterclass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuPlutonic%2Fprofiling-masterclass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuPlutonic","download_url":"https://codeload.github.com/JuPlutonic/profiling-masterclass/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245199132,"owners_count":20576499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["performance","profiling","rails6","ruby"],"created_at":"2024-09-26T15:03:44.252Z","updated_at":"2025-10-21T18:11:03.204Z","avatar_url":"https://github.com/JuPlutonic.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README.md\n\n## This is benchmarking master class\n\n### Benchmark json importing\n\n* minitest based: `rails test`\n\n* rspec based: `rspec -f d -c`\n\n\n## Profiling after program changes\n\n1. on main/master branch update etalon with\n\n`http 'localhost:3000/report?start_date=2015-07-01\u0026finish_date=2021-12-12' \u003e payloads/etalon.html`\n\n2. checkout branch with changes and run `ruby app/lib/profiling.rb` to see if those changes was a source of degradation\n\n### Run `Apache Benchmark`\n\n* find in Linux repositories apache2-utils and install it (on deb-based linux\n`sudo apt install apache2-utils`)\n\n* run `ab -s 128 -n 3 http://localhost:3000/report\\?start_date\\=2015-01-12\\\u0026finish_date\\=2021-02-17`\n\n* try to change `start_date` and `finish_date` and set period to 2.. 3.. 4.. days, month and years\n\n* don't forget to turn off Turbo Boost/PowerTune and power saving mode on your machine…\n\n\n### Memory profiling instruments (ruby-prof — tracing)\n\n* use *\u0026profile=measure_mem* to run simple memory profiling implemented in ApplicationHelper\n\n* use *\u0026profile=ruby_prof* for gem 'ruby-prof' and use output file `rubyprof.callgrind.out.xxxxx` with a visualizer\n\n* run `QCachegrind` Qt app for visualization and use one of these views\n\n  - Flat\n\n  - CallStack\n\n  - Graph\n\n  - callgrind (CallTree)\n\n* use [Valgrind Massif visualizer](https://github.com/KDE/massif-visualizer) which\n  makes screenshots with graph of memory consumption\n\n\u003e RubyMine must have build-in Graph visualization\n\n\u003e gem 'memory_profiler' provides similar to 'ruby-prof' memory usage information\n\n\n### Dynamic profiling instruments (derailed_benchmarks / pig-ci-rails)\n\n1. use derailed_benchmarks with my Rake task and profile memory usage by gems at boot:\n\n   ```sh\n   # to cut off files with insignificant memory usage to help eliminate noise\n   #  the task is using 0.1 MiB for ENV['CUT_OFF'] by default\n   CUT_OFF=0.3 RAILS_ENV=development rake perf:mem\n   CUT_OFF=0 RAILS_ENV=development rake perf:mem\n   ```\n\n2. test MB threshold in PigCI\n\n  - configure threshold in the `spec/rspec_helper.rb` file\n\n  - run report_spec request spec (it uses `load_seed`, but it's better to use files from `payloads/`\n    to get better report)\n\n  - all other tests must be with `describe … , pig_ci: false do` in their RSpec metadata\n\n  - check pig-ci's resulting report in `pig-ci/index.html` file\n\n\n### How to see FlameGraph (stackprof — sampling)\n\nAdd _\u0026profile=json_ to report forming url \u003chttp://localhost:3000/report?start_date=2015-01-12\u0026finish_date=2021-02-17\u003e\n  and the upload formed json file `tmp/stackprof.json` to web app \u003chttps://www.speedscope.app/\u003e\n\n```cpp\nor to generate SVG image add to that report forming url\n```\n  _\u0026profile=raw_ and then pass `tmp/stackprof.raw` to [flamegraph.pl script](https://github.com/brendangregg/FlameGraph) in console\n\n---\n\n\u003e TASKS:\n\u003e\n\u003e * make `app/lib/fast_report_builder.rb` faster or begin with `app/lib/slow_report_builder.rb`\n\u003e\n\u003e   - current \"fast\" budget is **APPROX_BUDGET = 0.15**, THRESHOLD_METRIC_IN_SECONDS = 0.2, see `app/lib/profiling.rb`\n\u003e\n\u003e   - use prefix \"faster_\" for report's name, by editing `app/lib/benchmarks/db_file_io.rb` file\n\u003e\n\u003e * change payloads/data_18.txt with payloads/data_6000.txt\n\u003e\n\u003e   - don't forget to change postfix \"\\_small\" with \"\\_big\" for report's file name, see the `db_file_io.rb` file\n\u003e\n\u003e * add changed \"faster\" report builder to Minitest/RSpec and run benchmarking test\n\u003e\n\u003e * use more derailed_benchmarks gem to perform [soak][soak_testing] (endurance) testing\n\n[soak_testing]: https://en.wikipedia.org/w/index.php?title=Software_performance_testing#Soak_testing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuplutonic%2Fprofiling-masterclass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuplutonic%2Fprofiling-masterclass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuplutonic%2Fprofiling-masterclass/lists"}