openevidence-performance-tuning
Performance Tuning for OpenEvidence. Trigger: "openevidence performance tuning".
What this skill does
# OpenEvidence Performance Tuning
## Overview
OpenEvidence's clinical API handles evidence query response times, citation batch retrieval, and complex multi-condition query optimization. Clinical evidence queries can take 2-5 seconds as the system searches across thousands of medical studies and synthesizes responses. Citation batch retrieval for systematic reviews generates heavy load when fetching 50-200 references per query. Caching evidence responses, batching citation fetches, and optimizing query specificity reduces clinician wait times by 50-70% and keeps complex queries within acceptable latency bounds.
## Caching Strategy
```typescript
const cache = new Map<string, { data: any; expiry: number }>();
const TTL = { evidence: 1_800_000, citations: 3_600_000, queries: 300_000 };
async function cached(key: string, ttlKey: keyof typeof TTL, fn: () => Promise<any>) {
const entry = cache.get(key);
if (entry && entry.expiry > Date.now()) return entry.data;
const data = await fn();
cache.set(key, { data, expiry: Date.now() + TTL[ttlKey] });
return data;
}
// Citations are stable (1hr). Evidence summaries update with new studies (30 min).
```
## Batch Operations
```typescript
async function fetchCitationsBatch(client: any, citationIds: string[], batchSize = 25) {
const results = [];
for (let i = 0; i < citationIds.length; i += batchSize) {
const batch = citationIds.slice(i, i + batchSize);
const res = await Promise.all(batch.map(id => client.getCitation(id)));
results.push(...res);
if (i + batchSize < citationIds.length) await new Promise(r => setTimeout(r, 500));
}
return results;
}
```
## Connection Pooling
```typescript
import { Agent } from 'https';
const agent = new Agent({ keepAlive: true, maxSockets: 6, maxFreeSockets: 3, timeout: 30_000 });
// Moderate socket count — evidence queries are sequential, citations parallel
```
## Rate Limit Management
```typescript
async function withRateLimit(fn: () => Promise<any>): Promise<any> {
try { return await fn(); }
catch (err: any) {
if (err.status === 429) {
const retryMs = parseInt(err.headers?.['retry-after'] || '10') * 1000;
await new Promise(r => setTimeout(r, retryMs));
return fn();
}
throw err;
}
}
```
## Monitoring
```typescript
const metrics = { queries: 0, citationFetches: 0, cacheHits: 0, avgLatencyMs: 0, errors: 0 };
function track(op: 'query' | 'citation', startMs: number, cached: boolean) {
metrics[op === 'query' ? 'queries' : 'citationFetches']++;
const lat = Date.now() - startMs;
metrics.avgLatencyMs = (metrics.avgLatencyMs * (metrics.queries - 1) + lat) / metrics.queries;
if (cached) metrics.cacheHits++;
}
```
## Performance Checklist
- [ ] Cache evidence responses with 30-min TTL (studies update periodically)
- [ ] Cache citation metadata with 1-hour TTL (stable once published)
- [ ] Batch citation retrieval in groups of 25 with 500ms pauses
- [ ] Use specific condition + intervention queries instead of broad searches
- [ ] Prefetch commonly queried drug interaction evidence
- [ ] Enable HTTP keep-alive for persistent API connections
- [ ] Monitor average query latency (target < 3s for simple queries)
- [ ] Set client timeout to 30s for complex multi-condition queries
## Error Handling
| Issue | Cause | Fix |
|-------|-------|-----|
| Slow evidence query (> 5s) | Broad multi-condition search | Narrow query to specific condition + intervention |
| 429 on citation batch | Too many parallel citation fetches | Batch to 25, add 500ms delay between groups |
| Stale evidence summary | Cache too long for rapidly evolving topic | Reduce TTL for high-churn topics (e.g., COVID) |
| Timeout on complex query | Multi-study synthesis exceeding limit | Increase timeout to 30s, simplify query scope |
| Missing citations | Study not yet indexed | Retry after 24h, check study publication date |
## Resources
- [OpenEvidence Platform](https://www.openevidence.com)
- OpenEvidence API Docs
## Next Steps
See `openevidence-reference-architecture`.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.