Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c8eeeaa
fixed roaring include error in CLion
cherep58 Sep 25, 2025
5e786dc
fixed linter warnings
cherep58 Sep 25, 2025
8989ed9
refactored tests for relabeler
cherep58 Sep 30, 2025
855d891
refactored stateless relabeler
cherep58 Oct 1, 2025
4e7d1ba
renamed LabelsBuilderStateMap to LabelsBuilder
cherep58 Oct 1, 2025
e79a043
refactored relabeler tests
cherep58 Oct 2, 2025
ea774f2
rewritten test for PerGoroutineRelabelerFixture
cherep58 Oct 2, 2025
087fbbb
refactored PerGoroutineRelabeler
cherep58 Oct 2, 2025
e13b156
fixed clang-tidy warning
cherep58 Oct 2, 2025
42c25d9
Merge branch 'rebuild_heads_container' of https://github.com/deckhous…
cherep58 Oct 2, 2025
ea7a819
used std::string instead of std::ostringstream
cherep58 Oct 2, 2025
a6ffc25
optimized hard_validate function
cherep58 Oct 2, 2025
316d4d0
Merge branch 'rebuild_heads_container' of https://github.com/deckhous…
cherep58 Oct 3, 2025
9ec7715
fixed bug
cherep58 Oct 6, 2025
6a256c8
used reserve_and_write
cherep58 Oct 6, 2025
322cf7b
Merge branch 'rebuild_heads_container' of https://github.com/deckhous…
cherep58 Oct 6, 2025
3e91ef1
extracted stale nan tracking into separate method from relabeling pro…
cherep58 Oct 7, 2025
e8d9411
Merge branch 'rebuild_heads_container' of https://github.com/deckhous…
cherep58 Oct 7, 2025
90080cc
Merge branch 'stalenan_inner_series' of https://github.com/deckhouse/…
cherep58 Oct 7, 2025
21f42c6
fixed bug in RelabelConfig with mutable variable
cherep58 Oct 8, 2025
bef44a3
Merge branch 'stalenan_inner_series' of https://github.com/deckhouse/…
cherep58 Oct 8, 2025
42aa0db
Merge branch 'rebuild_heads_container' of https://github.com/deckhous…
cherep58 Oct 8, 2025
cca2324
Merge branch 'stalenan_inner_series' of https://github.com/deckhouse/…
cherep58 Oct 8, 2025
1f4b045
fixed unit tests
cherep58 Oct 8, 2025
e7ff43c
Merge branch 'rebuild_heads_container' of https://github.com/deckhous…
cherep58 Oct 9, 2025
9b952b1
Merge branch 'stalenan_inner_series' of https://github.com/deckhouse/…
cherep58 Oct 9, 2025
ee32511
Merge branch 'rebuild_heads_container' of https://github.com/deckhous…
cherep58 Oct 9, 2025
367f691
fixed state destruction at GC
cherep58 Oct 9, 2025
2d40a3e
Merge branch 'rebuild_heads_container' of https://github.com/deckhous…
cherep58 Oct 10, 2025
c1eb20c
Merge branch 'rebuild_heads_container' into stalenan_inner_series_impl
cherep58 Oct 15, 2025
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
46 changes: 37 additions & 9 deletions pp/entrypoint/prometheus_relabeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,18 +212,37 @@ extern "C" void prompp_prometheus_per_shard_relabeler_input_relabeling(void* arg
}
}

using StaleNaNsStateDeprecated = PromPP::Prometheus::Relabel::StaleNaNsStateDeprecated;
using StaleNaNsStateDeprecatedPtr = std::unique_ptr<StaleNaNsStateDeprecated>;

extern "C" void prompp_prometheus_relabel_stalenans_state_deprecated_ctor(void* res) {
struct Result {
StaleNaNsStateDeprecatedPtr state;
};

new (res) Result{.state = std::make_unique<StaleNaNsStateDeprecated>()};
}

extern "C" void prompp_prometheus_relabel_stalenans_state_deprecated_dtor(void* args) {
struct Arguments {
StaleNaNsStateDeprecatedPtr state;
};

static_cast<Arguments*>(args)->~Arguments();
}

using StaleNaNsState = PromPP::Prometheus::Relabel::StaleNaNsState;
using StaleNaNsStatePtr = std::unique_ptr<StaleNaNsState>;

extern "C" void prompp_prometheus_relabel_stalenans_state_ctor(void* res) {
extern "C" void prompp_prometheus_relabel_stale_nans_state_ctor(void* res) {
struct Result {
StaleNaNsStatePtr state;
};

new (res) Result{.state = std::make_unique<StaleNaNsState>()};
}

extern "C" void prompp_prometheus_relabel_stalenans_state_dtor(void* args) {
extern "C" void prompp_prometheus_relabel_stale_nans_state_dtor(void* args) {
struct Arguments {
StaleNaNsStatePtr state;
};
Expand All @@ -241,7 +260,7 @@ extern "C" void prompp_prometheus_per_shard_relabeler_input_relabeling_with_stal
CachePtr cache;
LssVariantPtr input_lss;
LssVariantPtr target_lss;
StaleNaNsStatePtr state;
StaleNaNsStateDeprecatedPtr state;
PromPP::Primitives::Timestamp def_timestamp;
};
struct Result {
Expand Down Expand Up @@ -279,7 +298,7 @@ extern "C" void prompp_prometheus_per_shard_relabeler_input_collect_stalenans(vo
PromPP::Primitives::Go::SliceView<PromPP::Prometheus::Relabel::InnerSeries*> shards_inner_series;
PerShardRelabelerPtr per_shard_relabeler;
CachePtr cache;
StaleNaNsStatePtr state;
StaleNaNsStateDeprecatedPtr state;
PromPP::Primitives::Timestamp stale_ts;
};
struct Result {
Expand Down Expand Up @@ -343,7 +362,7 @@ extern "C" void prompp_prometheus_per_shard_relabeler_input_relabeling_with_stal
CachePtr cache;
LssVariantPtr input_lss;
LssVariantPtr target_lss;
StaleNaNsStatePtr state;
StaleNaNsStateDeprecatedPtr state;
PromPP::Primitives::Timestamp def_timestamp;
};
struct Result {
Expand Down Expand Up @@ -676,7 +695,6 @@ extern "C" void prompp_prometheus_per_goroutine_relabeler_input_relabeling_with_
CachePtr cache;
LssVariantPtr input_lss;
LssVariantPtr target_lss;
StaleNaNsStatePtr state;
PromPP::Primitives::Timestamp def_timestamp;
};
struct Result {
Expand All @@ -698,7 +716,7 @@ extern "C" void prompp_prometheus_per_goroutine_relabeler_input_relabeling_with_

const entrypoint::head::ReallocationsDetector reallocation_detector(target_lss);
in->per_goroutine_relabeler->input_relabeling_with_stalenans(input_lss, target_lss, *in->cache, hashdex, in->options, *in->stateless_relabeler, *out,
in->shards_inner_series, in->shards_relabeled_series, *in->state, in->def_timestamp);
in->shards_inner_series, in->shards_relabeled_series, in->def_timestamp);
target_lss.build_deferred_indexes();
out->target_lss_has_reallocations = reallocation_detector.has_reallocations();
},
Expand All @@ -718,7 +736,6 @@ extern "C" void prompp_prometheus_per_goroutine_relabeler_input_relabeling_with_
CachePtr cache;
LssVariantPtr input_lss;
LssVariantPtr target_lss;
StaleNaNsStatePtr state;
PromPP::Primitives::Timestamp def_timestamp;
};
struct Result {
Expand All @@ -739,7 +756,7 @@ extern "C" void prompp_prometheus_per_goroutine_relabeler_input_relabeling_with_
auto& target_lss = std::get<entrypoint::head::QueryableEncodingBimap>(*in->target_lss);

out->ok = in->per_goroutine_relabeler->input_relabeling_with_stalenans_from_cache(input_lss, target_lss, *in->cache, hashdex, in->options, *out,
in->shards_inner_series, *in->state, in->def_timestamp);
in->shards_inner_series, in->def_timestamp);
},
*in->hashdex);
} catch (...) {
Expand Down Expand Up @@ -851,3 +868,14 @@ extern "C" void prompp_prometheus_per_goroutine_relabeler_append_relabeler_serie
entrypoint::handle_current_exception(err_stream);
}
}

void prompp_prometheus_per_goroutine_relabeler_track_stale_nans(void* args) {
struct Arguments {
PromPP::Primitives::Go::SliceView<PromPP::Prometheus::Relabel::InnerSeries*> inner_series;
StaleNaNsStatePtr stale_nans_state;
PromPP::Primitives::Timestamp default_timestamp;
};

const auto in = static_cast<Arguments*>(args);
PromPP::Prometheus::Relabel::PerGoroutineRelabeler::track_stale_nans(in->inner_series, *in->stale_nans_state, in->default_timestamp);
}
35 changes: 31 additions & 4 deletions pp/entrypoint/prometheus_relabeler.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,32 @@ void prompp_prometheus_per_shard_relabeler_dtor(void* args);
*/
void prompp_prometheus_per_shard_relabeler_input_relabeling(void* args, void* res);

/**
* @brief Create StaleNaNsStateDeprecated.
*
* @param res {
* state uintptr // pointer to constructed StaleNaNsStateDeprecated;
* }
*/
void prompp_prometheus_relabel_stalenans_state_deprecated_ctor(void* res);

/**
* @brief Destroy StaleNaNsStateDeprecated.
*
* @param args {
* state uintptr // pointer to StaleNaNsStateDeprecated;
* }
*/
void prompp_prometheus_relabel_stalenans_state_deprecated_dtor(void* args);

/**
* @brief Create StaleNaNsState.
*
* @param res {
* state uintptr // pointer to constructed StaleNaNsState;
* }
*/
void prompp_prometheus_relabel_stalenans_state_ctor(void* res);
void prompp_prometheus_relabel_stale_nans_state_ctor(void* res);

/**
* @brief Destroy StaleNaNsState.
Expand All @@ -179,7 +197,7 @@ void prompp_prometheus_relabel_stalenans_state_ctor(void* res);
* state uintptr // pointer to StaleNaNsState;
* }
*/
void prompp_prometheus_relabel_stalenans_state_dtor(void* args);
void prompp_prometheus_relabel_stale_nans_state_dtor(void* args);

/**
* @brief relabeling incomig hashdex(first stage) with state stalenans.
Expand Down Expand Up @@ -492,7 +510,6 @@ void prompp_prometheus_per_goroutine_relabeler_input_relabeling_from_cache(void*
* cache uintptr // pointer to constructed Cache;
* input_lss uintptr // pointer to constructed input label sets;
* target_lss uintptr // pointer to constructed target label sets;
* state uintptr // pointer to source state
* def_timestamp int64 // timestamp for metrics and StaleNaNs
* }
*
Expand All @@ -517,7 +534,6 @@ void prompp_prometheus_per_goroutine_relabeler_input_relabeling_with_stalenans(v
* cache uintptr // pointer to constructed Cache;
* input_lss uintptr // pointer to constructed input label sets;
* target_lss uintptr // pointer to constructed target label sets;
* state uintptr // pointer to source state
* def_timestamp int64 // timestamp for metrics and StaleNaNs
* }
*
Expand Down Expand Up @@ -589,6 +605,17 @@ void prompp_prometheus_per_goroutine_relabeler_input_transition_relabeling_only_
*/
void prompp_prometheus_per_goroutine_relabeler_append_relabeler_series(void* args, void* res);

/**
* @brief add stale nans to inner series if needed
*
* @param args {
* inner_series []*InnerSeries // InnerSeries
* stale_nan_state uintptr // pointer to source state
* default_timestamp int64 // timestamp for stale_nan samples
* }
*/
void prompp_prometheus_per_goroutine_relabeler_track_stale_nans(void* args);

#ifdef __cplusplus
} // extern "C"
#endif
62 changes: 53 additions & 9 deletions pp/go/cppbridge/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,37 @@ func prometheusRelabelerStateUpdateDtor(relabelerStateUpdate *RelabelerStateUpda
}

//
// StalenansState
// StalenansStateDeprecated
//

func prometheusRelabelStaleNansStateDeprecatedCtor() uintptr {
var res struct {
state uintptr
}

testGC()
fastcgo.UnsafeCall1(
C.prompp_prometheus_relabel_stalenans_state_deprecated_ctor,
uintptr(unsafe.Pointer(&res)),
)

return res.state
}

func prometheusRelabelStaleNansStateDeprecatedDtor(state uintptr) {
args := struct {
state uintptr
}{state}

testGC()
fastcgo.UnsafeCall1(
C.prompp_prometheus_relabel_stalenans_state_deprecated_dtor,
uintptr(unsafe.Pointer(&args)),
)
}

//
// StaleNansState
//

func prometheusRelabelStaleNansStateCtor() uintptr {
Expand All @@ -1731,7 +1761,7 @@ func prometheusRelabelStaleNansStateCtor() uintptr {

testGC()
fastcgo.UnsafeCall1(
C.prompp_prometheus_relabel_stalenans_state_ctor,
C.prompp_prometheus_relabel_stale_nans_state_ctor,
uintptr(unsafe.Pointer(&res)),
)

Expand All @@ -1745,7 +1775,7 @@ func prometheusRelabelStaleNansStateDtor(state uintptr) {

testGC()
fastcgo.UnsafeCall1(
C.prompp_prometheus_relabel_stalenans_state_dtor,
C.prompp_prometheus_relabel_stale_nans_state_dtor,
uintptr(unsafe.Pointer(&args)),
)
}
Expand Down Expand Up @@ -3526,7 +3556,7 @@ func prometheusPerGoroutineRelabelerInputRelabelingFromCache(
// prometheusPerGoroutineRelabelerInputRelabelingWithStalenans wrapper for relabeling incoming
// hashdex(first stage) with state stalenans.
func prometheusPerGoroutineRelabelerInputRelabelingWithStalenans(
perGoroutineRelabeler, statelessRelabeler, inputLss, targetLss, cache, hashdex, sourceState uintptr,
perGoroutineRelabeler, statelessRelabeler, inputLss, targetLss, cache, hashdex uintptr,
defTimestamp int64,
options RelabelerOptions,
shardsInnerSeries []*InnerSeries,
Expand All @@ -3542,7 +3572,6 @@ func prometheusPerGoroutineRelabelerInputRelabelingWithStalenans(
cache uintptr
inputLss uintptr
targetLss uintptr
state uintptr
defTimestamp int64
}{
shardsInnerSeries,
Expand All @@ -3554,7 +3583,6 @@ func prometheusPerGoroutineRelabelerInputRelabelingWithStalenans(
cache,
inputLss,
targetLss,
sourceState,
defTimestamp,
}
var res struct {
Expand All @@ -3578,7 +3606,7 @@ func prometheusPerGoroutineRelabelerInputRelabelingWithStalenans(
// prometheusPerGoroutineRelabelerInputRelabelingWithStalenansFromCache wrapper for relabeling incoming from cache
// hashdex(first stage) with state stalenans.
func prometheusPerGoroutineRelabelerInputRelabelingWithStalenansFromCache(
perGoroutineRelabeler, inputLss, targetLss, cache, hashdex, sourceState uintptr,
perGoroutineRelabeler, inputLss, targetLss, cache, hashdex uintptr,
defTimestamp int64,
options RelabelerOptions,
shardsInnerSeries []*InnerSeries,
Expand All @@ -3591,7 +3619,6 @@ func prometheusPerGoroutineRelabelerInputRelabelingWithStalenansFromCache(
cache uintptr
inputLss uintptr
targetLss uintptr
state uintptr
defTimestamp int64
}{
shardsInnerSeries,
Expand All @@ -3601,7 +3628,6 @@ func prometheusPerGoroutineRelabelerInputRelabelingWithStalenansFromCache(
cache,
inputLss,
targetLss,
sourceState,
defTimestamp,
}
var res struct {
Expand Down Expand Up @@ -3718,3 +3744,21 @@ func prometheusPerGoroutineRelabelerAppendRelabelerSeries(

return res.exception, res.targetLssHasReallocations
}

func prometheusPerGoroutineRelabelerTrackStaleNans(
innerSeries []*InnerSeries,
staleNansState uintptr,
defaultTimestamp int64,
) {
args := struct {
innerSeries []*InnerSeries
staleNansState uintptr
defaultTimestamp int64
}{innerSeries, staleNansState, defaultTimestamp}

testGC()
fastcgo.UnsafeCall1(
C.prompp_prometheus_per_goroutine_relabeler_track_stale_nans,
uintptr(unsafe.Pointer(&args)),
)
}
Loading
Loading