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

VimPerformanceState#vim_performance_state_for_ts optimizations #22611

Merged
merged 4 commits into from
Aug 1, 2023

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Jul 10, 2023

commits:

  • Always use iso formatted time for a cache key. (passing in date and formatting in the method)
  • Look in record's cache for reusing newly created VimPerformanceState.
  • No longer query vps table for now before calling perf_capture_state. (capture also does this query)
  • @param documentation for some Time values passed around

@kbrock
Copy link
Member Author

kbrock commented Jul 11, 2023

update:

  • removed rename of var from ts => ts_iso. It added a lot of change and this PR already has a bunch of change in it.

@kbrock
Copy link
Member Author

kbrock commented Jul 15, 2023

update:

  • rebased. want to make sure other VPS prs didn't mess this up.

defaulting to passing time into the method.
Places calling it, ensure that

Fixing:

sometimes we were passing non iso8061 into the method
so it was not finding the cached VimPerformanceState records

|       ms |       bytes |   objects |query |  qry ms |     rows |` comments`
|      ---:|         ---:|       ---:|  ---:|     ---:|      ---:|  ---
|  1,699.1 | 19,618,021* |   283,526 |    9 | 1,519.6 |       79 |`before`
|  1,664.1 | 15,672,327* |   225,826 |    5 | 1,550.8 |       75 |`after-fetch-time`
wanted to create specs around vim_performance_state_association and hit a tangent.

This already cached newly created vim_performance_state records when one did not exist in the db
but it never looked for that value in the local cache.

now it looks that value up
since perf_capture_state does a find for now, not reason to try and find it first
have tried to remove this extra query a few times.

previous attempts deleted this line.
this one is different as we added the unless. there were a few cases that we do
want a find here. (luckily there are tests around this)
@miq-bot
Copy link
Member

miq-bot commented Jul 15, 2023

Checked commits kbrock/manageiq@0d34281~...e6268fc with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
7 files checked, 0 offenses detected
Everything looks fine. 👍

@kbrock
Copy link
Member Author

kbrock commented Jul 15, 2023

update:

  • fixed 2 tests that failed after the rebase
    • a query was optimized by another PR merged - can't remember the PR. so this reduced the query count since it was affected by the other optimization.

@Fryguy Fryguy self-assigned this Jul 19, 2023
state = vim_performance_states.detect { |s| s.timestamp == t }
end
# look for state from previous perf_capture_state call
state ||= @states_by_ts[ts_iso_now]
Copy link
Member

Choose a reason for hiding this comment

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

this part is confusing to me. The right hand side will only execute if state is nil which means it would have ran the previous if state.nil? block. That block fetches a state using ts_iso_now. That means this line can only be run if it couldn't get a state using ts_iso_now, but then we use ts_iso_now to lookup into the @states_by_ts?

@Fryguy Fryguy merged commit 1a00c40 into ManageIQ:master Aug 1, 2023
@kbrock kbrock deleted the vps_for_ts branch August 1, 2023 22:44
@Fryguy
Copy link
Member

Fryguy commented Aug 2, 2023

Backported to petrosian in commit 7ea7b24.

commit 7ea7b24b5166b440e610c98db281ab4358e115be
Author: Jason Frey <[email protected]>
Date:   Tue Aug 1 16:31:10 2023 -0400

    Merge pull request #22611 from kbrock/vps_for_ts
    
    VimPerformanceState#vim_performance_state_for_ts optimizations
    
    (cherry picked from commit 1a00c40a2d885c2c5d64700a08a49b0507063235)

Fryguy added a commit that referenced this pull request Aug 2, 2023
VimPerformanceState#vim_performance_state_for_ts optimizations

(cherry picked from commit 1a00c40)
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.

3 participants