Skip to content

Commit

Permalink
Merge remote-tracking branch 'valkey/unstable' into hashset
Browse files Browse the repository at this point in the history
  • Loading branch information
zuiderkwast committed Oct 17, 2024
2 parents f5f4380 + a62d1f1 commit 19576b5
Show file tree
Hide file tree
Showing 19 changed files with 501 additions and 290 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ jobs:
!contains(github.event.inputs.skipjobs, 'sanitizer')
timeout-minutes: 14400
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
env:
Expand Down Expand Up @@ -659,6 +660,7 @@ jobs:
!contains(github.event.inputs.skipjobs, 'sanitizer')
timeout-minutes: 14400
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
env:
Expand Down Expand Up @@ -1001,6 +1003,7 @@ jobs:

build-macos:
strategy:
fail-fast: false
matrix:
os: [macos-12, macos-14]
runs-on: ${{ matrix.os }}
Expand Down
7 changes: 3 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ you need to ensure that the contribution is in accordance with the DCO.

1. If it is a major feature or a semantical change, please don't start coding
straight away: if your feature is not a conceptual fit you'll lose a lot of
time writing the code without any reason. Start by posting in the mailing list
and creating an issue at Github with the description of, exactly, what you want
to accomplish and why. Use cases are important for features to be accepted.
Here you can see if there is consensus about your idea.
time writing the code without any reason. Start by creating an issue at Github with the
description of, exactly, what you want to accomplish and why. Use cases are important for
features to be accepted. Here you can see if there is consensus about your idea.

2. If in step 1 you get an acknowledgment from the project leaders, use the following
procedure to submit a patch:
Expand Down
1 change: 1 addition & 0 deletions deps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ and our version:
1. Makefile is modified to allow a different compiler than GCC.
2. We have the implementation source code, and directly link to the following external libraries: `lua_cjson.o`, `lua_struct.o`, `lua_cmsgpack.o` and `lua_bit.o`.
3. There is a security fix in `ldo.c`, line 498: The check for `LUA_SIGNATURE[0]` is removed in order to avoid direct bytecode execution.
4. In `lstring.c`, the luaS_newlstr function's hash calculation has been upgraded from a simple hash function to MurmurHash3, implemented within the same file, to enhance performance, particularly for operations involving large strings.

Hdr_Histogram
---
Expand Down
12 changes: 6 additions & 6 deletions deps/hdr_histogram/hdr_redis_malloc.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#ifndef HDR_MALLOC_H__
#define HDR_MALLOC_H__

void *zmalloc(size_t size);
void *valkey_malloc(size_t size);
void *zcalloc_num(size_t num, size_t size);
void *zrealloc(void *ptr, size_t size);
void zfree(void *ptr);
void *valkey_realloc(void *ptr, size_t size);
void valkey_free(void *ptr);

#define hdr_malloc zmalloc
#define hdr_malloc valkey_malloc
#define hdr_calloc zcalloc_num
#define hdr_realloc zrealloc
#define hdr_free zfree
#define hdr_realloc valkey_realloc
#define hdr_free valkey_free
#endif
52 changes: 47 additions & 5 deletions deps/lua/src/lstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


#include <string.h>
#include <stdint.h>

#define lstring_c
#define LUA_CORE
Expand Down Expand Up @@ -71,14 +72,55 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
return ts;
}

uint32_t murmur32(const uint8_t* key, size_t len, uint32_t seed) {
static const uint32_t c1 = 0xcc9e2d51;
static const uint32_t c2 = 0x1b873593;
static const uint32_t r1 = 15;
static const uint32_t r2 = 13;
static const uint32_t m = 5;
static const uint32_t n = 0xe6546b64;
uint32_t hash = seed;

const int nblocks = len / 4;
const uint32_t* blocks = (const uint32_t*) key;
for (int i = 0; i < nblocks; i++) {
uint32_t k = blocks[i];
k *= c1;
k = (k << r1) | (k >> (32 - r1));
k *= c2;

hash ^= k;
hash = ((hash << r2) | (hash >> (32 - r2))) * m + n;
}

const uint8_t* tail = (const uint8_t*) (key + nblocks * 4);
uint32_t k1 = 0;
switch (len & 3) {
case 3:
k1 ^= tail[2] << 16;
case 2:
k1 ^= tail[1] << 8;
case 1:
k1 ^= tail[0];
k1 *= c1;
k1 = (k1 << r1) | (k1 >> (32 - r1));
k1 *= c2;
hash ^= k1;
}

hash ^= len;
hash ^= (hash >> 16);
hash *= 0x85ebca6b;
hash ^= (hash >> 13);
hash *= 0xc2b2ae35;
hash ^= (hash >> 16);

return hash;
}

TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
GCObject *o;
unsigned int h = cast(unsigned int, l); /* seed */
size_t step = 1;
size_t l1;
for (l1=l; l1>=step; l1-=step) /* compute hash */
h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
unsigned int h = murmur32((uint8_t *)str, l, (uint32_t)l);
for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
o != NULL;
o = o->gch.next) {
Expand Down
2 changes: 1 addition & 1 deletion src/aof.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ sds getLastIncrAofName(aofManifest *am) {
}

/* Or return the last one. */
listNode *lastnode = listIndex(am->incr_aof_list, -1);
listNode *lastnode = listLast(am->incr_aof_list);
aofInfo *ai = listNodeValue(lastnode);
return ai->file_name;
}
Expand Down
Loading

0 comments on commit 19576b5

Please sign in to comment.