-
Notifications
You must be signed in to change notification settings - Fork 617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds rideshare memory leak #2641
Open
Rperry2174
wants to merge
8
commits into
main
Choose a base branch
from
add-rideshare-mem-leak
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2505328
Adds rideshare memory leak
Rperry2174 5f1717f
adds ruby example
petethepig 0a7b1fa
add commented version which has fancy behavior
Rperry2174 6f087cf
actually add ruby
petethepig fbc336d
one more try
petethepig d0b698d
snapshot
petethepig c8f4038
fixes
petethepig e2d7c41
fix
petethepig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM ruby:3.0.1 | ||
|
||
WORKDIR /opt/app | ||
|
||
COPY Gemfile ./Gemfile | ||
COPY Gemfile.lock ./Gemfile.lock | ||
# RUN bundle config set --local deployment true | ||
RUN bundle install | ||
|
||
COPY lib ./lib | ||
|
||
CMD [ "ruby", "lib/server.rb" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
|
||
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } | ||
|
||
# gem "rails" | ||
|
||
gem "pyroscope" | ||
gem "sinatra", "~> 2.1" | ||
|
||
gem "thin", "~> 1.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
daemons (1.4.1) | ||
eventmachine (1.2.7) | ||
ffi (1.16.3) | ||
mustermann (1.1.1) | ||
ruby2_keywords (~> 0.0.1) | ||
pyroscope (0.5.10) | ||
ffi | ||
pyroscope (0.5.10-aarch64-linux) | ||
ffi | ||
pyroscope (0.5.10-arm64-darwin) | ||
ffi | ||
pyroscope (0.5.10-x86_64-linux) | ||
ffi | ||
rack (2.2.3) | ||
rack-protection (2.1.0) | ||
rack | ||
ruby2_keywords (0.0.5) | ||
sinatra (2.1.0) | ||
mustermann (~> 1.0) | ||
rack (~> 2.2) | ||
rack-protection (= 2.1.0) | ||
tilt (~> 2.0) | ||
thin (1.8.1) | ||
daemons (~> 1.0, >= 1.0.9) | ||
eventmachine (~> 1.0, >= 1.0.4) | ||
rack (>= 1, < 3) | ||
tilt (2.0.10) | ||
|
||
PLATFORMS | ||
aarch64-linux | ||
arm64-darwin-22 | ||
arm64-linux | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
pyroscope | ||
sinatra (~> 2.1) | ||
thin (~> 1.8) | ||
|
||
BUNDLED WITH | ||
2.2.22 |
5 changes: 5 additions & 0 deletions
5
examples/golang-push/rideshare/rideshare-mem/lib/bike/bike.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require_relative '../utility/utility' | ||
|
||
def order_bike(search_radius) | ||
find_nearest_vehicle(search_radius, "bike") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require_relative '../utility/utility' | ||
|
||
def order_car(search_radius) | ||
find_nearest_vehicle(search_radius, "car") | ||
end |
5 changes: 5 additions & 0 deletions
5
examples/golang-push/rideshare/rideshare-mem/lib/scooter/scooter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require_relative '../utility/utility' | ||
|
||
def order_scooter(search_radius) | ||
find_nearest_vehicle(search_radius, "scooter") | ||
end |
36 changes: 36 additions & 0 deletions
36
examples/golang-push/rideshare/rideshare-mem/lib/server.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "sinatra" | ||
require "thin" | ||
require "pyroscope" | ||
require_relative 'scooter/scooter' | ||
require_relative 'bike/bike' | ||
require_relative 'car/car' | ||
|
||
|
||
Pyroscope.configure do |config| | ||
config.application_name = "ride-sharing-app-ruby" | ||
config.server_address = "http://pyroscope:4040" | ||
config.tags = { | ||
"region": ENV["REGION"], | ||
} | ||
end | ||
|
||
get "/bike" do | ||
order_bike(0.4) | ||
"<p>Bike ordered</p>" | ||
end | ||
|
||
get "/scooter" do | ||
order_scooter(0.6) | ||
"<p>Scooter ordered</p>" | ||
end | ||
|
||
get "/car" do | ||
order_car(0.8) | ||
"<p>Car ordered</p>" | ||
end | ||
|
||
|
||
set :bind, '0.0.0.0' | ||
set :port, 5000 | ||
|
||
run Sinatra::Application.run! |
38 changes: 38 additions & 0 deletions
38
examples/golang-push/rideshare/rideshare-mem/lib/utility/utility.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require "pyroscope" | ||
|
||
def mutex_lock(n) | ||
i = 0 | ||
start_time = Time.new | ||
while Time.new - start_time < n * 10 do | ||
i += 1 | ||
end | ||
end | ||
|
||
def check_driver_availability(n) | ||
i = 0 | ||
start_time = Time.new | ||
while Time.new - start_time < n / 2 do | ||
i += 1 | ||
end | ||
|
||
# Every 4 minutes this will artificially create make requests in eu-north region slow | ||
# this is just for demonstration purposes to show how performance impacts show up in the | ||
# flamegraph | ||
current_time = Time.now | ||
current_minute = current_time.strftime('%M').to_i | ||
force_mutex_lock = (current_minute * 4 % 8) == 0 | ||
|
||
mutex_lock(n) if ENV["REGION"] == "eu-north" and force_mutex_lock | ||
end | ||
|
||
def find_nearest_vehicle(n, vehicle) | ||
Pyroscope.tag_wrapper({ "vehicle" => vehicle }) do | ||
i = 0 | ||
start_time = Time.new | ||
while Time.new - start_time < n do | ||
i += 1 | ||
end | ||
|
||
check_driver_availability(n) if vehicle == "car" | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
examples/golang-push/rideshare/rideshare_rails/.gitattributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# See https://git-scm.com/docs/gitattributes for more about git attribute files. | ||
|
||
# Mark the database schema as having been generated. | ||
db/schema.rb linguist-generated | ||
|
||
# Mark any vendored files as having been vendored. | ||
vendor/* linguist-vendored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# See https://help.github.com/articles/ignoring-files for more about ignoring files. | ||
# | ||
# If you find yourself ignoring temporary files generated by your text editor | ||
# or operating system, you probably want to add a global ignore instead: | ||
# git config --global core.excludesfile '~/.gitignore_global' | ||
|
||
# Ignore bundler config. | ||
/.bundle | ||
|
||
# Ignore the default SQLite database. | ||
/db/*.sqlite3 | ||
/db/*.sqlite3-* | ||
|
||
# Ignore all logfiles and tempfiles. | ||
/log/* | ||
/tmp/* | ||
!/log/.keep | ||
!/tmp/.keep | ||
|
||
# Ignore pidfiles, but keep the directory. | ||
/tmp/pids/* | ||
!/tmp/pids/ | ||
!/tmp/pids/.keep | ||
|
||
|
||
/public/assets | ||
|
||
# Ignore master key for decrypting credentials and more. | ||
/config/master.key | ||
|
||
_git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
FROM ruby:3.1.4 | ||
|
||
# RUN apk add --no-cache --update \ | ||
# build-base \ | ||
# linux-headers \ | ||
# git \ | ||
# postgresql-dev \ | ||
# nodejs \ | ||
# yarn \ | ||
# tzdata \ | ||
# graphviz \ | ||
# gmp-dev | ||
|
||
# RUN apk add --no-cache --update \ | ||
# sqlite-dev | ||
|
||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
ENV RAILS_ENV production | ||
ENV RAILS_SERVE_STATIC_FILES true | ||
ENV RAILS_LOG_TO_STDOUT true | ||
|
||
COPY Gemfile /usr/src/app/ | ||
COPY Gemfile.lock /usr/src/app/ | ||
|
||
RUN bundle config --global frozen 1 | ||
RUN bundle install --without development test | ||
|
||
COPY app /usr/src/app/app | ||
COPY bin /usr/src/app/bin | ||
COPY config /usr/src/app/config | ||
COPY public /usr/src/app/public | ||
|
||
COPY Rakefile /usr/src/app/ | ||
COPY config.ru /usr/src/app/ | ||
|
||
EXPOSE 5000 | ||
|
||
RUN rm -f tmp/pids/server.pid | ||
|
||
CMD ["rails", "s", "-b", "0.0.0.0", "-p", "5000"] | ||
|
6 changes: 6 additions & 0 deletions
6
examples/golang-push/rideshare/rideshare_rails/Dockerfile.load-generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM golang:1.19 | ||
|
||
|
||
COPY loadgen.go ./loadgen.go | ||
RUN go build -o /loadgen loadgen.go | ||
CMD [ "/loadgen" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
source "https://rubygems.org" | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" | ||
gem "rails", "~> 7.0.2", ">= 7.0.2.3" | ||
|
||
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] | ||
gem "sprockets-rails" | ||
|
||
# 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" | ||
|
||
gem "brotli" | ||
|
||
gem "pyroscope" | ||
|
||
gem "pyroscope-otel" | ||
gem 'opentelemetry-sdk', "~> 1.2.0" | ||
gem 'opentelemetry-exporter-jaeger', '~> 0.22.0' | ||
gem 'opentelemetry-instrumentation-rails' # it's top span is "http get" which is not super usefull for demo | ||
|
||
|
||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem | ||
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] | ||
|
||
group :development, :test do | ||
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem | ||
gem "debug", platforms: %i[ mri mingw x64_mingw ] | ||
end | ||
|
||
group :development do | ||
# Speed up commands on slow machines / big apps [https://github.com/rails/spring] | ||
# gem "spring" | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusting the sizes here will work when running locally, but in order to get these to reflect in sedemo, you'll need to update them here. There's additional knobs to tune there as well. The memory limit is 64Mi per pod, so using sizes this big would OOM those pods right away.
Of course, if this is just intended to be shown with a local version of the rideshare demo then adjusting these settings will but 👌