"""Recalculate published rounded cells; this is not an experimental replication.""" import argparse import hashlib import json from decimal import Decimal, localcontext from pathlib import Path import re ROOT = Path(__file__).resolve().parent HALF = Decimal("0.0005") PERCENT_HALF = Decimal("0.005") def require(condition, message): if not condition: raise ValueError(message) def unique_object(pairs): out = {} for key, value in pairs: require(key not in out, "Duplicate JSON key: " + key) out[key] = value return out def load(path): return json.loads(path.read_text(), object_pairs_hook=unique_object) def number(value, places): require(isinstance(value, str) and re.fullmatch(r"\d+\.\d{" + str(places) + r"}", value) is not None, "Expected nonnegative fixed-precision decimal") return Decimal(value) def overlaps(a, b): return max(a[0], b[0]) <= min(a[1], b[1]) def saving(after, before): require(before > 0, "Denominator must be positive") return 100 * (1 - after / before) def bounds(after, before, after_error, before_error, growth=False): require(before > before_error and after >= after_error, "Invalid rounding envelope") low = (after - after_error) / (before + before_error) high = (after + after_error) / (before - before_error) return (100 * (low - 1), 100 * (high - 1)) if growth else ( 100 * (1 - high), 100 * (1 - low)) def display(value): return format(value, ".2f") def interval(values): return [format(value, ".8f") for value in values] def calculate(data): require(data["schemaVersion"] == 1, "Unsupported schema") require(data["columns"] == ["segment", "file", "key", "index", "chunks", "total", "reportedSavingPercent", "reportedIndexOverheadPercent"], "Column identity") require([d["name"] for d in data["datasets"]] == ["FSL", "VM"], "Dataset coverage") rows = [] with localcontext() as ctx: ctx.prec = 40 for dataset in data["datasets"]: raw = {key: number(value, 3) for key, value in dataset["raw"].items()} require(set(raw) == {"file", "key", "index", "total"}, "Raw fields") require(raw["index"] > HALF and raw["total"] > HALF, "Positive raw sizes") require(abs(sum(raw[k] for k in ("file", "key", "index")) - raw["total"]) <= 4 * HALF, "Raw sum mismatch") require([r[0] for r in dataset["rows"]] == ["512KB", "1MB", "2MB", "4MB"], "Segment coverage or duplicate row") for entry in dataset["rows"]: require(len(entry) == 8, "Row width") segment = entry[0] f, k, i, m, total = [number(v, 3) for v in entry[1:6]] reported_saving, reported_index = [number(v, 2) for v in entry[6:]] require(abs(f + k + i + m - total) <= 5 * HALF, "Component sum mismatch") recipe_base = raw["file"] + raw["key"] metadata_after = f + k + m save_bounds = bounds(metadata_after, recipe_base, 3 * HALF, 2 * HALF) index_bounds = bounds(i, raw["index"], HALF, HALF, growth=True) require(overlaps(save_bounds, (reported_saving - PERCENT_HALF, reported_saving + PERCENT_HALF)), "Reported saving incompatible with rounded components") require(overlaps(index_bounds, (reported_index - PERCENT_HALF, reported_index + PERCENT_HALF)), "Reported index growth incompatible with rounding") rows.append({ "dataset": dataset["name"], "segmentLabel": segment, "metadataExcludingIndex": { "before": str(recipe_base), "after": str(metadata_after), "savingPercent": display(saving(metadata_after, recipe_base)), "reportedPercent": entry[6], "roundingEnvelopePercent": interval(save_bounds)}, "metadataIncludingIndex": { "before": str(raw["total"]), "after": str(total), "savingPercent": display(saving(total, raw["total"])), "roundingEnvelopePercent": interval(bounds(total, raw["total"], HALF, HALF))}, "indexOnly": { "before": str(raw["index"]), "after": str(i), "growthPercent": display(100 * (i / raw["index"] - 1)), "reportedPercent": entry[7], "roundingEnvelopePercent": interval(index_bounds)} }) return {"schemaVersion": 1, "kind": "published-rounded-table-arithmetic", "roundingAssumption": "Nearest 0.001 in size cells and 0.01 percentage point in reported rates; envelopes are not confidence intervals.", "dataPayloadIncluded": False, "cases": rows} def markdown(report): lines = [ "# Metadedup: what is inside the saving percentage?", "", "At the FSL 1 MB setting, 97.46% excludes the fingerprint index; the", "published totals give 97.09% when that index is included. Data payload", "is outside both denominators. This is an arithmetic check, not a", "trace replay, storage benchmark or newly measured saving.", "", "## Calculation", "", "Let F be file recipes, K key recipes, I the fingerprint index and M", "deduplicated metadata chunks. Subscripts 0 and 1 denote raw and", "Metadedup values. The source's non-index saving is", "100 * (1 - (F1 + K1 + M1) / (F0 + K0)).", "The inclusive saving is 100 * (1 - Total1 / Total0).", "Index growth is 100 * (I1 / I0 - 1), with its own, much smaller denominator.", "Subtracting index-growth percentage points from the saving is invalid.", "", "| Dataset | Segment label | Saving without index | Saving with index | Index growth from rounded cells |", "| --- | --- | ---: | ---: | ---: |", ] for row in report["cases"]: lines.append("| " + " | ".join([row["dataset"], row["segmentLabel"], row["metadataExcludingIndex"]["savingPercent"] + "%", row["metadataIncludingIndex"]["savingPercent"] + "%", row["indexOnly"]["growthPercent"] + "%"]) + " |") lines += [ "", "## Precision and evidence", "", "Inputs are the eight settings in Table II of the 2019 paper, transcribed", "in table2.json with source URL, access date and PDF hash. Its GB/KB/MB", "labels are retained; no decimal-versus-binary byte conversion is inferred.", "The FSL and VM populations are separate, not pooled observations.", "", "All arithmetic uses decimal strings. Assuming nearest rounding, each", "size cell represents an interval of plus or minus 0.0005 source units;", "each reported rate represents plus or minus 0.005 percentage point.", "The verifier checks interval overlap, not false exact agreement.", "For example the FSL 1 MB index cells imply about 1.08% growth while", "the paper reports 1.07%; these are compatible with the input precision.", "The envelopes in results.json are rounding bounds, not statistical", "confidence intervals or estimates of uncertainty in new deployments.", "", "Run python3 model.py --check and python3 -m unittest test_model.py with", "model.py, test_model.py, table2.json, results.json and RESULTS.md together.", "Run python3 model.py to regenerate only the two derived files.", "", "Source: https://msstconference.org/MSST-history/2019/Research/Metadedup.pdf", "Table II, PDF page 10; Li, Lee, Ren and Zhang, MSST 2019.", "The original traces and storage prototype were not executed here.", "", "The original 2019 prototype and the later distributed-key-management", "extension are different versions; the later README's performance and", "saving claims are not inputs to this calculation.", "", ] return "\n".join(lines) def outputs(folder): source = folder / "table2.json" report = calculate(load(source)) report["inputSha256"] = hashlib.sha256(source.read_bytes()).hexdigest() return {"results.json": json.dumps(report, indent=2) + "\n", "RESULTS.md": markdown(report)} def verify(folder): for name, expected in outputs(folder).items(): require((folder / name).read_text() == expected, "Stale or falsified " + name) if __name__ == "__main__": parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--check", action="store_true") args = parser.parse_args() if args.check: verify(ROOT) else: for name, text in outputs(ROOT).items(): (ROOT / name).write_text(text) print("Eight Table II settings verified; no experimental replication claimed.")