Skip to content

feat: Improve GPU memory usage indication#158

Draft
afonsobspinto wants to merge 1 commit into
masterfrom
feature/improve_gpu_memory_indication
Draft

feat: Improve GPU memory usage indication#158
afonsobspinto wants to merge 1 commit into
masterfrom
feature/improve_gpu_memory_indication

Conversation

@afonsobspinto
Copy link
Copy Markdown
Member

@afonsobspinto afonsobspinto commented May 11, 2026

Closes https://metacell.atlassian.net/browse/NA-758

Layer bar visual changes:

  • Loading bars increased from 2px to 4px.
  • Adds loading bar colouring:
    A layer only gets the orange (90%) /red (98%) colouring if global GPU memory pressure is high and that layer still has visible chunks missing. If all visible chunks for that layer are available, it stays normal gray even under pressure.

@afonsobspinto afonsobspinto marked this pull request as ready for review May 11, 2026 14:20
Copy link
Copy Markdown

@seankmartin seankmartin left a comment

Choose a reason for hiding this comment

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

Note, these comments are from last week, seems I forgot to submit the review

numChunkMemoryStatistics,
} from "#src/chunk_manager/base.js";

export type GpuMemoryPressure = "normal" | "warning" | "critical";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Would probably be better to use an enum

export type GpuMemoryPressure = "normal" | "warning" | "critical";

export const GPU_MEMORY_PRESSURE_WARNING_RATIO = 0.9;
export const GPU_MEMORY_PRESSURE_CRITICAL_RATIO = 0.98;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Due to the size of chunks, I think it's quite likely 0.98 won't be reached in many cases. Thinking on that

export const GPU_MEMORY_PRESSURE_WARNING_RATIO = 0.9;
export const GPU_MEMORY_PRESSURE_CRITICAL_RATIO = 0.98;

export function computeGpuMemoryBytes(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think overall this might be a bit too inclusive. While I like that it's a non-biased stance, I think we might need to be a bit more heuristic based.
I guess it doesn't matter much if a prefetch chunk is causing memory pressure. The problems with memory pressure will become tangible to the user when the visible chunk memory is hitting the limit.
Similarly we may want to only show memory pressure on visible chunks (the top bar in the layer indicator), and make the prefetch bar smaller or hidden by default and a UI config setting to turn on the prefetch bar.
I get the sense that at the moment as soon as you enter a situation of high memory pressure, then even if you leave that high memory pressure situation for visible chunks, you'll still see the warning and critical colors very often because the non-visible memory usage is still high

Comment on lines +55 to +62
if (
!Number.isFinite(gpuMemoryBytes) ||
!Number.isFinite(gpuMemoryLimitBytes) ||
gpuMemoryBytes < 0 ||
gpuMemoryLimitBytes <= 0
) {
return "normal";
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not sure any of these can really happen, outside of the limit being 0, but then we'd just get infinity which is fine as a critical value

@afonsobspinto afonsobspinto marked this pull request as draft May 19, 2026 13:50
@afonsobspinto
Copy link
Copy Markdown
Member Author

Moving to draft as we need to further discuss the expected behaviour. For now #170 should be enough

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.

2 participants