Repository navigation
feat: compute telemetry statistics instead of regex search - #54
Merged
Merged
Conversation
Parse integer and fraction parts with unsigned from_chars, pad the fraction to scaleDigits, and reject values that would exceed INT64_MAX before multiplying. Negative range is symmetric; INT64_MIN is not supported.
Cover valid values, overflow boundaries, invalid formats, scaleDigits range, GetField and ParseLine. The sample line used by the ParseLine tests is written by hand, not taken from the dataset. Document what each parser function accepts and rejects.
TelemetryStats keeps count, errors, sum, min, max and an overflow flag. Add() takes one value, AddError() counts a rejected line, Merge() combines two results. Sums use __builtin_add_overflow; on overflow only the flag is set, other fields stay valid. ChunkResult now holds ids and stats only, so it can be sent with msg << batch.
FileProcessor::ProcessChunk parses each line with TelemetryParser and updates the chunk stats; chunk boundary handling is unchanged. SendTaskDone sends ChunkResult as a whole, SerializeBatch is removed. Master and tests still use the old ChunkResult fields, so the build is broken until they are updated.
…e status API The session keeps TelemetryStats; on TaskDone the master reads the whole ChunkResult, drops results whose task_id is not in flight, and calls Merge. Keyword, max_results and writing matched lines to a file are removed, so the dispatch and recovery code no longer knows the result fields. GET /api/status returns a stats object with count, errors, sum, min, max, mean, scale and overflow; sum, min and max stay scaled integers. Tests still use the old API and do not build yet.
Describe the engine/computation coupling and the accumulator decision, close items made obsolete by removing regex search, and add issues for failed chunks, min/max with count 0 and the benchmark script.
FakeWorker and TestServer send and read the whole ChunkResult, master tests call StartSearch without a keyword, worker and FileProcessor tests check stats instead of matched lines, with a split at every byte to check that each line is counted once. Add parametrized TelemetryStats::Add tests. Also fix the Pow10 call in SearchController.
Check that AddError counts only errors, that overflow above and below sets the flag without stopping count, and that Merge combines results, keeps values when merging an empty result, carries the overflow flag and detects overflow of the merged sum.
FakeWorker sends the given stats in TaskDone. New master tests check that stats from two chunks are merged, that a duplicate TaskDone does not change them and that a reassigned chunk is counted once. StatsToJson leaves out sum after an overflow; README documents this and the 64-bit integers in the JSON.
kValueScale is computed at compile time next to kValueScaleDigits, with a static_assert that it fits in int64_t. SearchController uses it instead of its own Pow10, FileProcessor checks that the parser's power table gives the same scale, and the unused SendFoundLine declaration is removed.
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.
Summary
LogGrid now computes
count,sum,min,maxandmeanof thevaluecolumn of telemetry CSV files (id,timestamp,channel,value) instead of searching lines with a regex, as decided in the January plan.Changes
TelemetryParserturns a CSV line into a fixed-point value (value × 10¹⁰,int64_t) without going through floating point;FileProcessor::ProcessChunkcomputes the stats of a chunk; chunk boundary handling is unchanged.TelemetryStatswithAdd,AddErrorandMerge, overflow detection with__builtin_add_overflow;ChunkResultholds ids and stats and is sent whole;kValueScaleDigitsandkValueScaledefined once.TelemetryStats; TaskDone drops results whose task is not in flight and callsMerge. Keyword,max_resultsand writing matched lines to a file are removed, so dispatch and recovery code no longer depends on the result fields.POST /api/searchtakespath(andoutputDir);GET /api/status/{id}returns astatsobject.Testing
ch60.csv(637 MB, 14,639,410 lines, 122 chunks) on a laptop with WSL2: every run gave the same sum, count equal to the line count, 0 errors. About 0.4 s without a CPU limit, about 3.0 s with 2 workers × 2 CPU.TelemetryParserturns a CSV line into a fixed-point value (value × 10¹⁰,int64_t) without going through floating point;FileProcessor::ProcessChunkcomputes the stats of a chunk; chunk boundary handling is unchanged.TelemetryStatswithAdd,AddErrorandMerge, overflow detection with__builtin_add_overflow;ChunkResultholds ids and stats and is sent whole;kValueScaleDigitsandkValueScaledefined once.TelemetryStats; TaskDone drops results whose task is not in flight and callsMerge. Keyword,max_resultsand writing matched lines to a file are removed, so dispatch and recovery code no longer depends on the result fields.POST /api/searchtakespath(andoutputDir);GET /api/status/{id}returns astatsobject.Testing
ch60.csv(637 MB, 14,639,410 lines, 122 chunks) on a laptop with WSL2: every run gave the same sum, count equal to the line count, 0 errors. About 0.4 s without a CPU limit, about 3.0 s with 2 workers × 2 CPU.Known limitations
See
KNOWN_ISSUES.md: a chunk whose file the worker cannot open is merged as empty, a too short TaskDone blocks the session, the sum overflows above about 87 copies of channel 60 in one session, andbench/kill_worker.pydoes not work with the statistics API yet.