main 5041353

hardware.go RawHistoryFolder

1// Package port defines interfaces for external dependencies.
2package port
3
4import "context"
5
6// HardwareInfo contains detected system hardware specifications.
7// Used for performance profile auto-tuning.
8type HardwareInfo struct {
9	// CPU information
10	CPUCores   int // Number of physical CPU cores
11	CPUThreads int // Number of logical CPU threads (with hyperthreading)
12
13	// Memory information (in bytes)
14	TotalRAM     uint64 // Total system RAM
15	AvailableRAM uint64 // Currently available RAM
16
17	// GPU information
18	GPUVendor GPUVendor // AMD, Intel, NVIDIA, or Unknown
19	GPUName   string    // Human-readable GPU name (e.g., "AMD Radeon RX 9070 XT")
20	VRAM      uint64    // Video memory in bytes (0 if unknown)
21}
22
23// CPUCoresOrDefault returns CPUCores if > 0, otherwise returns the fallback.
24func (h HardwareInfo) CPUCoresOrDefault(fallback int) int {
25	if h.CPUCores > 0 {
26		return h.CPUCores
27	}
28	return fallback
29}
30
31// CPUThreadsOrDefault returns CPUThreads if > 0, otherwise returns the fallback.
32func (h HardwareInfo) CPUThreadsOrDefault(fallback int) int {
33	if h.CPUThreads > 0 {
34		return h.CPUThreads
35	}
36	return fallback
37}
38
39// TotalRAMMB returns total RAM in megabytes.
40// Returns 0 if RAM exceeds int range (unlikely on any real system).
41func (h HardwareInfo) TotalRAMMB() int {
42	mb := h.TotalRAM / (1024 * 1024)
43	if mb > uint64(^uint(0)>>1) { // Check against max int
44		return 0
45	}
46	return int(mb)
47}
48
49// VRAMMB returns VRAM in megabytes.
50// Returns 0 if VRAM exceeds int range (unlikely on any real system).
51func (h HardwareInfo) VRAMMB() int {
52	mb := h.VRAM / (1024 * 1024)
53	if mb > uint64(^uint(0)>>1) { // Check against max int
54		return 0
55	}
56	return int(mb)
57}
58
59// HasDedicatedGPU returns true if a discrete GPU with VRAM was detected.
60func (h HardwareInfo) HasDedicatedGPU() bool {
61	return h.VRAM > 0 && h.GPUVendor != GPUVendorUnknown
62}
63
64// HardwareSurveyor detects system hardware specifications.
65type HardwareSurveyor interface {
66	// Survey detects and returns hardware information.
67	// This should be called once at startup and cached.
68	Survey(ctx context.Context) HardwareInfo
69}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close