Skip to content
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

Add rubygems for profiling and performance analyzing #9953

Open
wants to merge 1 commit into
base: rpm/develop
Choose a base branch
from

Conversation

m-bucher
Copy link

@m-bucher m-bucher commented Nov 7, 2023

Would it make sense to add a tool for profiling the rails requests?
https://github.com/MiniProfiler/rack-mini-profiler

Requires: theforeman/foreman#9897

Fixes #36898

@ekohl
Copy link
Member

ekohl commented Nov 7, 2023

Perhaps, but then I'd expect a foreman-profiling package that pulls these gems in. To achieve that, we have bundler.d and subpackages in foreman.spec. For foreman-proxy there's a similar setup. The benefit is that it's easier for end users to set up and for packagers we'd benefit from automatic updates to these gems.

@m-bucher
Copy link
Author

m-bucher commented Nov 7, 2023

@ekohl agreed. I have a remaining question:
Adding bundler.d/profiling.rb could either be done in the spec-file or by adding it to https://github.com/theforeman/foreman.
The downside of adding it to foreman directly is that it will automatically be enabled on dev-boxes as well. Is that OK or is there a third option I currently just do not see.
I could add it as bundler.d/profiling.rb.off, but that seems hacky as well 🤔

@ekohl
Copy link
Member

ekohl commented Nov 7, 2023

The correct solution is in foreman.git. Otherwise you have all the downsides and none of the upsides. Automatic packages updates won't work, we need to keep it in sync between Debian and RPM.

You actually have optional groups in bundler: https://bundler.io/guides/groups.html#optional-groups-and-bundlewith

group :profiling, optional: true do
  # ...
end

@m-bucher
Copy link
Author

m-bucher commented Nov 7, 2023

I see, can I achieve the group becoming active by installing the foreman-profiling sub-package?
I would assume I have to configure it somewhere. Maybe as a %post in the spec-file.

@m-bucher m-bucher force-pushed the add_profiling_tools branch 3 times, most recently from 9bb5f38 to 4c97d2d Compare November 7, 2023 14:48
@ekohl
Copy link
Member

ekohl commented Nov 7, 2023

I see, can I achieve the group becoming active by installing the foreman-profiling sub-package?
I would assume I have to configure it somewhere. Maybe as a %post in the spec-file.

I'd patch the optional: true part out in packaging with a simple sed statement. That needs to be duplicated for Debian and RPM, but once implemented it shouldn't change.

@m-bucher m-bucher force-pushed the add_profiling_tools branch from 4c97d2d to 1b5c101 Compare November 7, 2023 15:25

%files profiling
%{_datadir}/%{name}/bundler.d/profiling.rb
%{_datadir}/%{name}/config/initializers/rack_mini_profiler.rb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think by default this means the file is present in both foreman and foreman-profiling. Be sure to check that.

It may also be fine to include it in core if it gracefully falls back if the dependencies aren't present. Though there may be a security concern so I'm not strict on that. Just want to make sure you're doing what you intend to do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what I can say from trying it out is that in 'productive-mode, which means Gemfile.In` is present, all available groups are loaded, regardless of it being optional or not.

When we use bundler, groups matter, but even though I do bundle --with profiling, the group would have to be required somewhere in code like here: https://github.com/theforeman/foreman/blob/fa79806973c6de08b6d265ed1ae99c0ff4f06bd6/config/application.rb#L59

Assuming we want to have it in development-environment and in production, if it is installed, then I would keep it in bundler.d/profiling.rb but add it to development-group.

I think by default this means the file is present in both foreman and foreman-profiling. Be sure to check that.

AFAIK having the same filepath in multiple packages is a big NoNo in most packaging-frameworks and my first test suggests it is only in the foreman-profiling package after build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what I can say from trying it out is that in productive-mode, which means Gemfile.In is present, all available groups are loaded, regardless of it being optional or not.

That's due to bundler_ext, which we use on Red Hat. We don't on Debian. Perhaps this is a good excuse to drop bundler_ext usage. The original use case was that you could ignore gem dependencies in RPMs, for security patching. These days we just make sure the gem dependencies are correct.

AFAIK having the same filepath in multiple packages is a big NoNo in most packaging-frameworks and my first test suggests it is only in the foreman-profiling package after build.

I know I've seen weirdness with this in the past, so just wanted to highlight that it should be checked.

@m-bucher m-bucher force-pushed the add_profiling_tools branch from 9a25b4c to 3b49f77 Compare April 8, 2024 14:21
@m-bucher
Copy link
Author

m-bucher commented Apr 8, 2024

@ekohl is this ready to merge now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants