Repository navigation
remove: two memory-monitoring packages nothing imported, one of them a listener - #365
Merged
Merged
Conversation
…a listener
pkg/profiling built a mux with the five standard net/http/pprof handlers plus
/memory/stats, /memory/samples, /memory/gc and /memory/free, and served it from
`Addr: fmt.Sprintf(":%d", port)` — every interface, two mutating handlers, no
authentication anywhere in the package. pkg/memmon is the same idea with the
listener left off: MemoryMonitor, Profiler, leak detection, per-object tracking,
1,464 lines, no importer, and a doc page describing it as a shipped feature with
a Quick Start.
Neither had a Go importer outside its own package. `go build ./...` and
`go vet ./...` are unchanged by removing both, which is the argument: a package
the compiler does not need is a package the documentation should not promise.
Two packages implementing one absent feature is how a reader ends up believing
the feature exists.
v0.11.0 removed `global.enable_pprof` and `global.profile_port` rather than
wiring them, and recorded the reason as "tracked as #245, where the profiling
package's fate is decided with it". This is that decision. Restoring either
setting now means building the server it names, with an authenticated bind that
is not a wildcard — SECURITY.md and the GlobalConfig doc both say so.
Also removed: docs/memory-monitoring.md, its mkdocs.yml nav entry, the
concurrency-patterns.md link and test command, and both .coverage-floors
entries. The gate is what forces the last of those and it was verified by
mutation: leaving `pkg/memmon 51` in place fails with "a floor of 51% is set but
the coverage profile has no data for it", so a deletion cannot half-land.
The floors file's note about pkg/memmon's 51.0%-or-50.6% GC-timing flake was
rewritten into the header as the general lesson rather than deleted with the
entry. The flake was the smaller half of that finding — the test it exposed
accepted either outcome with t.Log("No alerts generated (may be normal...)"), so
deleting the branch under test left it green — and that holds regardless of
which package it happened in.
Closes #245
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #245.
pkg/profilingstarted an HTTP server on a bare:port— which binds everyinterface, not loopback — and served the five standard
net/http/pprofhandlers plus four of its own, two of which (
/memory/gc,/memory/free)mutate process state. No authentication, no bind restriction. That is the
security issue in #245.
pkg/memmonis the same idea with the listener left out: 1,464 lines ofsampling, alerting and profile-writing that reach nothing.
Neither package has an importer.
go build ./...andgo vet ./...produce identical output before and after the deletion, which is the whole
argument for deleting rather than documenting or hardening: there is no
caller to migrate and no behaviour to preserve.
global.profile_portwasalready removed rather than wired; the config doc comment now says that
restoring the setting means building the server too, with an authenticated
non-wildcard bind.
What goes
pkg/profiling/memory.gopkg/profiling/memory_test.gopkg/memmon/monitor.gopkg/memmon/profiler.gopkg/memmon/monitor_test.godocs/memory-monitoring.mdPlus the
mkdocs.ymlnav entry, the two.coverage-floorslines, anddocs/concurrency-patterns.md'sgo test -race ./pkg/memmon/...example,which now names
./internal/vfs/...— a package that exists and is worthrunning the race detector against.
SECURITY.mdsaid no pprof listener is started at any address. That wastrue of the shipped binary and misleading about the repository, since the
code to start one was sitting in
pkg/profiling. It now says there is nolonger any code here that could start one, and points at
go test -cpuprofilefor the legitimate need.The coverage-floor comment is the interesting part
The floors file carried ten lines explaining that
pkg/memmon's floorflaked between 51.0% and 50.6% depending on garbage-collector timing. Both
lines are gone with the package, but the lesson is not, so it moved into the
file header: chasing that flake is what found the larger defect. The varying
statement was an alert branch whose test accepted either outcome —
t.Log("No alerts generated (may be normal...)")— so deleting the branchentirely left the test green. A gate with zero margin is what made that
visible. Widen the test, not the margin.
Verification
go build ./...,go vet ./...— output unchanged by the deletion-short -racesuite greenpkg/memmon 51to.coverage-floorsfails with "a floor of 51% is set but the coverageprofile has no data for it". A half-landed deletion — floors kept,
package gone — cannot pass CI.