-
Notifications
You must be signed in to change notification settings - Fork 78
feat(FR-1681): implement automatic shared memory calculation in session creation #4644
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
base: main
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🔴 | Statements | 4.69% (+0% 🔼) |
547/11669 |
| 🔴 | Branches | 3.82% (+0% 🔼) |
314/8221 |
| 🔴 | Functions | 2.91% (-0% 🔻) |
104/3577 |
| 🔴 | Lines | 4.64% (+0% 🔼) |
529/11410 |
Show new covered files 🐣
St.❔ |
File | Statements | Branches | Functions | Lines |
|---|---|---|---|---|---|
| 🔴 | ... / ImportAndRunPage.tsx |
0% | 100% | 0% | 0% |
Test suite run success
125 tests passing in 14 suites.
Report generated by 🧪jest coverage report action from a627ebb
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.
Pull Request Overview
This PR implements automatic shared memory (shmem) calculation in the startSessionWithDefault function to ensure consistency with UI-based session creation.
Key Changes:
- Added automatic shmem calculation logic that sets shmem to 1GB when memory ≥ 4GB, otherwise 64MB
- Imports
AUTOMATIC_DEFAULT_SHMEMconstant andcompareNumberWithUnitshelper function - Logic is applied when
enabledAutomaticShmemflag is enabled and memory is allocated
| // Apply automatic shmem calculation if enabledAutomaticShmem is true | ||
| if (mergedValue.enabledAutomaticShmem && mergedValue.resource?.mem) { | ||
| const mem = mergedValue.resource.mem; | ||
|
|
||
| // Apply the same logic as ResourceAllocationFormItems | ||
| // If mem > 4G, set shmem to 1G, otherwise use AUTOMATIC_DEFAULT_SHMEM (64m) | ||
| if (compareNumberWithUnits(mem, '4g') >= 0) { | ||
| mergedValue.resource.shmem = '1g'; | ||
| } else { | ||
| mergedValue.resource.shmem = AUTOMATIC_DEFAULT_SHMEM; | ||
| } | ||
| } |
Copilot
AI
Nov 14, 2025
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.
The automatic shmem calculation logic is inconsistent with the original implementation in ResourceAllocationFormItems.tsx.
Issues:
- The
runShmemAutomationRulefunction inResourceAllocationFormItems.tsxexpectsM_plus_S(Memory + Shared Memory combined), but this implementation only usesmem(Memory alone) - Missing validation: The original logic checks if
M+S > M+1Gto ensure there's enough memory to allocate 1GB for shmem - Missing check: The original verifies
compareNumberWithUnits('1g', AUTOMATIC_DEFAULT_SHMEM) > 0to avoid downgrading shmem
Recommended fix:
// Apply automatic shmem calculation if enabledAutomaticShmem is true
if (mergedValue.enabledAutomaticShmem && mergedValue.resource?.mem) {
const mem = mergedValue.resource.mem;
const currentShmem = mergedValue.resource.shmem || AUTOMATIC_DEFAULT_SHMEM;
const M_plus_S = addNumberWithUnits(mem, currentShmem, 'g') || '0g';
// Apply the same logic as ResourceAllocationFormItems
if (
compareNumberWithUnits(M_plus_S, '4g') >= 0 &&
compareNumberWithUnits(M_plus_S, addNumberWithUnits(mem, '1g') || '0b') >= 0 &&
compareNumberWithUnits('1g', AUTOMATIC_DEFAULT_SHMEM) > 0
) {
mergedValue.resource.shmem = '1g';
} else {
mergedValue.resource.shmem = AUTOMATIC_DEFAULT_SHMEM;
}
}Note: You'll also need to import addNumberWithUnits from the helper module.
agatha197
left a comment
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.
please check copilot's reviews.

Resolves (FR-1681)
Summary
Implement automatic shared memory (shmem) calculation in the
startSessionWithDefaultfunction to ensure consistency with UI-based session creation.Changes
useStartSession.tsxenabledAutomaticShmemis enabled and memory is allocated:AUTOMATIC_DEFAULT_SHMEMconstant andcompareNumberWithUnitshelperBackground
Previously, the
ResourceAllocationFormItemscomponent had automatic shmem calculation logic, but programmatic session creation throughuseStartSessionhook did not apply the same logic. This created inconsistency between UI-based and programmatic session creation, potentially leading to suboptimal resource allocation.Test Plan