npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cache-arena

v0.2.0

Published

A benchmark harness for JavaScript/TypeScript caches: hit-ratio miss-ratio curves against Belady's OPT and throughput with confidence intervals, across standard synthetic workloads and real traces, with markdown tables and SVG charts. Reference policies (

Readme

cache-arena

A benchmark harness for JavaScript and TypeScript caches. It measures the two things that actually matter about a cache, on the workloads that actually stress one, and reports them the way the literature does, so you can put any cache on the same axes as every other and show the result rather than assert it.

Two axes, kept separate on purpose:

  • Hit ratio as a function of cache size (the miss-ratio curve, MRC), with size expressed as a fraction of the workload's footprint and Belady's OPT as the optimal ceiling. This axis is deterministic: a simulation, not a timing, so it is exactly reproducible.
  • Throughput (ops/sec) with warmup, repeated trials, and a 95% confidence interval. This axis is noisy, and is treated as such.

The "arena" is the point: a cache means little measured alone. cache-arena lines the contenders up against each other and against OPT, on identical seeded workloads, and reports the standings.

It is deliberately not tied to any one cache. It ships reference implementations of the standard policies, adapters for the popular npm caches, and a bring-your-own-cache interface.

Status: early. The core (workloads, reference policies, adapters, OPT, MRC and throughput) is here and validated; real-trace ingestion, SVG charts, and the full CLI are landing next.

Install

npm install cache-arena

cache-arena has zero runtime dependencies. Competitor caches are loaded lazily, so you install only the ones you want to benchmark.

Quick start

import {
  standardWorkloads,
  referencePolicies,
  competitors,
  missRatioCurves,
} from "cache-arena";

const workloads = standardWorkloads(); // Zipf sweep, scan, loop, shift, two-pool
const { subjects } = await competitors(); // whichever npm caches are installed

const result = missRatioCurves({
  subjects: [...referencePolicies(), ...subjects],
  workloads,
  includeOpt: true, // add the Belady optimal line
});

Each result.cells entry is { workload, subject, fraction, size, hitRatio }: hit ratio for one cache, on one workload, at one cache size (a fraction of that workload's distinct-key footprint).

Concepts

  • Workload: a reference stream of keys plus its footprint (distinct keys). The synthetic generators are seeded, so a run is identical on any machine. standardWorkloads(seed) (or --seed n) re-draws the whole suite at another seed, to confirm a ranking holds rather than being a lucky draw.
  • Subject: a named cache under test. make(capacity) returns a fresh cache behind a uniform { has, get, set } surface.
  • Fraction-of-footprint sizing: a hit ratio is meaningless without the ratio of cache size to working set, so sizes are set as fractions of each workload's footprint (the convention S3-FIFO and SIEVE report at, 0.1% and 10%).
  • OPT: Belady's offline optimal, the minimum miss ratio achievable on a trace at a given size. The line every real policy is measured against.

Reference policies

Correct, readable implementations, useful as benchmark baselines and as documentation of what each algorithm is:

FIFO, LRU, LFU, Random, CLOCK, SIEVE (NSDI'24), and S3-FIFO (SOSP'23). W-TinyLFU is intentionally not reimplemented here: benchmark a real one (koffein, or the transitory package) through an adapter.

Bring your own cache

import { adapter } from "cache-arena";

const mine = adapter({
  name: "my-cache",
  policy: "custom",
  make: (capacity) => new MyCache(capacity), // needs get / set / has
  // miss: null,   // if your cache signals a miss with something other than undefined
});

Roadmap

  • [x] Synthetic workloads, reference policies, competitor adapters, OPT, MRC, throughput
  • [x] Real-trace ingestion (newline keys, CSV key column)
  • [x] SVG charts (MRC curves + OPT, throughput bars) and markdown report output
  • [x] CLI (cache-arena bench / list), with --seed for robustness runs
  • [ ] A config file for the CLI
  • [ ] More policies (ARC, LIRS)

Methodology and credits

The design follows the standard cache-evaluation methodology (miss-ratio curves, fraction-of-footprint sizing, Belady's optimal, separated efficiency and throughput axes, seeded and repeated). Reference algorithms and their sources:

  • L. A. Belady, "A Study of Replacement Algorithms for a Virtual-Storage Computer," IBM Systems Journal 5(2), 1966 (OPT).
  • J. Yang et al., "FIFO queues are all you need for cache eviction," SOSP 2023 (S3-FIFO).
  • Y. Zhang et al., "SIEVE is Simpler than LRU," NSDI 2024 (SIEVE).
  • N. Megiddo, D. Modha, "ARC," FAST 2003; G. Einziger et al., "TinyLFU," ACM ToS 2017; and the trace-driven tradition of ARC/LIRS and the libCacheSim / Caffeine simulators.

License

MIT (c) David Estevez