#ifndef NDEBUG
#define SIRIDB_VERSION_BUILD_RELEASE "+debug"
#else
-#define SIRIDB_VERSION_BUILD_RELEASE "-alpha-0"
+#define SIRIDB_VERSION_BUILD_RELEASE "-alpha-1"
#endif
#define SIRIDB_STRINGIFY(num) #num
shard->replacing = replacing;
shard->len = shard->size = HEADER_SIZE;
shard->duration = duration;
- shard->max_chunk_sz = (replacing == NULL) ?
- (tp == SIRIDB_SHARD_TP_NUMBER ?
- DEFAULT_MAX_CHUNK_SZ_NUM : DEFAULT_MAX_CHUNK_SZ_LOG) :
- replacing->max_chunk_sz;
+ if (replacing == NULL)
+ {
+ shard->max_chunk_sz = (tp == SIRIDB_SHARD_TP_NUMBER)
+ ? DEFAULT_MAX_CHUNK_SZ_NUM
+ : DEFAULT_MAX_CHUNK_SZ_LOG;
+ }
+ else
+ {
+ shard->max_chunk_sz = replacing->max_chunk_sz;
+ if (tp == SIRIDB_SHARD_TP_NUMBER && shard->max_chunk_sz < 4000)
+ {
+ uint64_t now_ts;
+ struct timespec now;
+ clock_gettime(CLOCK_REALTIME, &now);
+ now_ts = siridb_time_now(siridb, now);
+
+ if (now_ts > id && (now_ts - id) > (duration * 3))
+ {
+ /* for numbers, we grow the max_chunk_size on each optimize;
+ * as soon as the shard is older than 3 times the duration */
+ shard->max_chunk_sz *= 2;
+ log_debug(
+ "Grow chunk size for shard id %" PRIu64 " to %u",
+ id, shard->max_chunk_sz);
+ }
+ }
+ }
if (SHARD_init_fn(siridb, shard) < 0)
{
case STREAM_API_CLIENT:
case STREAM_PIPE_CLIENT:
case STREAM_TCP_CLIENT: /* listens to client connections */
- log_debug("client connection lost");
+ log_debug("Client connection lost");
if (client->origin != NULL)
{
siridb_user_t * user = client->origin;