Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pp/bare_bones/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <atomic>
#include <cstring>
#include <limits>

#include "preprocess.h"
#include "type_traits.h"
Expand Down
21 changes: 4 additions & 17 deletions pp/go/cppbridge/primitives_lss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cppbridge_test
import (
"context"
"runtime"
"sort"
"testing"

"github.com/prometheus/prometheus/pp/go/model"
Expand Down Expand Up @@ -414,15 +413,9 @@ func (s *QueryableLSSSuite) TestCopyAddedSeries() {
s.lss.CopyAddedSeries(lssCopy)
lssCopy.CopyAddedSeries(lssCopyOfCopy)

// lssCopy will contain lexicographically sorted labels with new IDs.
expectedLabelSets := make([]model.LabelSet, len(s.labelSets))
copy(expectedLabelSets, s.labelSets)
sort.Slice(expectedLabelSets, func(i, j int) bool {
return expectedLabelSets[i].String() < expectedLabelSets[j].String()
})

// Assert
s.Equal(labelSetToCppBridgeLabels(expectedLabelSets), lssCopy.GetLabelSets(s.labelSetIDs).LabelsSets())
// !!!ATTENTION!!! When copying the added series, the order in which the series are added is preserved.
s.Equal(labelSetToCppBridgeLabels(s.labelSets), lssCopy.GetLabelSets(s.labelSetIDs).LabelsSets())
s.Equal(emptyLabelsSets, lssCopyOfCopy.GetLabelSets(s.labelSetIDs).LabelsSets())
}

Expand Down Expand Up @@ -502,14 +495,8 @@ func (s *QueryableLSSSuite) TestCopyAddedSeriesFromSnapshot() {
bitsetSeriesCopy := lssCopy.BitsetSeries()
snapshotCopy.CopyAddedSeries(bitsetSeriesCopy, lssCopyOfCopy)

// lssCopy will contain lexicographically sorted labels with new IDs.
expectedLabelSets := make([]model.LabelSet, len(s.labelSets))
copy(expectedLabelSets, s.labelSets)
sort.Slice(expectedLabelSets, func(i, j int) bool {
return expectedLabelSets[i].String() < expectedLabelSets[j].String()
})

// Assert
s.Equal(labelSetToCppBridgeLabels(expectedLabelSets), lssCopy.GetLabelSets(s.labelSetIDs).LabelsSets())
// !!!ATTENTION!!! When copying the added series, the order in which the series are added is preserved.
s.Equal(labelSetToCppBridgeLabels(s.labelSets), lssCopy.GetLabelSets(s.labelSetIDs).LabelsSets())
s.Equal(emptyLabelsSets, lssCopyOfCopy.GetLabelSets(s.labelSetIDs).LabelsSets())
}
24 changes: 15 additions & 9 deletions pp/series_index/queryable_encoding_bimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,25 +186,26 @@ class QueryableEncodingBimapCopier {
}

void copy_added_series() {
BareBones::Vector<uint32_t> ids;
ids.reserve(source_.size());
std::ranges::copy(ls_id_range_.begin(), ls_id_range_.end(), std::back_inserter(ids));

sorting_index_.sort(ids);
old_new_ids_.clear();
old_new_ids_.reserve(source_.size());

Cache<uint32_t> cache;
cache.reserve(source_.data().label_name_sets_table.size(), source_.data().label_name_sets_table.data().symbols_table.size(), source_.data().symbols_tables);

destination_.reserve(source_);

for (const auto ls_id : ids) {
for (const auto ls_id : ls_id_range_) {
old_new_ids_.emplace_back(ls_id, destination_.next_item_index());
destination_.items_.emplace_back(destination_.data_, source_[ls_id], cache);
}

const auto cmp = sorting_index_.get_comparator();
std::sort(old_new_ids_.begin(), old_new_ids_.end(), [&](const id_pair& a, const id_pair& b) { return cmp(a.old_id, b.old_id); });
}

void copy_ls_id_set() {
for (uint32_t ls_id_new = 0; ls_id_new < destination_.size(); ++ls_id_new) {
destination_.ls_id_set_.emplace_hint_cmp(destination_.ls_id_set_.end(), [&](auto, auto) { return true; }, ls_id_new);
for (const auto& p : old_new_ids_) {
destination_.ls_id_set_.emplace_hint_cmp(destination_.ls_id_set_.end(), [](auto, auto) { return true; }, p.new_id);
}
}

Expand Down Expand Up @@ -250,10 +251,15 @@ class QueryableEncodingBimapCopier {
}

private:
struct id_pair {
uint32_t old_id;
uint32_t new_id;
};

const DecodingTable& source_;
const SortingIndex& sorting_index_;
QueryableEncodingBimap& destination_;
const SeriesIds& ls_id_range_;
BareBones::Vector<id_pair> old_new_ids_;
};

} // namespace series_index
4 changes: 4 additions & 0 deletions pp/series_index/sorting_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ struct SortingIndex {
sort(container.begin(), container.end());
}

PROMPP_ALWAYS_INLINE auto get_comparator() const noexcept {
return [this](uint32_t a, uint32_t b) PROMPP_LAMBDA_INLINE { return index[a] < index[b]; };
}

Vector<uint32_t> index;
};

Expand Down
6 changes: 3 additions & 3 deletions werf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ shell:
- chown -R 64535:64535 /src/
- chown -R 64535:64535 /etc/
- chown -R 64535:64535 /consoles/
- chmod 0700 /src/prometheus
- chmod 0700 /src/promtool
- chmod 0700 /src/prompptool
- chmod 0755 /src/prometheus
- chmod 0755 /src/promtool
- chmod 0755 /src/prompptool
- |
touch /bin/prompp
ln -s /bin/prompp /bin/prometheus
Expand Down
Loading