chatgpt-web-dev / chatgpt-web

A third-party ChatGPT Web UI page built with Express and Vue3, through the official OpenAI completion API. / 用 Express 和 Vue3 搭建的第三方 ChatGPT 前端页面, 基于 OpenAI 官方 completion API.
https://chatgpt-web.dev
MIT License
1.65k stars 443 forks source link

perf: memory usage optimize #404

Closed BobDu closed 9 months ago

BobDu commented 9 months ago

优化了正式环境运行时的内存占用

Closed: #345 #383

对比了一下 发现 使用 tsup 编译后的 nodejs 应用启动就是会内存占用偏大一点。

另外 使用 pnpm prod 启动和 直接使用 node build/index.js 启动占用的内存也不太一样。前者会多出来一个50MB左右内存消耗的父进程。

从这两个方向优化一下编译启动流程。实测下来内存占用可以从 200MB 优化至 70MB

  1. 后端服务不再使用 tsup 编译 改为使用 tsc
  2. esno 升级为 tsx
  3. 为配合移除 tsup 修复了一些后端服务中部分应该声明为 dependencies 的依赖被错误定义至 devDependencies
  4. 为配合移除 tsup 更新了 eslint 工具链
  5. 修改了 require() 导入语法为 import
vercel[bot] commented 9 months ago

Someone is attempting to deploy a commit to a Personal Account owned by @Kerwin1202 on Vercel.

@Kerwin1202 first needs to authorize it.

Urmi10799 commented 9 months ago

Tested this PR. Works perfectly! Recommend to merge.