Skip to content

app/vlinsert/insertutil: optimize LogMessageProcessor#1021

Merged
valyala merged 85 commits intomasterfrom
lmp-atomics
Feb 5, 2026
Merged

app/vlinsert/insertutil: optimize LogMessageProcessor#1021
valyala merged 85 commits intomasterfrom
lmp-atomics

Conversation

@vadimalekseev
Copy link
Member

Describe Your Changes

Before this change, the logMessageProcessor incremented two global atomics for each inserted row, causing high contention and bottlenecking throughput on multi-core systems. This commit switches to per-flush atomic updates, significantly reducing the overhead.

goos: linux
goarch: amd64
pkg: github.com/VictoriaMetrics/VictoriaLogs/app/vlinsert/insertutil
cpu: AMD Ryzen 9 5950X 16-Core Processor
          │   old.txt   │               new.txt               │
          │   sec/op    │   sec/op     vs base                │
AddRow-32   71.23n ± 2%   53.84n ± 5%  -24.41% (p=0.000 n=30)

          │   old.txt    │               new.txt                │
          │     B/s      │     B/s       vs base                │
AddRow-32   6.341Gi ± 2%   8.389Gi ± 5%  +32.30% (p=0.000 n=30)

          │  old.txt   │              new.txt              │
          │    B/op    │   B/op    vs base                 │
AddRow-32   73.50 ± 7%   0.00 ± ?  -100.00% (p=0.000 n=30)

          │  old.txt   │            new.txt             │
          │ allocs/op  │ allocs/op   vs base            │
AddRow-32   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=30) ¹
¹ all samples are equal

Checklist

The following checks are mandatory:

Before this change, the logMessageProcessor incremented two global atomics for each inserted row, causing high contention and bottlenecking throughput on multi-core systems. This commit switches to per-flush atomic updates, significantly reducing the overhead.
Signed-off-by: Aliaksandr Valialkin <valyala@gmail.com>
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

func25 and others added 20 commits February 5, 2026 20:11
…orage

The Storage.getPartitions() returns active partitions with the incremented reference counts.
The Storage.putPartitions() decrements reference counts on the given partitions.

Use these helpers instead of for { ... } loops across multiple paces.
This improves code radability and maintainability a bit.
…ns by passing partition_prefix to /internal/partition/snapshot/create endpoint

This functionality is useful for bulk creation of snapshots for multiple per-day partitions.
For example, partition_prefix=202601 creates snapshots for all the per-day partitions on January 2026.

Use `partition_prefix` argument instead of `name` argument for the `/internal/partition/snapshot/create` endpoint
in order to be consistent with `/internal/force_merge`. Support for the `name` argument for backwards compatibility.

The /internal/partition/snapshot/create returns JSON-encoded list of paths to created snapshots now
instead of a JSON string with a path to a single created snapshot.
…deletion of snapshots older than the given age

While at it, implement /internal/partition/snapshot/delete_stale?max_age=<d> endpoint for deleting snapshots
older than the given max_age=<d>. For example, max_age=1d removes snapshots older than one day.

Updates #829

Thanks to @withlin for the initial implementation at #975
… the commit 0e142e4

There are docs.victoriametrics.com urls in the wild, which start with /VictoriaLogs/ .
These urls lead to 404 pages now. For example, https://docs.victoriametrics.com/VictoriaLogs/FAQ.html#how-does-victorialogs-work
and https://docs.victoriametrics.com/VictoriaLogs/keyConcepts.html#stream-fields .

Fix it by returning back alases for such pages.

Updates VictoriaMetrics/VictoriaMetrics#8602
…dd(1) + sync.WaitGroup.Done()

This improves code readability a bit.
….1-0.20260119142925-34f242a6b861 to v1.134.1-0.20260126232947-e35a9a366c8a
- Reduce the number of arguments and return values at the recursive appendLogFields() function from 8 to 2.

- Reduce the number of arguments and return values at the appendLogField() function at hot path from 7 to 3.

This increases JSON parsing performance by ~10% according to the BenchmarkJSONParserParseLogMessage.
…a map.

This optimizes the performance of LogRows.MustAdd() by ~10%
when len(LogRows.streamFields) < 16 (typical scenario).
In this case linear scan over a slice of strings is faster than map access.

Thanks to @vadimalekseev for the suggestion at #1029 (comment)
…llisions (#1007)

Signed-off-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
…s parsing (#1003)

Signed-off-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
…rtificates reloading (#999)

Signed-off-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
caicancai and others added 23 commits February 5, 2026 20:12
Signed-off-by: cancaicai <2356672992@qq.com>
Signed-off-by: Cancai Cai <77189278+caicancai@users.noreply.github.com>
…...)`

The offset must be subtracted from the _time (or from any other field) instead of adding it,
in order to be consistent with the offset at day_range() and week_range() functions.

This also properly aligns buckets returned from /select/logsql/hits ant /select/logsql/stats_query_range
endpoints when the `offset` query arg is passed to them.
See #1066 (comment)
- Remove the duplicate entry in the docs/victorialogs/CHANGELOG.md

- Add a reference from the docs for ipv4_range to the docs for ipv6_range in the `see also` section,
  so users could discover the related function.

- Remove irrelevant links from the `see also` sections for ipv4_range and ipv6_range filters.

- Use the proper ordering for imports at lib/logstorage/filter_ipv6_range.go :
  - Standard Go packages go first
  - Then the group for improting external pakages
  - Then the group for the packages in the current module

- Allow searching for ipv4 addresses with ipv6_range() filter,
  since ipv4 addresses can be represented as ipv6 addresses ffff:ipv4.

- Simplify the code for tryParseIPv6CIDR() a bit.

- Add tests for tryParseIPv4CIDR() and tryParseIPv6CIDR().

Updates #84
Updates #1049
Signed-off-by: Yury Moladau <yurymolodov@gmail.com>
Signed-off-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Co-authored-by: Roman Khavronenko <roman@victoriametrics.com>
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Signed-off-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
…eserve newlines (#1041)

Signed-off-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
…ange() filters covering ranges, which intersect ipv4 range

This is a follow-up for the commit 9027e92

Updates #84
Updates #1049
….1-0.20260126232947-e35a9a366c8a to v1.135.1-0.20260204143121-09d2ce36e86d

This is needed for reducing memory usage at #1042

The original commit, which should reduce memory usage, is VictoriaMetrics/VictoriaMetrics@09d2ce3
Signed-off-by: Phuong Le <39565248+func25@users.noreply.github.com>
Co-authored-by: Phuong Le <39565248+func25@users.noreply.github.com>
…es (#1045)

Signed-off-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
the code is simplified according to the suggestion from @vadimalekseev at #1045

Updates #1044
@valyala valyala merged commit 841f2e2 into master Feb 5, 2026
3 checks passed
@valyala valyala deleted the lmp-atomics branch February 5, 2026 19:15
@valyala
Copy link
Contributor

valyala commented Feb 5, 2026

@vadimalekseev , thank you for the performance improvement!

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 192 files (changes from recent commits).

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="app/vmui/packages/vmui/src/components/Configurators/QueryEditor/LogsQL/parser.ts">

<violation number="1">
P2: Operator detection now uses the untrimmed part, so tokens like `AND ` or `OR ` (which include the trailing space added during splitting) won’t match and will be misclassified as filters. Trim before checking operators to preserve correct parsing.</violation>
</file>

<file name="app/vlagent/kubernetescollector/file_collector.go">

<violation number="1">
P2: Close the opened file before returning on fingerprint mismatch to avoid leaking file descriptors.</violation>
</file>

<file name="app/vmui/packages/vmui/src/components/Configurators/QueryEditor/LogsQL/utils.ts">

<violation number="1">
P2: The cursor/selection start is always shifted by the comment delta even when the insertion happens after the cursor (e.g., cursor in leading indentation). This makes the caret jump unexpectedly and misplaces the selection. Adjust deltaStart based on whether the cursor is after the insertion point.</violation>
</file>

<file name="app/vmui/packages/vmui/src/pages/OverviewPage/OverviewHits/OverviewHits.tsx">

<violation number="1">
P2: barsCount is used inside the effect but missing from the dependency array, so updates to barsCount won’t refresh the fetched data.</violation>
</file>

<file name="app/vmui/packages/vmui/src/components/Main/ShortcutKeys/ShortcutKeys.tsx">

<violation number="1">
P2: `withHotkey` disables the shortcut, but the tooltip always advertises the F1 hotkey. Consider hiding the shortcut label when `withHotkey` is false to avoid misleading users.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

valyala added a commit that referenced this pull request Feb 5, 2026
…stion performance improvement to the correct place

It was accidentally put into incorrect place in the commit 841f2e2

Updates #1021
@valyala
Copy link
Contributor

valyala commented Feb 5, 2026

FYI, this pull request has been included in VictoriaLogs v1.45.0.

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.