Git Product home page Git Product logo

models-ruby's People

Contributors

henryaddison avatar kieranj avatar metade avatar nickevansuk avatar openactive-bot avatar thill-odi avatar ylt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

models-ruby's Issues

Memory issues with the openactive gem

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.

Data model generation failing

There appears to be an error here:

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
working-directory: ./models-ruby/

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.