- HN/Rust: Skylight uses an agent embedded in Rails applications. Ruby = high memory, C++ = high risk of crashes.
- 92% smaller than Ruby agent.
Optimize Rails performance bottleneck with caching and Rack middleware
- Redis for slow AR queries. For Heroku, you can have Redis to Go.
- Sidekiq Cron used to update the cache every half an hour.
- A Redis hit means no database query and also reduces memory usage because you don’t need to instantiate ActiveRecord objects.
- Rack middleware: You can create your own middleware, so that the app doesn’t pass through Rails.
Limit Rails memory usage, fix R14 and save money on Heroku
gem derailed_benchmarksto see which gems consume a lot of memory.
jemallocas an alternative to the official MRI memory allocator.
- Limiting concurrency and workers. Just 1?
- Optimize JSON parsing?
Ruby under a Microscope
defs/keywordscontains all the keywords in Ruby.
retryare used to execute parts of the loop.
redorepeats the current iteration,
retryrepeats the whole loop from the start. Reference
undefapparently is a reserved word, but how would you use it?
- This is used in things like mocking.
- Rails codebase: Used for testing the behavior of classes with and without modules mixed-in.
- This can be used for blocking a class explicitly defined in the superclass.
- For mixins: you can include the whole mixin, but remove the methods it shouldn’t support. Ex: in the graphics library
buttonclass mixes in
releasemethod because buttons don’t support it.
- You can sort of include methods dynamically.
Form.send(:include, FormExportingMethods)if you really need to.
99 Bottles of OOP
- Shameless green.
- Transformation Priority Premise: It makes sense, but it’s like, too robot-like/nuanced?
- Tests: Sometimes it’s just better to test the hardcoded strings rather than pass through a function.