乐于分享
好东西不私藏

OpenClaw性能调优实战:内存管理、并发控制与资源优化

OpenClaw性能调优实战:内存管理、并发控制与资源优化

🚀 OpenClaw性能调优实战:内存管理、并发控制与资源优化

性能调优概述:构建高效多Agent系统

在多Agent协作的复杂环境中,性能调优是确保系统稳定、高效运行的关键。OpenClaw作为AI助手平台,需要同时处理多个Agent的并发请求、大量数据的处理和复杂的计算任务,因此性能优化尤为重要。

性能调优的核心原则

性能调优的三大支柱

  1. 内存****管理:合理分配和使用内存资源,避免内存泄漏和过度消耗

  2. 并发控制:有效管理并发任务,最大化CPU利用率,避免资源竞争

  3. 资源优化:优化I/O操作、网络通信和计算密集型任务

性能调优的基本原则

  • 测量优先:在优化之前先进行性能测量,确定瓶颈所在

  • 渐进优化:从小的优化开始,逐步改进,避免过度优化

  • 权衡取舍:在性能、内存、复杂度之间找到最佳平衡点

  • 持续监控:性能优化是持续的过程,需要持续监控和调整

性能指标定义

关键性能指标(KPI)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
performance_metrics:response_time:description:"系统响应时间"target:"< 1 second (p95)"measurement:"从请求到响应的时间"throughput:description:"系统吞吐量"target:"> 1000 requests/second"measurement:"单位时间内处理的请求数"memory_usage:description:"内存使用量"target:"< 80% of available memory"measurement:"RSS (Resident Set Size)"cpu_utilization:description:"CPU使用率"target:"< 80% sustained"measurement:"CPU时间百分比"error_rate:description:"错误率"target:"< 0.1%"measurement:"失败请求占总请求的比例"concurrency:description:"并发处理能力"target:"> 100 concurrent agents"measurement:"同时活跃的Agent数量"

性能基准测试

基准测试策略

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
benchmark_strategy:baseline_testing:description:"建立性能基线"metrics: ["response_time""throughput""memory_usage"]duration:"1 hour"load_pattern:"steady"stress_testing:description:"压力测试"metrics: ["error_rate""concurrency""resource_utilization"]duration:"30 minutes"load_pattern:"ramp_up"soak_testing:description:"浸泡测试"metrics: ["memory_leaks""performance_degradation"]duration:"24 hours"load_pattern:"steady"spike_testing:description:"尖峰测试"metrics: ["response_time_under_load""recovery_time"]duration:"10 minutes"load_pattern:"sudden_spike"

内存管理优化:高效利用系统内存

内存管理是性能调优的基础,合理的内存管理能够显著提升系统性能和稳定性。

内存使用分析

内存使用模式识别

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
// 内存使用分析器classMemoryUsageAnalyzer {constructor() {this.heapSnapshots = [];this.memoryTimeline = [];  }asynctakeHeapSnapshot() {const snapshot = await v8.getHeapSnapshot();this.heapSnapshots.push({timestampDate.now(),snapshot: snapshot,usage: process.memoryUsage()    });return snapshot;  }analyzeMemoryLeaks() {if (this.heapSnapshots.length < 2) {thrownewError('Need at least 2 heap snapshots for leak analysis');    }const baseline = this.heapSnapshots[0];const current = this.heapSnapshots[this.heapSnapshots.length - 1];// 比较堆快照,识别内存泄漏const leaks = this.compareHeapSnapshots(baseline.snapshot, current.snapshot);return {baselineUsage: baseline.usage,currentUsage: current.usage,leaks: leaks,growthRate: (current.usage.rss - baseline.usage.rss) / (current.timestamp - baseline.timestamp)    };  }compareHeapSnapshots(baseline, current) {// 实现堆快照比较逻辑const baselineObjects = this.extractObjects(baseline);const currentObjects = this.extractObjects(current);const leaks = [];for (const [type, count] ofObject.entries(currentObjects)) {const baselineCount = baselineObjects[type] || 0;if (count > baselineCount * 1.1) { // 10%增长阈值        leaks.push({type: type,baselineCount: baselineCount,currentCount: count,growth: count - baselineCount        });      }    }return leaks;  }}

内存泄漏检测与修复

常见内存泄漏模式

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
memory_leak_patterns:global_variables:description:"全局变量累积"detection:"监控全局对象大小增长"fix:"定期清理或使用WeakMap"event_listeners:description:"事件监听器未移除"detection:"监控事件监听器数量"fix:"在组件销毁时移除监听器"closures:description:"闭包引用外部变量"detection:"分析闭包中的变量引用"fix:"避免不必要的闭包或手动断开引用"timers:description:"定时器未清除"detection:"监控活动定时器数量"fix:"在适当时候清除定时器"caches:description:"缓存未设置过期"detection:"监控缓存大小增长"fix:"实现LRU缓存或设置TTL"

内存泄漏修复示例

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
// 修复全局变量累积classGlobalVariableManager {constructor() {this.data = newMap();this.cleanupInterval = setInterval(() => {this.cleanupStaleData();    }, 3600000); // 每小时清理一次  }setData(key, value, ttl = 3600000) { // 默认1小时TTLthis.data.set(key, {value: value,expiresAtDate.now() + ttl,createdAtDate.now()    });  }getData(key) {const entry = this.data.get(key);if (!entry) returnnull;if (Date.now() > entry.expiresAt) {this.data.delete(key);returnnull;    }return entry.value;  }cleanupStaleData() {const now = Date.now();for (const [key, entry] ofthis.data.entries()) {if (now > entry.expiresAt) {this.data.delete(key);      }    }  }destroy() {clearInterval(this.cleanupInterval);this.data.clear();  }}// 修复事件监听器泄漏classEventListenerManager {constructor() {this.listeners = newMap();  }addListener(target, event, handler) {if (!this.listeners.has(target)) {this.listeners.set(target, newMap());    }const targetListeners = this.listeners.get(target);if (!targetListeners.has(event)) {      targetListeners.set(event, newSet());    }    targetListeners.get(event).add(handler);    target.addEventListener(event, handler);  }removeListener(target, event, handler) {const targetListeners = this.listeners.get(target);if (targetListeners && targetListeners.has(event)) {const handlers = targetListeners.get(event);      handlers.delete(handler);      target.removeEventListener(event, handler);if (handlers.size === 0) {        targetListeners.delete(event);      }    }  }removeAllListeners(target) {const targetListeners = this.listeners.get(target);if (targetListeners) {for (const [event, handlers] of targetListeners.entries()) {for (const handler of handlers) {          target.removeEventListener(event, handler);        }      }this.listeners.delete(target);    }  }destroy() {for (const target ofthis.listeners.keys()) {this.removeAllListeners(target);    }this.listeners.clear();  }}

内存池与对象复用

内存池实现

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
// 内存池管理器classMemoryPool {constructor(createFn, resetFn, maxSize = 100) {this.createFn = createFn;this.resetFn = resetFn;this.maxSize = maxSize;this.pool = [];  }acquire() {if (this.pool.length > 0) {returnthis.pool.pop();    }returnthis.createFn();  }release(obj) {if (this.pool.length < this.maxSize) {this.resetFn(obj);this.pool.push(obj);    }  }clear() {this.pool = [];  }getSize() {returnthis.pool.length;  }}// 使用内存池优化Agent创建classOptimizedAgentManager {constructor() {this.agentPool = newMemoryPool(() =>newAgent(), // 创建函数(agent) => agent.reset(), // 重置函数50// 最大池大小    );  }asynccreateAgent(config) {const agent = this.agentPool.acquire();    agent.configure(config);return agent;  }asyncdestroyAgent(agent) {this.agentPool.release(agent);  }}

垃圾回收优化

垃圾回收调优

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
# Node.js垃圾回收调优配置garbage_collection_tuning:node_options:-"--max-old-space-size=4096"# 限制老生代空间为4GB-"--max-semi-space-size=128"# 限制新生代半空间为128MB-"--expose-gc"# 暴露GC接口用于手动触发gc_strategies:manual_gc:description:"手动触发GC"use_case:"内存密集型操作后"implementation:"global.gc()"incremental_gc:description:"增量GC"use_case:"避免长时间停顿"implementation:"V8默认启用"parallel_gc:description:"并行GC"use_case:"多核CPU环境"implementation:"V8默认启用"

手动GC触发策略

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
// 手动GC触发器classManualGCTrigger {constructor(threshold = 0.8) {this.threshold = threshold;this.lastGCTime = 0;this.minGCDelay = 60000// 1分钟最小间隔  }shouldTriggerGC() {const usage = process.memoryUsage();const totalMemory = os.totalmem();const usedRatio = usage.heapUsed / totalMemory;const now = Date.now();const timeSinceLastGC = now - this.lastGCTime;return usedRatio > this.threshold && timeSinceLastGC > this.minGCDelay;  }triggerGC() {if (typeofglobal.gc === 'function' && this.shouldTriggerGC()) {console.log('Manual GC triggered');global.gc();this.lastGCTime = Date.now();    }  }// 在内存密集型操作后调用afterMemoryIntensiveOperation() {this.triggerGC();  }}

并发控制优化:最大化系统吞吐量

并发控制是多Agent系统性能的关键,有效的并发控制能够充分利用多核CPU资源,提高系统吞吐量。

工作线程池管理

工作线程池实现

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
// 工作线程池classWorkerThreadPool {constructor(numWorkers = os.cpus().length) {this.numWorkers = numWorkers;this.workers = [];this.taskQueue = [];this.activeTasks = 0;this.maxConcurrentTasks = numWorkers * 2;this.initializeWorkers();  }initializeWorkers() {for (let i = 0; i < this.numWorkers; i++) {const worker = newWorker('./worker.js');      worker.on('message'this.handleWorkerMessage.bind(this));      worker.on('error'this.handleWorkerError.bind(this));this.workers.push({ worker, busyfalse });    }  }asyncexecuteTask(task) {returnnewPromise((resolve, reject) => {this.taskQueue.push({ task, resolve, reject });this.processQueue();    });  }processQueue() {if (this.activeTasks >= this.maxConcurrentTasks || this.taskQueue.length === 0) {return;    }const taskItem = this.taskQueue.shift();const availableWorker = this.workers.find(w => !w.busy);if (availableWorker) {      availableWorker.busy = true;this.activeTasks++;      availableWorker.worker.postMessage({taskIdgenerateUUID(),task: taskItem.task      });// 存储resolve/reject函数以供后续使用      availableWorker.currentTask = taskItem;    } else {// 如果没有可用工作线程,重新加入队列this.taskQueue.unshift(taskItem);    }  }handleWorkerMessage(message) {const worker = this.workers.find(w => w.worker.threadId === message.threadId);if (worker && worker.currentTask) {const { resolve, reject } = worker.currentTask;if (message.error) {reject(newError(message.error));      } else {resolve(message.result);      }      worker.currentTask = null;      worker.busy = false;this.activeTasks--;// 处理下一个任务this.processQueue();    }  }handleWorkerError(error) {console.error('Worker error:', error);// 重启工作线程const workerIndex = this.workers.findIndex(w => w.worker.threadId === error.threadId);if (workerIndex !== -1) {this.workers[workerIndex].worker.terminate();const newWorker = newWorker('./worker.js');      newWorker.on('message'this.handleWorkerMessage.bind(this));      newWorker.on('error'this.handleWorkerError.bind(this));this.workers[workerIndex] = { worker: newWorker, busyfalse };    }  }getStats() {return {numWorkersthis.numWorkers,activeTasksthis.activeTasks,queueLengththis.taskQueue.length,maxConcurrentTasksthis.maxConcurrentTasks    };  }}

异步任务队列优化

异步任务队列实现

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
// 异步任务队列classAsyncTaskQueue {constructor(concurrency = 10, batchSize = 5) {this.concurrency = concurrency;this.batchSize = batchSize;this.queue = [];this.running = 0;this.batchTimeout = null;  }asyncenqueue(task) {returnnewPromise((resolve, reject) => {this.queue.push({ task, resolve, reject });this.processQueue();    });  }processQueue() {if (this.running >= this.concurrency || this.queue.length === 0) {return;    }// 批处理优化if (this.queue.length >= this.batchSize) {this.processBatch();    } else {// 设置批处理超时if (!this.batchTimeout) {this.batchTimeout = setTimeout(() => {this.batchTimeout = null;this.processBatch();        }, 100); // 100ms超时      }    }  }asyncprocessBatch() {const batchSize = Math.min(this.batchSizethis.queue.lengththis.concurrency - this.running);if (batchSize === 0return;const batch = this.queue.splice(0, batchSize);this.running += batchSize;try {// 并行执行批处理任务const promises = batch.map(async (item) => {try {const result = await item.task();          item.resolve(result);        } catch (error) {          item.reject(error);        }      });awaitPromise.all(promises);    } finally {this.running -= batchSize;this.processQueue();    }  }getStats() {return {queueLengththis.queue.length,runningthis.running,concurrencythis.concurrency,batchSizethis.batchSize    };  }}

背压控制机制

背压控制实现

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
// 背压控制器classBackpressureController {constructor(maxQueueSize = 1000, highWaterMark = 0.8) {this.maxQueueSize = maxQueueSize;this.highWaterMark = highWaterMark;this.currentQueueSize = 0;this.paused = false;  }canAcceptTask() {returnthis.currentQueueSize < this.maxQueueSize && !this.paused;  }acceptTask(task) {if (!this.canAcceptTask()) {thrownewError('Queue is full or paused');    }this.currentQueueSize++;this.checkHighWaterMark();return task;  }completeTask() {this.currentQueueSize = Math.max(0this.currentQueueSize - 1);this.checkLowWaterMark();  }checkHighWaterMark() {const utilization = this.currentQueueSize / this.maxQueueSize;if (utilization >= this.highWaterMark && !this.paused) {this.paused = true;this.emit('pause');    }  }checkLowWaterMark() {const utilization = this.currentQueueSize / this.maxQueueSize;if (utilization < this.highWaterMark * 0.5 && this.paused) {this.paused = false;this.emit('resume');    }  }pause() {this.paused = true;this.emit('pause');  }resume() {this.paused = false;this.emit('resume');  }on(event, callback) {if (!this.eventsthis.events = {};if (!this.events[event]) this.events[event] = [];this.events[event].push(callback);  }emit(event, ...args) {if (this.events && this.events[event]) {this.events[event].forEach(callback =>callback(...args));    }  }}

锁与同步优化

无锁数据结构实现

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
// 无锁队列classLockFreeQueue {constructor() {this.head = { valuenullnextnull };this.tail = this.head;  }enqueue(value) {const newNode = { value: value, nextnull };while (true) {const currentTail = this.tail;const currentNext = currentTail.next;if (currentTail === this.tail) {if (currentNext === null) {// 尝试CAS操作if (this.compareAndSet(currentTail, 'next'null, newNode)) {this.compareAndSet(this.tail'tail', currentTail, newNode);return;          }        } else {// 帮助其他线程完成尾部更新this.compareAndSet(this.tail'tail', currentTail, currentNext);        }      }    }  }dequeue() {while (true) {const currentHead = this.head;const currentTail = this.tail;const currentNext = currentHead.next;if (currentHead === this.head) {if (currentHead === currentTail) {if (currentNext === null) {returnnull// 队列为空          }// 帮助其他线程完成尾部更新this.compareAndSet(this.tail'tail', currentTail, currentNext);        } else {const value = currentNext.value;if (this.compareAndSet(this.head'head', currentHead, currentNext)) {return value;          }        }      }    }  }compareAndSet(obj, field, expected, newValue) {if (obj[field] === expected) {      obj[field] = newValue;returntrue;    }returnfalse;  }isEmpty() {returnthis.head === this.tail && this.head.next === null;  }}

资源优化策略:I/O、网络与计算优化

除了内存和并发,I/O操作、网络通信和计算密集型任务也是性能优化的重要方面。

I/O操作优化

I/O批量处理

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
// I/O批量处理器classBatchIOProcessor {constructor(batchSize = 100, maxDelay = 100) {this.batchSize = batchSize;this.maxDelay = maxDelay;this.writeBuffer = [];this.readBuffer = newMap();this.writeTimer = null;this.readTimer = null;  }asyncwrite(file, data) {returnnewPromise((resolve, reject) => {this.writeBuffer.push({ file, data, resolve, reject });if (this.writeBuffer.length >= this.batchSize) {this.flushWriteBuffer();      } elseif (!this.writeTimer) {this.writeTimer = setTimeout(() => {this.writeTimer = null;this.flushWriteBuffer();        }, this.maxDelay);      }    });  }asyncread(file) {returnnewPromise((resolve, reject) => {if (this.readBuffer.has(file)) {// 从缓冲区返回resolve(this.readBuffer.get(file));return;      }// 添加到读取队列if (!this.readBuffer.has(file)) {this.readBuffer.set(file, { pending: [], resolvednull });      }this.readBuffer.get(file).pending.push({ resolve, reject });if (!this.readTimer) {this.readTimer = setTimeout(() => {this.readTimer = null;this.flushReadBuffer();        }, this.maxDelay);      }    });  }asyncflushWriteBuffer() {if (this.writeBuffer.length === 0return;const batch = this.writeBuffer.splice(0this.batchSize);try {// 批量写入const promises = batch.map(async (item) => {await fs.promises.writeFile(item.file, item.data, { flag'a' });return item;      });const results = awaitPromise.allSettled(promises);// 处理结果      results.forEach((result, index) => {const item = batch[index];if (result.status === 'fulfilled') {          item.resolve();        } else {          item.reject(result.reason);        }      });    } catch (error) {// 处理错误      batch.forEach(item => item.reject(error));    }  }asyncflushReadBuffer() {if (this.readBuffer.size === 0return;const filesToRead = Array.from(this.readBuffer.keys()).filter(file =>this.readBuffer.get(file).pending.length > 0    );if (filesToRead.length === 0return;try {// 批量读取const promises = filesToRead.map(async (file) => {const data = await fs.promises.readFile(file, 'utf8');return { file, data };      });const results = awaitPromise.allSettled(promises);// 处理结果      results.forEach((result) => {if (result.status === 'fulfilled') {const{file,data}=result.value;const bufferEntry = this.readBuffer.get(file);// 缓存结果          bufferEntry.resolved = data;// 解决所有待处理的Promise          bufferEntry.pending.forEach(({ resolve }) =>resolve(data));          bufferEntry.pending = [];        } else {const file = filesToRead[results.indexOf(result)];const bufferEntry = this.readBuffer.get(file);// 处理错误          bufferEntry.pending.forEach(({ reject }) =>reject(result.reason));          bufferEntry.pending = [];        }      });    } catch (error) {// 处理错误      filesToRead.forEach(file => {const bufferEntry = this.readBuffer.get(file);        bufferEntry.pending.forEach(({ reject }) =>reject(error));        bufferEntry.pending = [];      });    }  }}

网络通信优化

连接池实现

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
// HTTP连接池classHTTPConnectionPool {constructor(maxConnections = 100, keepAlive = 30000) {this.maxConnections = maxConnections;this.keepAlive = keepAlive;this.connections = newMap();this.activeConnections = 0;  }asyncgetConnection(url) {const key = this.getConnectionKey(url);if (!this.connections.has(key)) {this.connections.set(key, []);    }const pool = this.connections.get(key);// 查找可用连接let connection = pool.find(conn => !conn.inUse && conn.isValid());if (connection) {      connection.inUse = true;return connection;    }// 创建新连接if (this.activeConnections < this.maxConnections) {      connection = awaitthis.createConnection(url);      connection.inUse = true;      pool.push(connection);this.activeConnections++;return connection;    }// 等待可用连接returnnewPromise((resolve, reject) => {const timeout = setTimeout(() => {reject(newError('Connection timeout'));      }, 5000);constcheckConnection = () => {        connection = pool.find(conn => !conn.inUse && conn.isValid());if (connection) {clearTimeout(timeout);          connection.inUse = true;resolve(connection);        } else {setTimeout(checkConnection, 100);        }      };checkConnection();    });  }releaseConnection(connection) {    connection.inUse = false;// 设置keep-alive超时if (connection.keepAliveTimer) {clearTimeout(connection.keepAliveTimer);    }    connection.keepAliveTimer = setTimeout(() => {if (!connection.inUse) {        connection.destroy();this.activeConnections--;// 从池中移除const key = this.getConnectionKey(connection.url);const pool = this.connections.get(key);if (pool) {const index = pool.indexOf(connection);if (index !== -1) {            pool.splice(index, 1);          }        }      }    }, this.keepAlive);  }getConnectionKey(url) {const parsed = newURL(url);return`${parsed.protocol}//${parsed.host}`;  }asynccreateConnection(url) {const agent = new http.Agent({keepAlivetrue,keepAliveMsecsthis.keepAlive,maxSocketsthis.maxConnections    });return {url: url,agent: agent,inUsefalse,isValid() => !agent.destroyed,destroy() => agent.destroy(),keepAliveTimernull    };  }}

计算密集型任务优化

Web Worker计算优化

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
// worker.js - Web Worker文件const { parentPort } = require('worker_threads');parentPort.on('message'async (message) => {try {const { taskId, task } = message;// 执行计算密集型任务const result = awaitperformComputation(task);    parentPort.postMessage({taskId: taskId,result: result,threadIdrequire('worker_threads').threadId    });  } catch (error) {    parentPort.postMessage({taskId: taskId,error: error.message,threadIdrequire('worker_threads').threadId    });  }});asyncfunctionperformComputation(task) {// 根据任务类型执行不同的计算switch (task.type) {case'vector_computation':returnawaitcomputeVectorSimilarity(task.vectors);case'data_processing':returnawaitprocessData(task.data);case'model_inference':returnawaitrunModelInference(task.input);default:thrownewError(`Unknown task type: ${task.type}`);  }}// 主线程中的计算任务调度器classComputationTaskScheduler {constructor() {this.workerPool = newWorkerThreadPool();  }asyncscheduleComputation(task) {returnawaitthis.workerPool.executeTask(async () => {// 执行计算任务returnawaitperformComputation(task);    });  }asyncperformComputation(task) {// 根据任务复杂度选择执行方式if (this.isHeavyComputation(task)) {// 重计算任务使用Web Workerreturnawaitthis.scheduleComputation(task);    } else {// 轻量计算任务直接执行returnawaitperformComputation(task);    }  }isHeavyComputation(task) {// 判断是否为重计算任务switch (task.type) {case'vector_computation':return task.vectors.length > 1000;case'data_processing':return task.data.length > 10000;case'model_inference':returntrue// 模型推理总是重计算default:returnfalse;    }  }}

性能监控与调优工具

有效的性能调优需要强大的监控和分析工具支持。

性能监控仪表板

Prometheus指标暴露

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
// Prometheus指标收集器classPrometheusMetricsCollector {constructor() {this.metrics = {// 内存指标memoryUsagenew prometheus.Gauge({name'openclaw_memory_usage_bytes',help'Memory usage in bytes',labelNames: ['type']      }),// CPU指标cpuUsagenew prometheus.Gauge({name'openclaw_cpu_usage_percent',help'CPU usage percentage'      }),// 请求指标requestDurationnew prometheus.Histogram({name'openclaw_request_duration_seconds',help'Request duration in seconds',buckets: [0.10.512510]      }),// 并发指标activeTasksnew prometheus.Gauge({name'openclaw_active_tasks',help'Number of active tasks'      }),// 队列指标queueLengthnew prometheus.Gauge({name'openclaw_queue_length',help'Task queue length',labelNames: ['queue_name']      })    };  }recordMemoryUsage() {const usage = process.memoryUsage();this.metrics.memoryUsage.set({ type'rss' }, usage.rss);this.metrics.memoryUsage.set({ type'heap_total' }, usage.heapTotal);this.metrics.memoryUsage.set({ type'heap_used' }, usage.heapUsed);  }recordCPUUsage(cpuPercent) {this.metrics.cpuUsage.set(cpuPercent);  }recordRequestDuration(duration) {this.metrics.requestDuration.observe(duration);  }recordActiveTasks(count) {this.metrics.activeTasks.set(count);  }recordQueueLength(queueName, length) {this.metrics.queueLength.set({ queue_name: queueName }, length);  }getMetrics() {return prometheus.register.metrics();  }}

性能分析工具集成

性能分析工具配置

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
# config/profiling.yamlprofiling:enabled:truetools:-name:"clinic"description:"Node.js性能分析工具"commands:doctor:"clinic doctor -- node app.js"flame:"clinic flame -- node app.js"bubbleprof:"clinic bubbleprof -- node app.js"-name:"0x"description:"火焰图生成工具"command:"0x -- node app.js"-name:"v8-profiler"description:"V8内置分析器"sampling_interval:1000# 微秒profiles:cpu:duration:"30s"output:"./profiles/cpu-profile-${timestamp}.cpuprofile"heap:duration:"snapshot"output:"./profiles/heap-snapshot-${timestamp}.heapsnapshot"event_loop:duration:"60s"output:"./profiles/event-loop-${timestamp}.json"

性能分析脚本

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
#!/bin/bash# scripts/profile-performance.shset -ePROFILE_TYPE=${1:-cpu}DURATION=${2:-30}echo"Starting $PROFILE_TYPE profiling for $DURATION seconds..."case$PROFILE_TYPEin  cpu)    clinic doctor -- node app.js &    PID=$!sleep$DURATIONkill$PID    ;;  heap)    node --inspect app.js &    PID=$!sleep 5# 触发堆快照    curl -X POST http://localhost:9229/json/heap-profiling/startsleep$DURATION    curl -X POST http://localhost:9229/json/heap-profiling/stopkill$PID    ;;  flame)    clinic flame -- node app.js &    PID=$!sleep$DURATIONkill$PID    ;;  *)echo"Unknown profile type: $PROFILE_TYPE"exit 1    ;;esacecho"Profiling completed. Check ./profiles/ directory for results."

实战案例:性能调优的实际应用

现在让我们通过一个实际的案例来展示性能调优的应用。

案例背景:AI资讯日报系统性能问题

问题描述: AI资讯日报系统在处理大量文章时出现性能瓶颈:

  • 内存使用量持续增长,最终导致OOM

  • 处理1000篇文章需要30分钟以上

  • 系统响应时间超过10秒

  • 并发处理能力不足,只能同时处理10个任务

性能分析结果

基准测试结果

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
baseline_performance:memory_usage:"2.5GB (growing)"processing_time:"30 minutes for 1000 articles"response_time:"12 seconds (p95)"concurrency:"10 concurrent tasks"error_rate:"5% (mostly timeouts)"

性能瓶颈分析

  1. 内存泄漏:全局缓存未设置TTL,导致内存持续增长

  2. I/O瓶颈:每个文章处理都进行单独的文件读写操作

  3. 并发不足:使用单线程处理,未充分利用多核CPU

  4. 网络瓶颈:HTTP请求未使用连接池,频繁创建连接

优化方案实施

内存优化

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
// 修复内存泄漏classArticleCache {constructor(maxSize = 1000, ttl = 3600000) { // 1小时TTLthis.cache = newLRUCache({ maxSize });this.ttl = ttl;  }set(key, value) {this.cache.set(key, {value: value,expiresAtDate.now() + this.ttl    });  }get(key) {const entry = this.cache.get(key);if (!entry) returnnull;if (Date.now() > entry.expiresAt) {this.cache.delete(key);returnnull;    }return entry.value;  }}

I/O批量优化

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
// 批量I/O处理const batchIO = newBatchIOProcessor(5050);asyncfunctionprocessArticles(articles) {const promises = articles.map(async (article) => {// 批量读取const content = await batchIO.read(article.filePath);// 处理文章const processed = awaitprocessArticle(content);// 批量写入await batchIO.write(article.outputPath, processed);return processed;  });returnawaitPromise.all(promises);}

并发控制优化

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
// 并发任务处理const taskQueue = newAsyncTaskQueue(5020); // 50并发,20批量asyncfunctionprocessArticlesConcurrently(articles) {const promises = articles.map(article =>    taskQueue.enqueue(() =>processSingleArticle(article))  );returnawaitPromise.all(promises);}

网络连接池优化

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
// HTTP连接池const connectionPool = newHTTPConnectionPool(10030000);asyncfunctionfetchArticleContent(url) {const connection = await connectionPool.getConnection(url);try {const response = awaitfetch(url, { agent: connection.agent });returnawait response.text();  } finally {    connectionPool.releaseConnection(connection);  }}

优化效果对比

优化后性能指标

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
optimized_performance:memory_usage:"800MB (stable)"processing_time:"3 minutes for 1000 articles"response_time:"0.8 seconds (p95)"concurrency:"100 concurrent tasks"error_rate:"0.1%"

性能提升总结

  • 内存使用:减少68%,从2.5GB降至800MB,且保持稳定

  • 处理速度:提升10倍,从30分钟降至3分钟

  • 响应时间:改善15倍,从12秒降至0.8秒

  • 并发能力:提升10倍,从10个并发任务到100个

  • 错误率:降低50倍,从5%降至0.1%

最佳实践总结:构建高性能系统

性能调优清单

生产环境性能调优清单

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
performance_tuning_checklist:memory_management:- [x实现LRU缓存并设置TTL- [x监控内存使用并设置告警- [x定期进行堆快照分析- [x配置适当的GC参数concurrency_control:- [x使用工作线程池处理CPU密集型任务- [x实现异步任务队列和批量处理- [x配置合适的并发限制- [x实现背压控制机制io_optimization:- [x实现I/O批量处理- [x使用连接池管理网络连接- [x优化文件系统访问模式- [x实现缓存策略monitoring:- [x配置Prometheus指标收集- [x设置性能告警阈值- [x定期进行性能基准测试- [x建立性能基线

性能维护计划

定期性能维护任务

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
performance_maintenance_schedule:daily:-"检查性能告警"-"审查资源使用趋势"-"验证性能基线"weekly:-"执行性能基准测试"-"分析慢查询和瓶颈"-"优化缓存策略"-"调整并发参数"monthly:-"进行全面性能审计"-"更新性能优化策略"-"测试新的优化技术"-"培训团队性能意识"

性能调优工具集

推荐性能调优工具

  • 内存分析:Chrome DevTools Heap Snapshot, clinic doctor

  • CPU分析:clinic flame, 0x, V8 profiler

  • I/O分析:clinic bubbleprof, strace, iostat

  • 网络分析:Wireshark, tcpdump, netstat

  • 监控工具:Prometheus + Grafana, Datadog, New Relic

结语:性能是持续的追求

性能调优不是一次性的任务,而是一个持续的过程。随着业务需求的变化、数据量的增长和技术的发展,性能优化也需要不断调整和改进。

通过本文介绍的内存管理、并发控制和资源优化技术,您可以构建一个真正高性能、高可用的OpenClaw系统。记住,最好的性能优化不是最复杂的,而是最适合您具体场景的。

现在就开始应用这些性能调优技术吧,让您的OpenClaw系统飞起来!

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-25 00:18:08 HTTP/1.1 GET : https://www.yeyulingfeng.com/a/484151.html
  2. 运行时间 : 0.094081s [ 吞吐率:10.63req/s ] 内存消耗:5,268.24kb 文件加载:145
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=3b8ee6afd4784efca81e1a1143de7c89
  1. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/composer/autoload_static.php ( 6.05 KB )
  7. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/ralouphie/getallheaders/src/getallheaders.php ( 1.60 KB )
  10. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  11. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  12. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  13. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  14. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  15. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  16. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  17. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  18. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  19. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/guzzlehttp/guzzle/src/functions_include.php ( 0.16 KB )
  21. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/guzzlehttp/guzzle/src/functions.php ( 5.54 KB )
  22. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  23. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  24. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  25. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/provider.php ( 0.19 KB )
  26. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  27. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  28. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  29. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/common.php ( 0.03 KB )
  30. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  32. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/alipay.php ( 3.59 KB )
  33. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  34. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/app.php ( 0.95 KB )
  35. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/cache.php ( 0.78 KB )
  36. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/console.php ( 0.23 KB )
  37. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/cookie.php ( 0.56 KB )
  38. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/database.php ( 2.48 KB )
  39. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/filesystem.php ( 0.61 KB )
  40. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/lang.php ( 0.91 KB )
  41. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/log.php ( 1.35 KB )
  42. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/middleware.php ( 0.19 KB )
  43. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/route.php ( 1.89 KB )
  44. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/session.php ( 0.57 KB )
  45. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/trace.php ( 0.34 KB )
  46. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/config/view.php ( 0.82 KB )
  47. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/event.php ( 0.25 KB )
  48. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  49. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/service.php ( 0.13 KB )
  50. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/AppService.php ( 0.26 KB )
  51. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  52. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  53. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  54. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  55. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  56. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/services.php ( 0.14 KB )
  57. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  58. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  59. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  60. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  61. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  62. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  63. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  64. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  65. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  66. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  67. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  68. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  69. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  70. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  71. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  72. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  73. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  74. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  75. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  76. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  77. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  78. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  79. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  80. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  81. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  82. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  83. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  84. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  85. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  86. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  87. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/Request.php ( 0.09 KB )
  88. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  89. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/middleware.php ( 0.25 KB )
  90. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  91. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  92. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  93. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  94. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  95. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  96. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  97. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  98. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  99. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  100. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  101. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  102. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  103. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/route/app.php ( 3.94 KB )
  104. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  105. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  106. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/controller/Index.php ( 9.68 KB )
  108. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/BaseController.php ( 2.05 KB )
  109. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  110. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  111. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  112. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  113. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  114. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  115. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  116. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  117. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  118. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  119. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  120. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  121. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  122. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  123. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  124. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  125. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  126. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  127. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  128. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  129. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  130. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  131. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  132. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  133. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  134. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  135. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/app/controller/Es.php ( 3.30 KB )
  136. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  137. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  138. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  139. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  140. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  141. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  142. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  143. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  144. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/runtime/temp/c935550e3e8a3a4c27dd94e439343fdf.php ( 31.80 KB )
  145. /yingpanguazai/ssd/ssd1/www/wwww.yeyulingfeng.com/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000498s ] mysql:host=127.0.0.1;port=3306;dbname=wenku;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000601s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000473s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.001790s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000515s ]
  6. SELECT * FROM `set` [ RunTime:0.000205s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000589s ]
  8. SELECT * FROM `article` WHERE `id` = 484151 LIMIT 1 [ RunTime:0.001673s ]
  9. UPDATE `article` SET `lasttime` = 1774369088 WHERE `id` = 484151 [ RunTime:0.005189s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 64 LIMIT 1 [ RunTime:0.000310s ]
  11. SELECT * FROM `article` WHERE `id` < 484151 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000391s ]
  12. SELECT * FROM `article` WHERE `id` > 484151 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000403s ]
  13. SELECT * FROM `article` WHERE `id` < 484151 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001004s ]
  14. SELECT * FROM `article` WHERE `id` < 484151 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000718s ]
  15. SELECT * FROM `article` WHERE `id` < 484151 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.000823s ]
0.095862s