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

Set --expect-discarded-cache option #1540

Merged
merged 5 commits into from Feb 17, 2023
Merged

Conversation

cklin
Copy link
Contributor

@cklin cklin commented Feb 14, 2023

This PR changes the action to pass --expect-discarded-cache to the last codeql database run-queries invocation to improve performance.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

This refactoring commit changes databaseRunQueries() to accept a list of
flags instead of separate memory and threads flags.
src/analyze.ts Outdated Show resolved Hide resolved
@cklin cklin marked this pull request as ready for review February 15, 2023 17:42
@cklin cklin requested a review from a team as a code owner February 15, 2023 17:42
Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

A question inline.

Also, can you think of any way of testing this? Probably a unit test or two would be fine. We are testing the runQueries command in this test: https://github.com/aeisenberg/codeql-action/blob/main/src/analyze.test.ts#L25 This test could be expanded, or a new test that focuses explicitly on this flag could be written.

We can pair on this if you like.

src/analyze.ts Outdated Show resolved Hide resolved
src/analyze.ts Outdated Show resolved Hide resolved
src/analyze.ts Outdated
Comment on lines 226 to 227
const isLastLanguage =
language === config.languages[config.languages.length - 1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how --expect-discarded-cache actually works, but does it affect all languages in a cluster at the same time? Ie- if you have a clustered db with java and javascript, will running with --expect-discarded-cache on java queries affect the cache for javascript?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on discussions in the tracking issue, I think we should set --expect-discarded-cache for the last run-queries command of each language (as opposed to for all languages).

This refactoring commit changes runQueries() to calculate the set of
indices with non-empty custom queries early. Doing so allows us to check
early on whether there are any custom queries to run.
@cklin
Copy link
Contributor Author

cklin commented Feb 17, 2023

I made the suggested changes and added unit tests. PTAL. Thank you!

Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

Nice work.

});
});

test("optimizeForLastQueryRun for two languages, CliConfigFileEnabled", async (t) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Going forward, Feature.CliConfigFileEnabled should be enabled for all users (except some specific DCA repos).

@cklin cklin merged commit 3dde1f3 into github:main Feb 17, 2023
@github-actions github-actions bot mentioned this pull request Feb 24, 2023
6 tasks
@cklin cklin deleted the expect-discarded-cache branch February 27, 2023 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants