-
Notifications
You must be signed in to change notification settings - Fork 4
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
rpmautospec is very slow: grpc %changelog generated in 3 minutes #22
Comments
FTR rpmautospec-0.3.5-1.fc37.noarch |
It takes 20-25 seconds for me. I needed to disable the pager for this to work nicely:
That still seems like a lot for generating a changelog on a modern desktop. I’ll try profiling the script and see if I find anything interesting. |
So all of the time is going to calling this rpmautospec/rpmautospec/pkg_history.py Lines 105 to 125 in 1a8eb8b
|
Same for me, I tried to profile the Python code, but it spends all the time in rpm subprocess. |
@musicinmybrain Do you have Python macro memoization? That is Fedora 38+ If so, that would explain why my thing is slower. If the spec file is expanded 102 times, it probably spawns dozens of Python subprocesses each time on Fedora 37 :( |
Yes, I’m testing on F38. |
I see the same thing with the current
That makes it easier to investigate. A typical
…and it looks like the only thing changing from call to call is the temporary directory path. Maybe this is something that can be cached. |
Oh, but the temporary directory is probably being manipulated and is the real input to the function. Hmm. |
I believe this wants to get an EVR for each commit. That is reasonable. And querying it by actually using rpm is probably the only correct way to do it (I don't know why it defines I can think of one optimization. Only query the specfile up until the
|
Just out of curiosity, I compared runtime of the While there is some weak evidence of a probably-linear relationship in this dataset, mostly we see a bimodal distribution consisting of packages that use Python and those that don’t. This supports the idea that Python interpreter startups are dominating the evaluation time. |
Thanks for reporting and investigating!
If I recall correctly, we set these two python macros as a workaround for packages using them where parsing broke if they aren’t set, in environments where the packages defining the macros aren’t installed – the Koji builders outside of the buildroot for example (at least at the time).
I have no idea how much overhead cutting of the remainder is, let me check that (I guess in the grand scheme of things it’s negligible, but that’s just a guess). |
OK, this is cool: Even seemingly unaffected spec files seem to benefit from parsing an abridged version. Namely, I tested this on current Rawhide versions of the Thanks for reporting this issue, for the analysis and the suggested optimization! |
Technically you only need to preserve as much of the specfile as is required to parse and query it. That are some tags like Name, Version, License, Summary etc. And the main package %description. As long as you cut it where %prep starts, you have a very high chance it's parseable, however not 100%, as I belive putting %prep before %description is valid (despite being crazy). |
Hmm, I guess there would be a way to ensure (at least better) that all necessary |
Attempt to parse an abridged version of the spec file first, i.e. one cut off at the `%prep` line, which should still contain everything needed to parse epoch, version and autorelease flags. Only if that fails, attempt to parse the full spec file. This speeds up things tremendously in the case of spec files using macros which run subprocesses, such as certain Python macros. Even spec files not affected by this are parsed (slightly) faster if shortened accordingly. Thanks to Miro Hrončok and Ben Beasley for analyzing the issue and suggesting this optimization. Fixes: fedora-infra#22 Signed-off-by: Nils Philippsen <nils@redhat.com>
Attempt to parse an abridged version of the spec file first, i.e. one cut off at the `%prep` line, which should still contain everything needed to parse epoch, version and autorelease flags. Only if that fails, attempt to parse the full spec file. This speeds up things tremendously in the case of spec files using macros which run subprocesses, such as certain Python macros. Even spec files not affected by this are parsed (slightly) faster if shortened accordingly. Thanks to Miro Hrončok and Ben Beasley for analyzing the issue and suggesting this optimization. Fixes: fedora-infra#22 Signed-off-by: Nils Philippsen <nils@redhat.com>
Attempt to parse an abridged version of the spec file first, i.e. one cut off at the `%prep` line, which should still contain everything needed to parse epoch, version and autorelease flags. Only if that fails, attempt to parse the full spec file. This speeds up things tremendously in the case of spec files using macros which run subprocesses, such as certain Python macros. Even spec files not affected by this are parsed (slightly) faster if shortened accordingly. Thanks to Miro Hrončok and Ben Beasley for analyzing the issue and suggesting this optimization. Fixes: #22 Signed-off-by: Nils Philippsen <nils@redhat.com>
I’ll cherry-pick #23 into the |
Attempt to parse an abridged version of the spec file first, i.e. one cut off at the `%prep` line, which should still contain everything needed to parse epoch, version and autorelease flags. Only if that fails, attempt to parse the full spec file. This speeds up things tremendously in the case of spec files using macros which run subprocesses, such as certain Python macros. Even spec files not affected by this are parsed (slightly) faster if shortened accordingly. Thanks to Miro Hrončok and Ben Beasley for analyzing the issue and suggesting this optimization. Fixes: fedora-infra#22 Signed-off-by: Nils Philippsen <nils@redhat.com> (cherry picked from commit af654c4)
Attempt to parse an abridged version of the spec file first, i.e. one cut off at the `%prep` line, which should still contain everything needed to parse epoch, version and autorelease flags. Only if that fails, attempt to parse the full spec file. This speeds up things tremendously in the case of spec files using macros which run subprocesses, such as certain Python macros. Even spec files not affected by this are parsed (slightly) faster if shortened accordingly. Thanks to Miro Hrončok and Ben Beasley for analyzing the issue and suggesting this optimization. Fixes: #22 Signed-off-by: Nils Philippsen <nils@redhat.com> (cherry picked from commit af654c4)
Related: fedora-infra#22 Signed-off-by: Nils Philippsen <nils@redhat.com>
Related: #22 Signed-off-by: Nils Philippsen <nils@redhat.com>
Related: fedora-infra#22 Signed-off-by: Nils Philippsen <nils@redhat.com>
Related: fedora-infra#22 Signed-off-by: Nils Philippsen <nils@redhat.com> (cherry picked from commit d2282f8)
It seems that the changelog at https://src.fedoraproject.org/rpms/grpc (specifically this commit which is the current rawhide branch) takes more than 3 minutes to generate on my modern machine.
The git log is not particularly complex or long. Since the conversion to rpmautospec and the creation of the changelog file, it has been linear. I believe this should take seconds, not minutes.
cc @musicinmybrain
The text was updated successfully, but these errors were encountered: