Elixir Performance Review
Quick Reference
references/ets-patterns.md |
| Binary handling, large messages |
references/memory.md |
| Task patterns, flow control |
references/concurrency.md |
Review Checklist
GenServer
- - [ ] Not a single-process bottleneck for all requests
- [ ] No blocking operations in handle_call/cast
- [ ] Proper timeout configuration
- [ ] Consider ETS for read-heavy state
Memory
- - [ ] Large binaries not copied between processes
- [ ] Streams used for large data transformations
- [ ] No unbounded data accumulation
Concurrency
- - [ ] Task.Supervisor for dynamic tasks (not raw Task.async)
- [ ] No unbounded process spawning
- [ ] Proper backpressure for message producers
Database
- - [ ] Preloading to avoid N+1 queries
- [ ] Pagination for large result sets
- [ ] Indexes for frequent queries
Valid Patterns (Do NOT Flag)
- - Single GenServer for low-throughput - Not all state needs horizontal scaling
- Synchronous calls for critical paths - Consistency may require it
- In-memory state without ETS - ETS has overhead for small state
- Enum over Stream for small collections - Stream overhead not worth it
Context-Sensitive Rules
| Issue | Flag ONLY IF |
|---|
| GenServer bottleneck | Handles > 1000 req/sec OR blocking I/O in callbacks |
| Use streams |
Processing > 10k items OR reading large files |
| Use ETS | Read:write ratio > 10:1 AND concurrent access |
Before Submitting Findings
Load and follow review-verification-protocol before reporting any issue.
Elixir 性能审查
快速参考
references/ets-patterns.md |
| 二进制数据处理、大消息 |
references/memory.md |
| 任务模式、流量控制 |
references/concurrency.md |
审查清单
GenServer
- - [ ] 不是所有请求的单进程瓶颈
- [ ] handle_call/cast中无阻塞操作
- [ ] 配置了适当的超时时间
- [ ] 考虑对读密集型状态使用ETS
内存
- - [ ] 大二进制数据不在进程间复制
- [ ] 大数据转换使用流处理
- [ ] 无无限制的数据累积
并发
- - [ ] 动态任务使用Task.Supervisor(而非原始Task.async)
- [ ] 无无限制的进程创建
- [ ] 消息生产者具备适当的背压机制
数据库
- - [ ] 预加载以避免N+1查询
- [ ] 大结果集使用分页
- [ ] 频繁查询使用索引
有效模式(请勿标记)
- - 低吞吐量的单GenServer - 并非所有状态都需要水平扩展
- 关键路径的同步调用 - 一致性可能要求如此
- 不使用ETS的内存状态 - 对于小状态,ETS有额外开销
- 小集合使用Enum而非Stream - Stream的开销不值得
上下文敏感规则
| 问题 | 仅在以下情况标记 |
|---|
| GenServer瓶颈 | 处理超过1000请求/秒 或 回调中存在阻塞I/O |
| 使用流处理 |
处理超过1万个项目 或 读取大文件 |
| 使用ETS | 读写比例超过10:1 且 存在并发访问 |
提交发现结果前
在报告任何问题前,请加载并遵循审查验证协议。