You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: optimize FileMetaReader hot path and EncoderReader map sizing (#50020)
FileMetaReader.Next() is called for every line harvested by filebeat.
Replace DeepUpdate (recursive map merge) and dotted-key Put
("log.file.device_id") with direct map assignment. Lazy-cache the
per-file metadata (path, device_id, inode, fingerprint) on first call
since these values are constant for the file's lifetime.
The cached interface{} values are copied via maps.Copy without
re-boxing, which is where the alloc savings come from. The cache is
built into a local variable and only assigned on success, so a failed
setFileSystemMetadata retries on the next call.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* perf: pre-size Fields map in EncoderReader to avoid grow on first write
EncoderReader.Next() creates a Fields map for every line. Changing
from mapstr.M{} (capacity 0) to make(mapstr.M, 1) avoids a runtime
map grow when the first downstream consumer writes into it. Benefits
all inputs using EncoderReader: filestream, legacy log, and S3.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: add changelog fragment and resolve lint issues
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: remove changelog fragment, using skip-changelog label
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test: use require.IsType and consolidate benchmark into metafields_test.go
Replace bare type assertion + require.True(ok) patterns with require.IsType
in metafields_other_test.go and metafields_windows_test.go. Move benchmark
functions from metafields_bench_test.go into metafields_test.go and delete
the separate bench file, following the one-test-file-per-processor principle.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: use comma-ok type assertions to satisfy errcheck linter
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* perf: exact cachedMeta pre-sizing via platformFileFields constant
Add a platformFileFields constant to each platform file (2 on non-Windows,
3 on Windows) so metafields.go can compute the exact map capacity without
over-allocating. Add TestCachedMetaSizing on both platforms to verify the
pre-allocation matches the actual entry count. Also document that the direct
log key assignment is intentional, and fix TestMetaFieldsOwnerAndGroup to
use the platform-correct group name (wheel on macOS, root on Linux).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix testifylint: use require.Len instead of len() comparison
The linter requires require.Len(t, x, n) instead of
require.Equal(t, n, len(x)).
Assisted-By: Cursor
Made-with: Cursor
* fix testifylint: use require.Len in windows test file
Same fix as previous commit, but for the Windows-specific test.
Assisted-By: Cursor
Made-with: Cursor
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments