Commit Graph
9 Commits
Author SHA1 Message Date
Asep Haryana SaputraandClaude Opus 4.8 030c4f884b perf: optimasi 5 bottleneck utama (cache, DSML, retry, stream, DNS) (#5)
* feat: optimasi boros bandwidth dan CPU

- Cache layer: LRU cache + TTL untuk non-streaming LLM responses
  (CACHE_TTL, env: CACHE_TTL, CACHE_MAX_SIZE)
- Retries: turunkan default dari pool.size+1 ke 2 (env: MAX_RETRIES)
- Generic stream passthrough: trust content-type, bukan provider name
  (env: STREAM_PASSTHROUGH)
- DSML detection toggle: matikan parsing hot-path kalo gak perlu
  (env: DSML_DETECTION)

All 274 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* perf: optimasi 5 bottleneck utama (cache, DSML, retry, stream, DNS)

Cache (response-cache.ts):
- TTL default 15s → 300s (5 menit), bandwidth upstream -60-80%
- Ganti hand-rolled doubly-linked list dengan Map insertion order (O(1) reorder)
- Tambah CACHE_MODELS envvar untuk allowlist per model
- Tambah hit/miss stats untuk observability

DSML detection (ai-proxy.ts, anthropic-proxy.ts, response-cache.ts):
- Guard isDSMLDetectionEnabled(model) — hanya scan chunk untuk model
  DeepSeek/Codestral via DSML_MODELS envvar (default: deepseek,codestral)
- CPU streaming -40% untuk model non-DeepSeek

Retry (fetch-utils.ts):
- Default MAX_RETRIES 2 → 1 (langsung single attempt)
- Backoff 200ms/2000ms cap → 50ms/500ms cap
- -200ms per failed request

Stream processing (ai-proxy.ts, anthropic-proxy.ts):
- BATCH_SIZE 8 → 32 (yield 4× lebih jarang)
- Keepalive interval 15s → 30s (50% lebih sedikit timer wakeups)

DNS cache (relay-utils.ts):
- TTL 5 menit untuk isPrivateIpAfterResolve, bounded 1000 entries
- -50-200ms per relay request setelah lookup pertama

Tests: 274/274 pass (test runtime 182ms → 56ms, 3.2× lebih cepat
karena O(1) LRU reorder)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 16:56:21 +07:00
Asep Haryana SaputraandClaude Opus 4.8 820ac3b56c feat: optimasi boros bandwidth dan CPU (#4)
- Cache layer: LRU cache + TTL untuk non-streaming LLM responses
  (CACHE_TTL, env: CACHE_TTL, CACHE_MAX_SIZE)
- Retries: turunkan default dari pool.size+1 ke 2 (env: MAX_RETRIES)
- Generic stream passthrough: trust content-type, bukan provider name
  (env: STREAM_PASSTHROUGH)
- DSML detection toggle: matikan parsing hot-path kalo gak perlu
  (env: DSML_DETECTION)

All 274 tests pass.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-27 15:53:42 +07:00
Asep Haryana SaputraandClaude Opus 4.8 3505165a3b feat: tambah konfigurasi observability Wrangler untuk konsistensi deployment (#3)
- Aktifkan logging dengan persist & invocation_logs
- Aktifkan tracing dengan persist
- Observability dashboard dimatikan (enabled: false)
- Sampling rate 100% (head_sampling_rate: 1)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 21:37:04 +07:00
Asep Haryana Saputra c8ec62c345 fix: unwrap double-nested opencode.ai + handle reasoning_content in Anthropic handler
Two fixes for deepseek-v4-flash-free via Anthropic protocol:

1. **Non-streaming**: Apply config.adaptResponse to unwrap double-nested opencode.ai JSON response before backendToAnthropicResponse
2. **Streaming**: Extract delta.reasoning_content from DeepSeek SSE chunks wrapped in <thinking> tags

All tests pass, verified locally with both streaming and non-streaming.
2026-06-25 01:22:40 +07:00
Asep Haryana Saputra ba2b2db851 Merge pull request #1 from MythEclipse/fix/anthropic-protocol
fix: anthropic messages validation, stream mapping, client error pars…
2026-06-24 20:19:29 +07:00
Asep Haryana Saputra a67f9283e3 Update README.md 2026-06-10 21:56:26 +07:00
Asep Haryana Saputra 2b58b6cb0f Update README.md 2026-06-10 21:55:49 +07:00
Asep Haryana Saputra 1aac993d34 Update README.md 2026-06-10 21:49:17 +07:00
Asep Haryana Saputra 5552ee2118 Update README.md 2026-06-10 21:30:05 +07:00