-
Notifications
You must be signed in to change notification settings - Fork 430
Overlay: Fall back to full analysis if memory flag is low #3332
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ import { | |
| cloneObject, | ||
| isDefined, | ||
| checkDiskUsage, | ||
| getMemoryFlagValue, | ||
| } from "./util"; | ||
|
|
||
| export * from "./config/db-config"; | ||
|
|
@@ -393,6 +394,7 @@ export interface InitConfigInputs { | |
| dbLocation: string | undefined; | ||
| configInput: string | undefined; | ||
| buildModeInput: string | undefined; | ||
| ramInput: string | undefined; | ||
| trapCachingEnabled: boolean; | ||
| dependencyCachingEnabled: string | undefined; | ||
| debugMode: boolean; | ||
|
|
@@ -661,6 +663,7 @@ export async function getOverlayDatabaseMode( | |
| languages: Language[], | ||
| sourceRoot: string, | ||
| buildMode: BuildMode | undefined, | ||
| ramInput: string | undefined, | ||
| codeScanningConfig: UserConfig, | ||
| logger: Logger, | ||
| ): Promise<{ | ||
|
|
@@ -692,6 +695,7 @@ export async function getOverlayDatabaseMode( | |
| ) | ||
| ) { | ||
| const diskUsage = await checkDiskUsage(logger); | ||
| const memoryFlagValue = getMemoryFlagValue(ramInput, logger); | ||
| if ( | ||
| diskUsage === undefined || | ||
| diskUsage.numAvailableBytes < OVERLAY_MINIMUM_AVAILABLE_DISK_SPACE_BYTES | ||
|
|
@@ -706,22 +710,27 @@ export async function getOverlayDatabaseMode( | |
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| `due to insufficient disk space (${diskSpaceMb} MB).`, | ||
| ); | ||
| } else { | ||
| if (isAnalyzingPullRequest()) { | ||
| overlayDatabaseMode = OverlayDatabaseMode.Overlay; | ||
| useOverlayDatabaseCaching = true; | ||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "with caching because we are analyzing a pull request.", | ||
| ); | ||
| } else if (await isAnalyzingDefaultBranch()) { | ||
| overlayDatabaseMode = OverlayDatabaseMode.OverlayBase; | ||
| useOverlayDatabaseCaching = true; | ||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "with caching because we are analyzing the default branch.", | ||
| ); | ||
| } | ||
| } else if (memoryFlagValue < 5 * 1024) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be good to turn |
||
| overlayDatabaseMode = OverlayDatabaseMode.None; | ||
| useOverlayDatabaseCaching = false; | ||
|
Comment on lines
+714
to
+715
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This pattern of disabling overlay mode is now duplicated in a lot and might be worth de-duplicating. I think you might be doing that in #3333 already. |
||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| `due to insufficient memory for CodeQL analysis (${memoryFlagValue} MB).`, | ||
| ); | ||
| } else if (isAnalyzingPullRequest()) { | ||
| overlayDatabaseMode = OverlayDatabaseMode.Overlay; | ||
| useOverlayDatabaseCaching = true; | ||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "with caching because we are analyzing a pull request.", | ||
| ); | ||
| } else if (await isAnalyzingDefaultBranch()) { | ||
| overlayDatabaseMode = OverlayDatabaseMode.OverlayBase; | ||
| useOverlayDatabaseCaching = true; | ||
| logger.info( | ||
| `Setting overlay database mode to ${overlayDatabaseMode} ` + | ||
| "with caching because we are analyzing the default branch.", | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -875,6 +884,7 @@ export async function initConfig( | |
| config.languages, | ||
| inputs.sourceRoot, | ||
| config.buildMode, | ||
| inputs.ramInput, | ||
| config.computedConfig, | ||
| logger, | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I wonder if it would make sense to rename
getMemoryFlagValuesince the result is now used for something other than the "memory flag".