faster gaps filling; #2364
Costa Tsaousis (ktsaou) committed
Jun 21, 2017 at 09:03 UTC
6c683211ff2b0a30909f09696ce013cf92d1419e
2 files changed
+21
-17
src/rrdset.c
+20
-17
@@ -731,6 +731,9 @@ static inline size_t rrdset_done_interpolate(
731
ssize_t iterations = (ssize_t)((now_collect_ut - last_stored_ut) / (update_every_ut));
732
if((now_collect_ut % (update_every_ut)) == 0) iterations++;
733
734
+ size_t counter = st->counter;
735
+ long current_entry = st->current_entry;
736
+
737
for( ; next_store_ut <= now_collect_ut ; last_collect_ut = next_store_ut, next_store_ut += update_every_ut, iterations-- ) {
738
#ifdef NETDATA_INTERNAL_CHECKS
739
if(iterations < 0) { error("INTERNAL CHECK: %s: iterations calculation wrapped! first_ut = %llu, last_stored_ut = %llu, next_store_ut = %llu, now_collect_ut = %llu", st->name, first_ut, last_stored_ut, next_store_ut, now_collect_ut); }
@@ -830,12 +833,12 @@ static inline size_t rrdset_done_interpolate(
833
}
834
835
if(unlikely(!store_this_entry)) {
833
- rd->values[st->current_entry] = pack_storage_number(0, SN_NOT_EXISTS);
836
+ rd->values[current_entry] = SN_EMPTY_SLOT; //pack_storage_number(0, SN_NOT_EXISTS);
837
continue;
838
}
839
840
if(likely(rd->updated && rd->collections_counter > 1 && iterations < st->gap_when_lost_iterations_above)) {
838
- rd->values[st->current_entry] = pack_storage_number(new_value, storage_flags );
841
+ rd->values[current_entry] = pack_storage_number(new_value, storage_flags );
842
rd->last_stored_value = new_value;
843
844
#ifdef NETDATA_INTERNAL_CHECKS
@@ -843,8 +846,8 @@ static inline size_t rrdset_done_interpolate(
846
debug(D_RRD_STATS, "%s/%s: STORE[%ld] "
847
CALCULATED_NUMBER_FORMAT " = " CALCULATED_NUMBER_FORMAT
848
, st->id, rd->name
846
- , st->current_entry
847
- , unpack_storage_number(rd->values[st->current_entry]), new_value
849
+ , current_entry
850
+ , unpack_storage_number(rd->values[current_entry]), new_value
851
);
852
#endif
853
@@ -855,58 +858,58 @@ static inline size_t rrdset_done_interpolate(
858
if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG)))
859
debug(D_RRD_STATS, "%s/%s: STORE[%ld] = NON EXISTING "
860
, st->id, rd->name
858
- , st->current_entry
861
+ , current_entry
862
);
863
#endif
864
862
- rd->values[st->current_entry] = pack_storage_number(0, SN_NOT_EXISTS);
865
+ rd->values[current_entry] = SN_EMPTY_SLOT; // pack_storage_number(0, SN_NOT_EXISTS);
866
rd->last_stored_value = NAN;
867
}
868
869
stored_entries++;
870
871
+ #ifdef NETDATA_INTERNAL_CHECKS
872
if(unlikely(rrdset_flag_check(st, RRDSET_FLAG_DEBUG))) {
873
calculated_number t1 = new_value * (calculated_number)rd->multiplier / (calculated_number)rd->divisor;
870
- calculated_number t2 = unpack_storage_number(rd->values[st->current_entry]);
874
+ calculated_number t2 = unpack_storage_number(rd->values[current_entry]);
875
872
- #ifdef NETDATA_INTERNAL_CHECKS
876
calculated_number accuracy = accuracy_loss(t1, t2);
877
debug(D_RRD_STATS, "%s/%s: UNPACK[%ld] = " CALCULATED_NUMBER_FORMAT " FLAGS=0x%08x (original = " CALCULATED_NUMBER_FORMAT ", accuracy loss = " CALCULATED_NUMBER_FORMAT "%%%s)"
878
, st->id, rd->name
876
- , st->current_entry
879
+ , current_entry
880
, t2
878
- , get_storage_number_flags(rd->values[st->current_entry])
881
+ , get_storage_number_flags(rd->values[current_entry])
882
, t1
883
, accuracy
884
, (accuracy > ACCURACY_LOSS) ? " **TOO BIG** " : ""
885
);
883
- #endif
886
887
rd->collected_volume += t1;
888
rd->stored_volume += t2;
889
888
- #ifdef NETDATA_INTERNAL_CHECKS
890
accuracy = accuracy_loss(rd->collected_volume, rd->stored_volume);
891
debug(D_RRD_STATS, "%s/%s: VOLUME[%ld] = " CALCULATED_NUMBER_FORMAT ", calculated = " CALCULATED_NUMBER_FORMAT ", accuracy loss = " CALCULATED_NUMBER_FORMAT "%%%s"
892
, st->id, rd->name
892
- , st->current_entry
893
+ , current_entry
894
, rd->stored_volume
895
, rd->collected_volume
896
, accuracy
897
, (accuracy > ACCURACY_LOSS) ? " **TOO BIG** " : ""
898
);
898
- #endif
899
-
899
}
900
+ #endif
901
}
902
// reset the storage flags for the next point, if any;
903
storage_flags = SN_EXISTS;
904
905
- st->counter++;
906
- st->current_entry = ((st->current_entry + 1) >= st->entries) ? 0 : st->current_entry + 1;
905
+ counter++;
906
+ current_entry = ((current_entry + 1) >= st->entries) ? 0 : current_entry + 1;
907
last_stored_ut = next_store_ut;
908
}
909
910
+ st->counter = counter;
911
+ st->current_entry = current_entry;
912
+
913
if(likely(last_ut)) {
914
st->last_updated.tv_sec = (time_t) (last_ut / USEC_PER_SEC);
915
st->last_updated.tv_usec = 0;
src/storage_number.h
+1
@@ -29,6 +29,7 @@ typedef uint32_t storage_number;
29
30
// extract the flags
31
#define get_storage_number_flags(value) ((((storage_number)value) & (1 << 24)) | (((storage_number)value) & (2 << 24)) | (((storage_number)value) & (4 << 24)))
32
+#define SN_EMPTY_SLOT 0x00000000
33
34
// checks
35
#define does_storage_number_exist(value) ((get_storage_number_flags(value) != 0)?1:0)