Skip to main content

HuggingFace Space Worker 分布式调度系统

Project description

HFS v3 - SET 索引优化版本

基于 v2 的优化版本,主要改进:

优化内容

1. SET 索引优化

  • 新增 hfs:project:{proj}:spaces:active SET 索引
  • 新增 hfs:account:{user}:spaces:active SET 索引
  • Lua 脚本原子维护 SET(bind/transition)
  • get_account_space_count 从 O(S) 降到 O(1)

2. Admin CLI Pipeline 优化

  • space list / account list 使用 Pipeline 批量获取
  • 减少网络往返,提升响应速度

3. 性能提升

  • select_account: 26s → 3s
  • space list (db6): 18s → 14s
  • 支持 Space 数量: ~100 → 10000+

目录结构

v3/
├── hfs/                    # 核心代码
│   ├── state.py            # SET 索引 Lua 脚本
│   ├── account.py          # O(1) 账号查询
│   ├── admin/              # CLI 命令
│   └── ...
├── tools/                  # 实用工具
│   ├── view_space_logs.py  # 查看 HF 原生日志
│   ├── chaos_test.py       # 混沌测试
│   └── multi_project_test.py  # 多项目测试
├── publish-tools/          # 发布脚本
└── docs/                   # 文档

使用

环境配置

# v3 使用独立的 Redis db
export HFS_REDIS_URL="redis://...../7"  # db7

迁移 SET 索引

# 首次部署需要构建 SET 索引
python tools/migrate.py --redis-url $HFS_REDIS_URL set-index

# 验证一致性
python tools/migrate.py --redis-url $HFS_REDIS_URL verify

运行测试

# 混沌测试
python tools/chaos_test.py

# 多项目测试
python tools/multi_project_test.py

与 v2 的区别

特性 v2 v3
Redis DB db6 db7
账号查询 O(S) scan O(1) SET
CLI 性能 逐个 GET Pipeline
数据结构 无索引 SET 索引

发布

# Git 发布
cd publish-tools && ./publish-git.sh hfs-v3 v0.1.0

# PyPI 发布
./publish-obfuscated.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mp_hfs-3.0.3.tar.gz (53.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mp_hfs-3.0.3-py3-none-any.whl (64.2 kB view details)

Uploaded Python 3

File details

Details for the file mp_hfs-3.0.3.tar.gz.

File metadata

  • Download URL: mp_hfs-3.0.3.tar.gz
  • Upload date:
  • Size: 53.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mp_hfs-3.0.3.tar.gz
Algorithm Hash digest
SHA256 bab03e4dedb6416d555052196d0c0e3dac844c56afcb139a86440a473dcb1c20
MD5 db43b3f463c889f35a57283f4132a741
BLAKE2b-256 b50b8006e3f19b6d3b01af7b18e523ca4b4d190a1f46222d80b87b07dd34fb8b

See more details on using hashes here.

File details

Details for the file mp_hfs-3.0.3-py3-none-any.whl.

File metadata

  • Download URL: mp_hfs-3.0.3-py3-none-any.whl
  • Upload date:
  • Size: 64.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mp_hfs-3.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 681776a966a522c478c368f1b97b6f4b7c749f9e47b15f9d80bb459a37c0048a
MD5 5b15c37b344b40d9c6e93474dbee9c3b
BLAKE2b-256 8c8ed04fb70927dc5045a9e1d6280658cc85005800e0f48fff44a237fe3a11be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page