MCPcopy Index your code
hub / github.com/continuedev/continue / isSupportedLanceDbCpuTargetForLinux

Function isSupportedLanceDbCpuTargetForLinux

core/config/util.ts:130–177  ·  view source on GitHub ↗
(ide?: IDE)

Source from the content-addressed store, hash-verified

128 * See here for details: https://github.com/continuedev/continue/issues/940
129 */
130export function isSupportedLanceDbCpuTargetForLinux(ide?: IDE) {
131 const CPU_FEATURES_TO_CHECK = ["avx2", "fma"] as const;
132
133 const globalContext = new GlobalContext();
134 const globalContextVal = globalContext.get(
135 "isSupportedLanceDbCpuTargetForLinux",
136 );
137
138 // If we've already checked the CPU target, return the cached value
139 if (globalContextVal !== undefined) {
140 return globalContextVal;
141 }
142
143 const arch = os.arch();
144
145 // This check only applies to x64
146 //https://github.com/lancedb/lance/issues/2195#issuecomment-2057841311
147 if (arch !== "x64") {
148 globalContext.update("isSupportedLanceDbCpuTargetForLinux", true);
149 return true;
150 }
151
152 try {
153 const cpuFlags = fs.readFileSync("/proc/cpuinfo", "utf-8").toLowerCase();
154
155 const isSupportedLanceDbCpuTargetForLinux = cpuFlags
156 ? CPU_FEATURES_TO_CHECK.every((feature) => cpuFlags.includes(feature))
157 : true;
158
159 // If it's not a supported CPU target, and it's the first time we are checking,
160 // show a toast to inform the user that we are going to disable indexing.
161 if (!isSupportedLanceDbCpuTargetForLinux && ide) {
162 // We offload our async toast to `showUnsupportedCpuToast` to prevent making
163 // our config loading async upstream of `isSupportedLanceDbCpuTargetForLinux`
164 void showUnsupportedCpuToast(ide);
165 }
166
167 globalContext.update(
168 "isSupportedLanceDbCpuTargetForLinux",
169 isSupportedLanceDbCpuTargetForLinux,
170 );
171
172 return isSupportedLanceDbCpuTargetForLinux;
173 } catch (error) {
174 // If we can't determine CPU features, default to true
175 return true;
176 }
177}
178
179async function showUnsupportedCpuToast(ide: IDE) {
180 const shouldOpenLink = await ide.showToast(

Callers 3

createMethod · 0.90
initLanceDbMethod · 0.90
loadSerializedConfigFunction · 0.90

Calls 3

getMethod · 0.95
updateMethod · 0.95
showUnsupportedCpuToastFunction · 0.85

Tested by

no test coverage detected