Skip to content

docs: fix broken references and polish README - #321

Merged
1a1a11a merged 4 commits into
developfrom
claude/readme-polish-z95j18
Aug 12, 2026
Merged

docs: fix broken references and polish README#321
1a1a11a merged 4 commits into
developfrom
claude/readme-polish-z95j18

Conversation

@1a1a11a

@1a1a11a 1a1a11a commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

A pass over the README. What started as copy-editing turned up that most of the documented commands don't run as written, so this fixes those first and then polishes the prose around them.

Every command, link, and code sample in the README was executed or resolved against the tree (built with Ninja, run against the shipped sample traces).

Broken things this fixes

The examples referenced traces that aren't in the repo. data/trace.vscsi, data/trace.csv, and data/twitter_cluster52.vscsi don't exist; the shipped traces are data/cloudPhysicsIO.* and data/twitter_cluster52.csv. Every example now points at a real file.

The csv examples fail even with the right filename. The reader stops with detect obj_id is numeric, please specify -t 'obj-id-is-num=1'. Added the option to the csv examples, plus a sentence explaining when it's needed. With it, the csv run reproduces the vscsi run's miss ratio exactly (0.6297), which confirms the documented column mapping is right for cloudPhysicsIO.csv.

Both MRC plotting scripts were broken for any input — separate from the README, and the reason the plotting section couldn't be verified as-is:

  • plot_mrc_size.py only parsed cachesim lines starting with "result", but a result line starts with the trace path (printf("%s %s cache size ...", reader->trace_path, ...)). The parsed mrc was always empty, so the script exited with fail to compute mrc.
  • plot_mrc_time.py parsed stdout for the periodic reports, but cachesim emits those as INFO logs on stderr. The series was always empty and plotting died with IndexError in ts[-1].

Both now produce plots. plot_appr_mrc.py imports pandas, which wasn't in requirements.txt — added.

Smaller reference fixes: the debug guide link (/doc/usage.md/doc/debug.md), the pre-commit hook path (setup-hooks.shsetup_hooks.sh), the Adaptsize link (adaptsize.c is a directory), the Python Release badge whose link pointed at a different org than its image, the unlinked SIEVE(https://sievecache.com), and the oracleGeneral struct field name (timestampclock_time, per oracleGeneralBin.h).

The C library example wasn't a compilable translation unit (no main), and {.cache_size=...} left default_ttl and hashpower zeroed. It now uses default_common_cache_params(), matching test.c. Verified it compiles with the documented gcc line and prints a miss ratio matching cachesim.

The Python plugin example called lcs.SyntheticReader but never imported anything as lcs. Both Python snippets were run against pip install libcachesim; the plugin LRU matches the built-in LRU exactly, which is the point of the example.

Content added

  • The algorithm list was missing about a dozen implemented algorithms (CAR, LIRS, LRU-K, Clock2QPlus, Random/RandomTwo, S3-FIFOd, FIFO-Merge, FIFO-Reinsertion, Size, LRU-Prob, SizeProbabilistic). Added them, and gave each entry the name you actually pass to cachesim — all 29 documented names were run against a trace to confirm they resolve.
  • Noted the build flags for LRB / GLCache / 3LCache (off by default) and that Belady/BeladySize need an oracle trace.
  • Documented the Node.js binding, which had a badge at the top but no section.
  • Linked the documentation index (doc/README.md) and requirements.txt.
  • A runnable traceAnalyzer invocation in the trace analysis section, which previously had prose but no command.

Notes

Structure, tone, and section order are unchanged — this reads as the same README.

Two things I noticed but left alone as out of scope: doc/quickstart_cachesim.md and doc/advanced_lib.md still reference data/trace.vscsi, and cache_init.h has a strstr(trace_path, "data/trace.") heuristic that lowers hashpower for the sample traces and no longer matches any shipped filename. Happy to follow up on either.


Generated by Claude Code

claude added 2 commits August 12, 2026 23:32
The README's examples pointed at files that are not in the repo, so the
documented commands failed when copy-pasted. Fix them and tighten the
surrounding prose.

Correctness fixes:
- point trace examples at the traces that ship in data/
  (cloudPhysicsIO.*, twitter_cluster52.csv) instead of the non-existent
  data/trace.vscsi and data/trace.csv
- add obj-id-is-num to the csv examples; without it the reader stops with
  an error on traces whose object id column is numeric, and note why
- fix the debug guide link (/doc/usage.md -> /doc/debug.md), the
  pre-commit hook path (setup-hooks.sh -> setup_hooks.sh), and the
  Adaptsize link (adaptsize.c is a directory)
- fix the Python Release badge link, which pointed at a different org
  than the badge image, and the unlinked SIEVE URL
- make the library example a compilable translation unit and use
  default_common_cache_params() so ttl/hashpower are initialized
- correct the oracleGeneral struct field name (timestamp -> clock_time)
- import SyntheticReader in the Python plugin example, which used a
  module alias it never defined

Content:
- list the eviction algorithms that were missing (CAR, LIRS, LRU-K,
  Clock2QPlus, Random, S3-FIFOd, FIFO-Merge/Reinsertion, ...) and give
  the name each one is invoked by on the command line
- note the build flags for LRB/GLCache/3LCache and that Belady needs an
  oracle trace
- document the Node.js binding, which had a badge but no section
- link the documentation index and requirements.txt

All commands, links and code samples in the README were executed or
resolved against the tree.
Both scripts documented in the README failed on any trace, independent of
the arguments given:

- plot_mrc_size.py only parsed cachesim output lines starting with
  "result", but a result line starts with the trace path, so the parsed
  mrc was always empty and the script exited with "fail to compute mrc".
  Match on the shape of the result line instead, and tolerate the shorter
  line printed when object sizes are ignored.
- plot_mrc_time.py parsed stdout for the periodic reports, but cachesim
  emits those as INFO logs on stderr, so the series was always empty and
  plotting died in ts[-1] with an IndexError. Scan both streams.

Also add pandas to requirements.txt; plot_appr_mrc.py imports it.
Copilot AI lite review requested due to automatic review settings August 12, 2026 23:33
@1a1a11a
1a1a11a requested a review from haochengxia as a code owner August 12, 2026 23:33

1a1a11a commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

CI is red on macos / clang, but it fails on the base branch too and isn't caused by this PR — this branch only touches README.md, requirements.txt, and two Python plotting scripts, none of which run in that job.

The job dies in the Prepare step, which runs scripts/install_dependency.sh:

[INFO] Setting up macOS dependencies...
Warning: No available formula with the name "google-perftools". Did you mean googletest?
[ERROR] Script failed with exit code 1

setup_macOS() at scripts/install_dependency.sh:127 passes google-perftools to brew, but that's the apt package name (correctly used at lines 105/107 for Ubuntu). Homebrew's tcmalloc formula is gperftools, so brew install exits non-zero and the step fails before CMake ever runs.

The same job fails identically on developb4ae48f and 74bf910, both predating this branch — failing at the same step in ~14s, with ubuntu green. Code Quality Checks and GitGuardian pass here.

I've left it alone since it's unrelated to a README pass and I can't verify a Homebrew change from Linux, but it looks like a one-word fix in setup_macOS(). Happy to send it as a separate PR if you'd like. I'll re-check this PR when the base branch goes green.


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates project documentation and supporting Python plotting scripts to ensure README examples, links, and MRC plotting workflows work against files and behaviors that actually exist in-tree.

Changes:

  • Fixed plot_mrc_time.py to parse periodic cachesim reports from stderr (INFO logs) as well as stdout.
  • Fixed plot_mrc_size.py result-line detection and made byte-miss-ratio parsing resilient when that field is omitted.
  • Updated README commands/links/examples (trace paths, CSV params, library example TU, Python plugin import, Node.js section) and added pandas to requirements.txt.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
scripts/plot_mrc_time.py Parse periodic INFO reports from stderr in addition to stdout so time-series plotting works.
scripts/plot_mrc_size.py Broaden result-line matching and handle missing byte-miss-ratio output.
requirements.txt Add pandas dependency for plot_appr_mrc.py.
README.md Fix broken links/paths and make examples runnable; expand algorithm list and add Node.js binding section.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/plot_mrc_size.py Outdated
Comment on lines 51 to 54
miss_ratio = float(ls[9].strip(","))
byte_miss_ratio = float(ls[13].strip(","))
# byte miss ratio is not reported when object size is ignored
byte_miss_ratio = float(ls[13].strip(",")) if len(ls) > 13 else 0.0
mrc_dict[algo].append((cache_size, miss_ratio, byte_miss_ratio))

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07ee7b8179

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread README.md Outdated
* [LFU](/libCacheSim/cache/eviction/LFU.c) `lfu`, [LFU with dynamic aging](/libCacheSim/cache/eviction/LFUDA.c) `lfuda`
* [ARC](/libCacheSim/cache/eviction/ARC.c) `arc`, [TwoQ](/libCacheSim/cache/eviction/TwoQ.c) `2q`, [CLOCK-PRO](/libCacheSim/cache/eviction/ClockPro.c) `clockpro`, [CAR](/libCacheSim/cache/eviction/CAR.c) `car`, [LIRS](/libCacheSim/cache/eviction/LIRS.c) `lirs`, [Clock2QPlus](/libCacheSim/cache/eviction/Clock2QPlus.c) `clock2qplus`
* [LRU-K](/libCacheSim/cache/eviction/cpp/LRU_K.cpp) `lru-k`, [LRU-Prob](/libCacheSim/cache/eviction/LRUProb.c) `lru-prob`, [Size](/libCacheSim/cache/eviction/Size.c) `size`
* [FIFO-Merge](/libCacheSim/cache/eviction/FIFO_Merge.c) `fifo-merge`, [FIFO-Reinsertion](/libCacheSim/cache/eviction/FIFO_Reinsertion.c) `fifo-reinsertion`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Route FIFO-Reinsertion to the documented implementation

When users pass the newly documented fifo-reinsertion name, create_cache() registers it as Clock_init in libCacheSim/bin/cachesim/cache_init.h:48, even though FIFO_Reinsertion_init is a separate implementation with different batching and retention defaults. The command therefore succeeds but silently measures Clock, potentially mislabeling experimental results; either map the name to FIFO_Reinsertion_init or omit it from this list.

Useful? React with 👍 / 👎.

Comment thread README.md Outdated
---
## Node.js package

Node.js bindings are also available, shipping pre-compiled binaries for Linux (x64) and macOS (x64, ARM64).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the unsupported macOS prebuilt-binary claim

The release workflow only runs on ubuntu-latest, explicitly builds Linux x64, and advertises only Linux x64 in .github/workflows/npm-release.yml:77-80,84-87,113-120; there is no Darwin x64 or ARM64 build job. Consequently macOS installations cannot download either precompiled binary claimed here and instead fall back to node-gyp rebuild, which requires local build dependencies and is not equivalent to the documented precompiled installation experience.

Useful? React with 👍 / 👎.

- plot_mrc_size.py: locate the miss ratio fields by name instead of by
  token index. A result line carries two optional fields (byte miss ratio
  is dropped when object sizes are ignored, cost saving ratio appears when
  the trace has per-request costs), so with --ignore-obj-size on a
  cost-bearing trace index 13 held the cost saving ratio and it was
  silently recorded as the byte miss ratio:
    ... miss ratio 0.8327, cost saving ratio 0.0251, throughput 0.93 MQPS
  Verified against all six result-line shapes cachesim emits.

- README: drop fifo-reinsertion from the eviction list. cache_init.h maps
  that name to Clock_init, so listing it next to FIFO_Reinsertion.c
  claimed an implementation the command does not run.

- README: correct the Node.js platform claim. npm-release.yml builds only
  Linux x64; other platforms fall back to node-gyp rebuild.

1a1a11a commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

All three review findings were valid and are fixed in 51b57c8.

Positional byte_miss_ratio parsing (plot_mrc_size.py) — reproduced it. A result line has two optional fields, so index 13 isn't stable:

# --ignore-obj-size 1 on a trace with per-request costs
../data/cloudPhysicsIO.vscsi LRU cache size 1000, 113872 req, miss ratio 0.8327, cost saving ratio 0.0251, throughput 0.93 MQPS

ls[13] here is 0.0251 — the cost saving ratio, silently recorded as the byte miss ratio, exactly as described. Values are now located by name (cache size <size>, <n> req, miss ratio <mr> and a separate byte miss ratio lookup). Checked against all six shapes cachesim actually emits: with/without byte miss ratio × with/without cost saving ratio × with/without the throughput suffix that single runs add but multi-size runs don't.

fifo-reinsertion — correct, and worse than described: cache_init.h:48 maps that name to Clock_init, and no CLI name maps to FIFO_Reinsertion_init at all, so that implementation is unreachable from cachesim. I've dropped the entry rather than remap the name, since changing the dispatch is a behavioral call for the maintainers. Worth a separate issue if FIFO_Reinsertion is meant to be reachable.

macOS prebuilt binaries — correct, and my mistake: I took the platform list from libCacheSim-node/README.md without checking the workflow. npm-release.yml runs on ubuntu-latest and builds Linux x64 only; its own release notes say "Supported Platforms: Linux x64". Reworded to say Linux x64 ships prebuilt and other platforms fall back to node-gyp rebuild. Note the same overclaim is still in libCacheSim-node/README.md:26-28 — left alone as outside this PR.

macos / clang is still red for the pre-existing Homebrew reason described above, unrelated to these changes.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51b57c8566

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread README.md Outdated
## Usage
### cachesim (a high-performance cache simulator)
After building and installing libCacheSim, `cachesim` should be in the `_build/bin/` directory.
The examples below are run from `_build/`, so the sample traces in [data/](/data/) are at `../data/`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit the _build working-directory claim

Restrict this statement to the commands that actually use _build, because following it for later cachesim subsections makes the documented debug and plotting commands fail: _build has no ./scripts/debug.sh, and cd scripts also targets a nonexistent _build/scripts directory. Either restore the repository root before those examples or document their paths relative to _build.

Useful? React with 👍 / 👎.

Comment thread scripts/plot_mrc_size.py Outdated
Comment on lines 45 to 48
m = RESULT_REGEX.search(line)
if m:
ls = line.split()
curr_dataname = extract_dataname(ls[0])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse result prefixes without splitting trace paths

Capture the trace path and algorithm from the text preceding cache size rather than using line.split(). When --tracepath contains spaces, cachesim prints that path verbatim, so a valid line such as /tmp/my trace.vscsi LRU cache size ... matches this regex but is recorded with dataname my and algorithm trace.vscsi; the resulting MRC is silently mislabeled.

Useful? React with 👍 / 👎.

- install_dependency.sh: brew has no google-perftools formula (that is the
  apt name, used correctly in setup_ubuntu), so setup_macOS exited 1 and
  the macos / clang job failed in Prepare before CMake ran. Homebrew ships
  tcmalloc as gperftools. Checked the rest of the brew line against the
  Homebrew API; the other formulae all resolve.

- plot_mrc_size.py: split the trace path and algorithm off the text before
  "cache size" instead of taking tokens 0 and 1. cachesim prints the path
  verbatim, so a path containing a space was recorded with the wrong
  dataname and algorithm.

- README: the "run from _build/" note applied to the whole cachesim
  section, but the debug and plotting scripts below it run from the
  repository root. Scope the note and say where those run.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c962e0469d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/plot_mrc_size.py
curr_dataname = extract_dataname(ls[0])
m = RESULT_REGEX.search(line)
if m:
prefix = m.group("prefix").rsplit(None, 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve spaces in custom plugin cache names

When pluginCache is run with an eviction parameter such as cache_name=My Cache, plugin_cache.c preserves that value in cache->cache_name, so cachesim emits ... My Cache cache size .... Splitting the prefix at only the final whitespace records the algorithm as Cache and folds My into the trace name, silently mislabeling the generated MRC; either reject whitespace in custom cache names or parse the trace/algorithm boundary without assuming algorithm names are single tokens.

Useful? React with 👍 / 👎.

@1a1a11a
1a1a11a merged commit 7c169cf into develop Aug 12, 2026
8 of 10 checks passed
1a1a11a pushed a commit that referenced this pull request Aug 13, 2026
doc/ referenced data/trace.vscsi, data/trace.csv, data/trace.txt and
data/trace.oracleGeneral in 45 places. The sample traces are
data/cloudPhysicsIO.*, so every command a new user copied out of the
quickstart guides failed on a fresh clone. The README was fixed in #321; this
does the same for doc/. Commands also ran as ./cachesim with a ../data path
that only resolves one directory up from the binary, so they now use
./bin/<tool> from the build directory to match the README.

The library reader examples in doc/advanced_lib.md did not work either.
Compiling them found obj_id_field set to 6 where cloudPhysicsIO.csv puts the
id in field 5, has_header false for a file with a header, and .binary_fmt
(not a field -- it is .binary_fmt_str) with "<3I2H2Q", which errors with
unknown format '3' because the format parser has no repeat counts. Both
snippets now compile and agree exactly with the vscsi reader. The docs also
now say that obj_id_is_num defaults to true, so a caller with string ids must
set it false or every id silently collapses to 0.

.readthedocs.yaml pointed Sphinx at docs/conf.py -- there is no docs/
directory, no conf.py and no .rst anywhere, so every build failed
immediately. Sphinx now runs over the existing Markdown with MyST, so the
sources stay readable on GitHub with no duplication. Getting to zero warnings
(from 96, with fail_on_warning set) meant fixing the docs themselves: API.md
had no headings and had drifted from the headers, advanced_lib.md documented a
simulator API that no longer exists, and performance.md was two empty sections
and one bullet.

The guides embed their plots with raw <img src="/doc/plot/..."> tags, which
resolve on github.com but became site-root paths in the built HTML, so all 18
images 404'd; doc/plot and doc/assets are now copied into the output and the
prefix stripped. The popularity-decay section pointed at a plot that has never
existed in the repo, which is why it was commented out, while the w92 plot
generated for that section sat unreferenced -- it now points at the real file
with a caption describing what the plot actually shows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YUq1vM4g82TkaX2jvLmuQc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants