Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
index.js256 linesDownload Raw Back to oxc-parser
1import CJS_COMPAT_NODE_URL_9zo2090uugq from 'node:url';2import CJS_COMPAT_NODE_PATH_9zo2090uugq from 'node:path';3import CJS_COMPAT_NODE_MODULE_9zo2090uugq from "node:module";4 5var __filename = CJS_COMPAT_NODE_URL_9zo2090uugq.fileURLToPath(import.meta.url);6var __dirname = CJS_COMPAT_NODE_PATH_9zo2090uugq.dirname(__filename);7var require = CJS_COMPAT_NODE_MODULE_9zo2090uugq.createRequire(import.meta.url);8 9// ------------------------------------------------------------10// end of CJS compatibility banner, injected by Storybook's esbuild configuration11// ------------------------------------------------------------12import {13  OxcParseError,14  oxcParse15} from "../_node-chunks/chunk-MXGCET2M.js";16import "../_node-chunks/chunk-7T7BCSOI.js";17import "../_node-chunks/chunk-RSQFAFCN.js";18import "../_node-chunks/chunk-SLGVGTWJ.js";19import "../_node-chunks/chunk-IATWEHFW.js";20 21// src/oxc-parser/index.ts22import {23  parseSync as oxcRawParseSync24} from "oxc-parser";25 26// src/oxc-parser/worker-pool.ts27import { existsSync } from "node:fs";28import { cpus } from "node:os";29import { fileURLToPath } from "node:url";30import { Worker } from "node:worker_threads";31import { logger } from "storybook/internal/node-logger";32var WORKER_RELATIVE_PATH = "../oxc-parser/worker.js", DEFAULT_TASK_TIMEOUT_MS = 3e4;33function resolveWorkerScriptPath() {34  if (typeof import.meta.url != "string")35    return;36  let path = fileURLToPath(new URL(WORKER_RELATIVE_PATH, import.meta.url));37  return existsSync(path) ? path : void 0;38}39function computePoolSize() {40  let cpuCount = cpus().length;41  return Math.max(1, Math.min(4, cpuCount - 1));42}43var OxcWorkerPool = class {44  constructor(scriptPath, size, taskTimeoutMs = DEFAULT_TASK_TIMEOUT_MS) {45    this.workers = [];46    this.queue = [];47    this.pending = /* @__PURE__ */ new Map();48    this.nextId = 0;49    this.disposed = !1;50    this.taskTimeoutMs = taskTimeoutMs;51    try {52      for (let i = 0; i < size; i++) {53        let worker = new Worker(scriptPath), slot = { worker, busy: !1 };54        worker.on("message", (msg) => this.handleMessage(slot, msg)), worker.on("error", (error) => this.handleWorkerFailure(error)), worker.on("exit", (code) => {55          this.disposed || this.handleWorkerFailure(new Error(`oxc-worker exited unexpectedly with code ${code}`));56        }), worker.unref(), this.workers.push(slot);57      }58    } catch (err) {59      for (let slot of this.workers)60        slot.worker.terminate().catch(() => 0);61      throw this.workers.length = 0, err;62    }63  }64  parse(filePath, source) {65    return this.disposed ? Promise.reject(new OxcParseError("oxc parse pool disposed")) : new Promise((resolve, reject) => {66      this.queue.push({ filePath, source, resolve, reject }), this.drain();67    });68  }69  drain() {70    for (; this.queue.length > 0; ) {71      let slot = this.workers.find((s) => !s.busy);72      if (!slot)73        return;74      let task = this.queue.shift(), id = this.nextId++;75      slot.busy = !0;76      let pending = {77        resolve: task.resolve,78        reject: task.reject79      };80      this.taskTimeoutMs > 0 && (pending.timer = setTimeout(() => {81        this.handleWorkerFailure(82          new Error(`oxc-worker task ${id} timed out after ${this.taskTimeoutMs}ms`)83        );84      }, this.taskTimeoutMs), pending.timer.unref?.()), this.pending.set(id, pending), slot.worker.postMessage({ id, filePath: task.filePath, source: task.source });85    }86  }87  handleMessage(slot, msg) {88    let entry = this.pending.get(msg.id);89    if (entry) {90      if (entry.timer && clearTimeout(entry.timer), this.pending.delete(msg.id), slot.busy = !1, msg.ok && msg.edges)91        entry.resolve(msg.edges);92      else {93        let err = new OxcParseError(msg.message ?? "oxc-worker error");94        msg.name && (err.name = msg.name), entry.reject(err);95      }96      this.drain();97    }98  }99  /**100   * On any worker failure: reject all in-flight and queued tasks, dispose the pool so101   * subsequent parse() calls fail fast and the caller in index.ts falls back to inline102   * oxcParse. Nulls out the module-level pool reference so getOxcParsePool() returns null.103   */104  handleWorkerFailure(error) {105    if (!this.disposed) {106      logger.debug(`oxc-worker failure: ${error.message}`), this.disposed = !0;107      for (let [, entry] of this.pending)108        entry.timer && clearTimeout(entry.timer), entry.reject(new OxcParseError(`oxc-worker failure: ${error.message}`, { cause: error }));109      this.pending.clear();110      for (let queued of this.queue)111        queued.reject(new OxcParseError("oxc parse pool disposed"));112      this.queue.length = 0;113      for (let slot of this.workers)114        slot.worker.terminate().catch(() => 0);115      this.workers.length = 0, sharedPool = null;116    }117  }118  async dispose() {119    if (this.disposed)120      return;121    this.disposed = !0;122    for (let [, entry] of this.pending)123      entry.timer && clearTimeout(entry.timer), entry.reject(new OxcParseError("oxc parse pool disposed"));124    this.pending.clear();125    for (let queued of this.queue)126      queued.reject(new OxcParseError("oxc parse pool disposed"));127    this.queue.length = 0;128    let terminations = this.workers.map((s) => s.worker.terminate().catch(() => 0));129    this.workers.length = 0, await Promise.all(terminations);130  }131}, sharedPool = null;132function ensurePool() {133  if (sharedPool)134    return;135  let scriptPath = resolveWorkerScriptPath();136  if (!scriptPath) {137    logger.debug(138      "oxc worker pool disabled: compiled worker script not found (running from source?)"139    );140    return;141  }142  try {143    sharedPool = new OxcWorkerPool(scriptPath, computePoolSize());144  } catch (error) {145    logger.debug(146      `oxc worker pool disabled: failed to spawn (${error instanceof Error ? error.message : String(error)})`147    ), sharedPool = null;148  }149}150function getOxcParsePool() {151  return ensurePool(), sharedPool;152}153async function disposeOxcParsePool() {154  let pool = sharedPool;155  sharedPool = null, pool && await pool.dispose().catch(() => {156  });157}158 159// src/oxc-parser/index.ts160async function parseWithOxc(filePath, source) {161  let pool = getOxcParsePool();162  if (!pool)163    return oxcParse(filePath, source);164  try {165    return await pool.parse(filePath, source);166  } catch {167    return oxcParse(filePath, source);168  }169}170async function parseBarrelInfo(filePath, source) {171  let parseResult;172  try {173    parseResult = oxcRawParseSync(filePath, source);174  } catch {175    return { named: /* @__PURE__ */ new Map(), wildcards: [] };176  }177  let moduleInfo = parseResult.module;178  if (!moduleInfo)179    return { named: /* @__PURE__ */ new Map(), wildcards: [] };180  let named = /* @__PURE__ */ new Map(), wildcards = [];181  for (let staticExport of moduleInfo.staticExports)182    for (let entry of staticExport.entries) {183      if (!entry.moduleRequest)184        continue;185      let specifier = entry.moduleRequest.value;186      if (entry.exportName.kind === "None") {187        wildcards.push(specifier);188        continue;189      }190      let exportedName = entry.exportName.name;191      exportedName && (entry.importName.kind !== "Name" || !entry.importName.name || named.set(exportedName, { specifier, importedName: entry.importName.name }));192    }193  return { named, wildcards };194}195function collectDeclaredNames(node, names) {196  if (node.type === "FunctionDeclaration" || node.type === "ClassDeclaration") {197    node.id?.name && names.add(node.id.name);198    return;199  }200  if (node.type === "VariableDeclaration" && Array.isArray(node.declarations))201    for (let declarator of node.declarations) {202      let { id } = declarator;203      id?.type === "Identifier" && id.name && names.add(id.name);204    }205}206async function parseLocalBindings(filePath, source) {207  let parseResult;208  try {209    parseResult = oxcRawParseSync(filePath, source);210  } catch {211    return /* @__PURE__ */ new Set();212  }213  let body = parseResult.program?.body;214  if (!Array.isArray(body))215    return /* @__PURE__ */ new Set();216  let names = /* @__PURE__ */ new Set();217  for (let statement of body) {218    let node = statement;219    node.type === "VariableDeclaration" || node.type === "FunctionDeclaration" || node.type === "ClassDeclaration" ? collectDeclaredNames(node, names) : node.type === "ExportNamedDeclaration" && node.declaration && !node.source && collectDeclaredNames(node.declaration, names);220  }221  return names;222}223async function parseReExports(filePath, source) {224  let parseResult;225  try {226    parseResult = oxcRawParseSync(filePath, source);227  } catch {228    return /* @__PURE__ */ new Map();229  }230  let moduleInfo = parseResult.module;231  if (!moduleInfo)232    return /* @__PURE__ */ new Map();233  let map = /* @__PURE__ */ new Map();234  for (let staticExport of moduleInfo.staticExports)235    for (let entry of staticExport.entries) {236      if (entry.isType || !entry.moduleRequest || entry.exportName.kind === "None")237        continue;238      let exportedName = entry.exportName.name;239      if (!exportedName)240        continue;241      let specifier = entry.moduleRequest.value;242      if (entry.importName.kind !== "Name" || !entry.importName.name)243        continue;244      let importedName = entry.importName.name;245      map.set(exportedName, { specifier, importedName });246    }247  return map;248}249export {250  disposeOxcParsePool,251  parseBarrelInfo,252  parseLocalBindings,253  parseReExports,254  parseWithOxc255};256 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai