Skip to content

Fix documentation examples and make the Read the Docs build work - #327

Open
1a1a11a wants to merge 1 commit into
developfrom
claude/polish-2-docs
Open

Fix documentation examples and make the Read the Docs build work#327
1a1a11a wants to merge 1 commit into
developfrom
claude/polish-2-docs

Conversation

@1a1a11a

@1a1a11a 1a1a11a commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Part 2 of 5, split out of #324. Independent — mergeable in any order, though see the note at the bottom on ordering against #329.

Documentation only. No source files are touched.

The examples pointed at files that do not exist

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 a quickstart guide 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, matching the README.

The library examples did not compile

I compiled the reader snippets in doc/advanced_lib.md rather than reading them, which found three separate errors:

  • obj_id_field set to 6, where cloudPhysicsIO.csv puts the id in field 5
  • has_header false for a file that has a header
  • .binary_fmt — not a field; it is .binary_fmt_str — with "<3I2H2Q", which fails with unknown format '3' because the format parser has no repeat counts

Both snippets now compile and run, and all three readers agree exactly, which is what makes the corrected column parameters trustworthy:

vscsi              n_req=113872   miss_ratio=0.6297  first(id=42932745,size=512)
csv (doc)          n_req=113872   miss_ratio=0.6297  first(id=42932745,size=512)
binary (doc)       n_req=113872   miss_ratio=0.6297  first(id=42932745,size=512)

The docs now also state that obj_id_is_num defaults to true. The CLI overrides it to false right after calling set_default_reader_init_params(), so cachesim hashes string ids correctly while a library caller taking the defaults gets the opposite — every non-numeric id silently becomes 0, collapsing distinct objects into one and producing a plausible miss ratio rather than an error. Documented rather than changed, since flipping the default would alter behavior for every existing library caller.

Read the Docs never built

.readthedocs.yaml pointed Sphinx at docs/conf.py. There is no docs/ directory, no conf.py and no .rst anywhere in the repository, so every build failed immediately.

Sphinx now runs over the existing Markdown with MyST, so the sources stay readable on GitHub with no duplicated content. Getting to zero warnings from 96, with fail_on_warning now set, meant fixing the docs themselves: API.md had no headings at all and had drifted badly 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 plots

The guides embed their plots with raw '&lt;img src="/doc/plot/..."&gt;' tags, which resolve on github.com but became site-root paths in the built HTML — all 18 images 404'd on a docs site. doc/plot and doc/assets are now copied into the output and the prefix stripped in the same hook that rewrites the Markdown links.

That left one reference unresolved: twitter_cluster52_10m_popularityDecayLineLog.svg has never existed in the repository, and was inert only because the whole block sat inside an HTML comment. Meanwhile w92_popularityDecayLineLog.svg, generated for exactly that section, sat unreferenced. The section now points at the real file, with a caption rewritten from the plotting script — the old one had been copied from the object-size section and described two plots where the markup had one, and the wrong quantity besides.

18 of 18 images now resolve.

Testing

  • sphinx-build -W clean on this branch alone: 13 pages, zero warnings
  • built HTML checked for image resolution (18/18) and for site-root href/src leftovers (0)
  • every runnable command in the quickstart guides extracted and executed

Ordering

One caveat: doc/quickstart_mrcProfiler.md documents MINISIM behavior that #329 delivers — that it accepts the same algorithm names as cachesim, and that beladySize warns under sampling. If this merges first, that section describes the tool as it will be rather than as it is. Merging #329 first avoids the gap; nothing breaks either way.


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: 48e2983517

ℹ️ 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".

# size the hash table: --hashpower is log2 of the number of entries, default 24
# (16M). Lowering it cuts memory substantially on small traces — replaying the
# sample trace drops from about 106 MB to 8 MB at --hashpower=16
./bin/cachesim ../data/cloudPhysicsIO.vscsi vscsi lru 1gb --hashpower=16

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 --hashpower example

Users copying this new command get an unrecognized-option error rather than the claimed memory reduction. The complete argp/--help option table in libCacheSim/bin/cachesim/cli_parser.c:55-98 defines no hashpower option, and the CLI never propagates such a value into common_cache_params_t; either expose the setting through cachesim or remove this command and the following comparison advice.

Useful? React with 👍 / 👎.

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

This PR updates the project’s Markdown documentation to fix broken example commands/paths, correct and modernize API/library documentation, and make Read the Docs builds succeed by adding a Sphinx+MyST pipeline over the existing doc/ Markdown sources.

Changes:

  • Replace non-existent sample trace filenames/paths in guides and examples with the shipped data/cloudPhysicsIO.* traces and consistent ./bin/<tool> invocation from the build directory.
  • Add Sphinx configuration (doc/conf.py) + RTD config updates to build Markdown via MyST, copy plot/assets into output, and rewrite GitHub-oriented links for a hosted docs site.
  • Substantially revise API and library docs (e.g., doc/API.md, doc/advanced_lib.md, doc/performance.md) to reflect current headers/behavior and remove/repair broken sections.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
FAQ.md Reformat and expand FAQ; update oracleGeneral struct field and add runnable tool examples/links.
doc/requirements.txt Add doc-only Python dependencies for Sphinx/MyST/RTD theme/mermaid.
doc/README.md Add Help section and link to CONTRIBUTING/FAQ/Issues/Discussions.
doc/quickstart_traceUtils.md Fix heading levels and update example trace paths.
doc/quickstart_traceAnalyzer.md Normalize headings, fix example commands/paths, and repair embedded plot reference/caption.
doc/quickstart_mrcProfiler.md Update commands to ./bin/mrcProfiler and add additional MINISIM notes.
doc/quickstart_cachesim.md Update example commands/paths; refresh algorithm links and add notes on obj-id-is-num and --hashpower.
doc/performance.md Replace placeholder content with concrete throughput/build/trace-format/runtime/memory tuning guidance.
doc/memory_usage_profiling.md Adjust code fence language to avoid misleading shell highlighting for non-shell output.
doc/install.md Normalize heading structure across install guide.
doc/index.md Add MyST toctree-based Sphinx entry point and clarify working-directory assumptions for commands.
doc/conf.py New Sphinx config: MyST Markdown build, copy plot/assets, and rewrite GitHub-style links for RTD.
doc/API.md Rewrite/structure the C API reference with updated types/signatures and guidance.
doc/advanced_lib.md Fix reader and simulator examples and update types/signatures.
doc/advanced_lib_extend.md Fix extension workflow links and improve references to existing readers/files.
.readthedocs.yaml Point RTD at doc/conf.py, install doc/requirements.txt, and enable fail_on_warning.
.github/copilot-instructions.md Update guidance about sample traces and proper benchmarking expectations.

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

Comment thread doc/advanced_lib.md Outdated
Comment thread doc/quickstart_mrcProfiler.md Outdated
Comment on lines +82 to +86
`--algo` accepts the same names as `cachesim`, so any built-in algorithm works — ARC, S3FIFO, sieve, twoq, and the rest. See the [README](/README.md#supported-algorithms) for the full list.

`belady` and `beladySize` need a trace that carries future access times, so they only run on an oracle format such as `oracleGeneral` or `lcs`; the profiler says so and stops otherwise.

`beladySize` is additionally approximate under sampling, beyond the usual sampling error, and warns when you ask for it. It ranks candidates by reuse distance, computed as `next_access_vtime - n_req`, but `next_access_vtime` counts requests in the full trace while `n_req` counts only the requests the sampler kept, so the distance comes out inflated. On `cloudPhysicsIO` at a 100 MB cache, sample rate 0.5 puts it 0.0126 away from the unsampled miss ratio, against 0.0003 for `belady` and 0.0023 for LRU. Use `FIX_RATE,1,<threads>` for an exact run, or `belady`, which compares future times directly and is unaffected.
@1a1a11a
1a1a11a force-pushed the claude/polish-2-docs branch from 48e2983 to f5a65c7 Compare August 13, 2026 17:50

@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: f5a65c7bce

ℹ️ 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 doc/quickstart_mrcProfiler.md Outdated

`--algo` accepts the same names as `cachesim`, so any built-in algorithm works — ARC, S3FIFO, sieve, twoq, and the rest. See the [README](/README.md#supported-algorithms) for the full list.

`belady` and `beladySize` need a trace that carries future access times, so they only run on an oracle format such as `oracleGeneral` or `lcs`; the profiler says so and stops otherwise.

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 Reject non-oracle Belady runs before promising validation

At this commit, mrcProfiler contains no oracle-format check before MINISIM calls create_cache_using_plugin() and begins replay. With a non-oracle trace such as the documented vscsi sample, requests retain next_access_vtime == -2; debug builds abort only through Belady_get()'s DEBUG_ASSERT, while release builds can continue and report a meaningless MRC. Either add the promised runtime validation in this commit or avoid documenting the profiler as safely rejecting these inputs.

Useful? React with 👍 / 👎.

Comment thread doc/quickstart_mrcProfiler.md Outdated
./bin/mrcProfiler ../data/cloudPhysicsIO.vscsi vscsi --algo=FIFO --profiler=MINISIM --profiler-params=FIX_RATE,0.01,10 --size=0.1,0.5,10
```

`--algo` accepts the same names as `cachesim`, so any built-in algorithm works — ARC, S3FIFO, sieve, twoq, and the rest. See the [README](/README.md#supported-algorithms) for the full list.

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 Avoid advertising cachesim's case-insensitive algorithm names

MINISIM does not yet accept the same names as cachesim: it constructs <argument>_init and performs a case-sensitive dlsym, whereas cachesim maps names case-insensitively. Consequently, examples explicitly advertised here such as --algo=sieve and --algo=twoq look for nonexistent sieve_init/twoq_init symbols instead of Sieve_init/TwoQ_init and abort. Document the exact symbol-cased names supported by this commit, or land the cachesim-style mapping first.

Useful? React with 👍 / 👎.

@1a1a11a
1a1a11a force-pushed the claude/polish-2-docs branch from f5a65c7 to 9d6a5c6 Compare August 13, 2026 18:07

@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: 9d6a5c6b3c

ℹ️ 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 doc/performance.md
## Runtime options

* `--num-thread=N` — simulations across algorithms and cache sizes are run in parallel, so a sweep costs little more than its slowest single run.
* `--ignore-obj-size 1` — treats every object as size one. Faster, and the right choice when you want object miss ratio rather than byte miss ratio.

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 Do not equate object miss ratio with unit-sized objects

When cache sizes represent byte capacity, this advice changes the experiment rather than merely selecting a metric: read_one_req() in libCacheSim/traceReader/reader.c replaces every obj_size with 1, so the configured capacity effectively becomes an object count. cachesim already reports n_miss / n_req as the object miss ratio while retaining real sizes, so users following this recommendation will measure a different cache model and may draw invalid comparisons.

Useful? React with 👍 / 👎.

1a1a11a commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

Consolidated response to the review comments on this PR.

The csv reader snippet — fixed, and the finding was sharper than it first looked. The snippet used a bare designated initializer, which zeroes every field it does not name; cap_at_n_req, block_size and ignore_size_zero_req all default to something other than zero. It also set has_header without has_header_set, and csv.c:335 auto-detects unless that flag is raised — so the assignment did nothing and the example worked only because detection happened to guess right on this file. It now starts from default_reader_init_params() and raises both _set flags. Compiled and run: 113872 requests, first id 42932745 size 512, matching the vscsi reader exactly.

The mrcProfiler guide — moved, not patched. Two reviewers flagged that it describes MINISIM accepting cachesim's algorithm names and warning on sampled beladySize, neither of which is true at this commit. Both are correct: that behaviour is delivered by #329. Rather than water down the text, doc/quickstart_mrcProfiler.md now belongs to #329, so its documentation lands with the code that makes it true. This PR no longer touches that file.

--hashpower in the cachesim guide — kept here, deliberately. Same class of problem, opposite resolution. I tried moving that block to #329 too, but develop's version of quickstart_cachesim.md still has the old ./cachesim ../data/trace.vscsi paths that this PR rewrites throughout, so the two PRs overlap on the same lines and the split stopped merging cleanly. A clean split is worth more than removing one forward reference, so the block stays here and #329 should merge first. The mrcProfiler guide had no such overlap, which is why it could move.

--ignore-obj-size advice in performance.md — real, not yet fixed. The point is that read_one_req() rewrites every obj_size to 1, so the flag changes the cache model into an object-count cache rather than merely selecting a metric, while cachesim already reports an object miss ratio with real sizes retained. That makes the recommendation actively misleading for anyone comparing results. It should be rewritten or dropped.

Also fixed here: doc/adoption.md, which arrived on develop in #323, carries a BibTeX block whose % comment Pygments' lexer rejects — harmless normally, fatal under the fail_on_warning this PR enables. The comment moved into prose, and adoption.md was added to the toctree so it is reachable in the rendered docs.


Generated by Claude Code

@1a1a11a
1a1a11a force-pushed the claude/polish-2-docs branch from 9d6a5c6 to ae05953 Compare August 14, 2026 20:04

@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: ae059539b2

ℹ️ 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 FAQ.md Outdated

In the sample [cloudPhysicsIO.csv](/data/cloudPhysicsIO.csv), time is in seconds and object size is in bytes.

`next_access_vtime` is a *logical* time: the number of requests between the current request and the next request to the same object, or `-1` when the object is never accessed again. Algorithms that need future information, such as [Belady](/libCacheSim/cache/eviction/Belady.c) and BeladySize, rely on it, which is why they only work on oracle traces.

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 Describe next-access time as an absolute request index

For users constructing or interpreting oracleGeneral traces from this format description, next_access_vtime is the absolute logical index of the next request, not the number of intervening requests: traceConvOracleGeneral.cpp converts it to stat.n_req - stored_vtime, and Belady compares that value directly with the current request count. Encoding a relative distance as documented changes eviction priorities and can silently produce invalid miss ratios.

Useful? React with 👍 / 👎.

Comment thread doc/conf.py
if target.startswith("../"):
target = "/" + target[len("../") :]

return "](%s%s)" % (_REPO_BLOB_URL, target)

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 Rewrite repository directory links with tree URLs

On the new Read the Docs site, every root-absolute repository directory link is rewritten to a GitHub blob URL, although directories require tree URLs. For example, the newly documented /example and /libCacheSim/include/libCacheSim/ targets become .../blob/develop/example and .../blob/develop/libCacheSim/include/libCacheSim/, so readers cannot open those referenced directories; distinguish directory targets when rewriting them.

Useful? React with 👍 / 👎.

@1a1a11a
1a1a11a force-pushed the claude/polish-2-docs branch from ae05953 to a3fca4f Compare August 14, 2026 20:16

@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: a3fca4f04e

ℹ️ 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 doc/README.md
## Developer Documentation
- [Debugging Guide](debug.md)
- [Install & Build](install.md)
- [Contributing](/CONTRIBUTING.md)

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 Point the contributing link at an existing guide

Neither CONTRIBUTING.md nor a case variant exists anywhere in the tracked repository (verified with a repository-wide tree search), so this newly added link returns 404 on GitHub; the same nonexistent target is also linked from the new Sphinx index. Add the guide or point both links to an existing contribution resource.

Useful? React with 👍 / 👎.

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