openactive / models-ruby Goto Github PK
View Code? Open in Web Editor NEWRuby Models for the OpenActive Opportunity and Booking Specifications
License: MIT License
Ruby Models for the OpenActive Opportunity and Booking Specifications
License: MIT License
With thanks to @rsslldnphy for this report:
The openactive gem allocates a large amount of objects on require. Roughly 3MB, which might not sound like a lot, but we were routinely being pushed only a few MB over our heroku dyno's limit.
These are the gems that allocate the most memory in our app, found using the derailed_benchmarks
gem:
Total allocated: 87758372 bytes (814782 objects)
Total retained: 16486839 bytes (149308 objects)
allocated memory by gem
-----------------------------------
60706044 dead_end-1.1.7
5138712 mime-types-3.3.1
3250825 openactive-0.1.2
2066262 forwardable
1706469 hashie-4.1.0
1575432 aws-sdk-core-3.114.0
1524992 set
1349008 graphql-1.12.12
1239154 aws-sdk-s3-1.94.1
1142172 iso-639-0.3.5
1005249 addressable-2.7.0
766970 activesupport-6.0.3.5
466576 aws-sdk-kms-1.43.0
As you can see the openactive gem allocates an outsized amount of memory compared to other gems (the dead_end
gem is a dependency of the profiler, so isn't in the production app).
From what I can see this memory is mostly strings, the strings used in the define_property
calls, exacerbated by the fact that the JsonLdSerializable
concern appears to clone all the properties so will double the allocations. You can see this from the memory allocations by file here:
allocated memory by file
-----------------------------------
60706044 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/dead_end-1.1.7/lib/dead_end/auto.rb
3966971 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/mime-types-3.3.1/lib/mime/type.rb
1623351 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/hashie-4.1.0/lib/hashie/dash.rb
1524992 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/2.7.0/set.rb
1237593 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/2.7.0/forwardable.rb
1142172 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/iso-639-0.3.5/lib/iso-639.rb
979195 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/addressable-2.7.0/lib/addressable/idna/pure.rb
975960 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/aws-sdk-core-3.114.0/lib/seahorse/model/shapes.rb
954258 /Users/rosoll/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/openactive-0.1.2/lib/openactive/concerns/json_ld_serializable.rb
This is only the first few lines of the output, there's a lot more files from openactive further down, but each one contributes only a small amount to the total memory allocations.
There appears to be an error here:
models-ruby/.github/workflows/create-data-model-pr.yaml
Lines 46 to 51 in a21cdc5
Data model generation appears to be failing:
https://github.com/openactive/models-ruby/runs/5216156909?check_suite_focus=true
Run ruby/setup-ruby@v1
Modifying PATH
Downloading Ruby
Extracting Ruby
Print Ruby version
Installing Bundler
bundle install
/opt/hostedtoolcache/Ruby/3.1.0/x64/bin/bundle config --local path /home/runner/work/models-ruby/models-ruby/models-ruby/vendor/bundle
/opt/hostedtoolcache/Ruby/3.1.0/x64/bin/bundle lock
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (~> 2.2.13)
Current Bundler version:
bundler (2.3.7)
Your bundle requires a different version of Bundler than the one you're running.
Install the necessary version with `gem install bundler:2.2.[33](https://github.com/openactive/models-ruby/runs/5216156909?check_suite_focus=true#step:9:33)` and rerun
bundler using `bundle _2.2.33_ lock`
Took 1.99 seconds
To test any fix this, a branch needs to be created, and the GitHub Workflow run manually via the "Run workflow" button on https://github.com/openactive/models-ruby/actions/workflows/create-data-model-pr.yaml for that specific branch.
0.25d
2d
As described here: https://developer.openactive.io/data-model/types/schedule scheduleTimezone
is a required property for Schedule, but its definition is not implemented:
Resulting on this error message
#<NoMethodError: undefined method schedule_timezone=' for #<OpenActive::Models::Schedule:0x00007fb576c4d2a8>
1d
0.5d
The RPDE output currently includes @id
instead of id
The bug is resolved by #24
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.