only using prefetch on addReplyBulk

This commit is contained in:
fcostaoliveira 2025-01-03 12:01:53 +00:00
parent 54bcbea675
commit da94227e37
3 changed files with 6 additions and 7 deletions

View File

@ -1070,6 +1070,8 @@ void addReplyBulk(client *c, robj *obj) {
if (prepareClientToWrite(c) != C_OK) return;
if (sdsEncodedObject(obj)) {
/* Prefetch the memory for the `flags` and potential header */
redis_prefetch_read((const sds)(obj->ptr) - 1);
const size_t len = sdslen(obj->ptr);
_addReplyLongLongBulk(c, len);
_addReplyToBufferOrList(c,obj->ptr,len);

View File

@ -65,23 +65,21 @@ struct __attribute__ ((__packed__)) sdshdr64 {
#define SDS_HDR_PREFETCH(T, s) redis_prefetch_read((const char *)((s) - sizeof(struct sdshdr##T)))
static inline size_t sdslen(const sds s) {
/* Prefetch the memory for the `flags` and potential header */
redis_prefetch_read((const char *)(s - 1));
unsigned char flags = s[-1];
switch(flags&SDS_TYPE_MASK) {
case SDS_TYPE_5:
return SDS_TYPE_5_LEN(flags);
case SDS_TYPE_8:
SDS_HDR_PREFETCH(8,s);
// SDS_HDR_PREFETCH(8,s);
return SDS_HDR(8,s)->len;
case SDS_TYPE_16:
SDS_HDR_PREFETCH(16,s);
// SDS_HDR_PREFETCH(16,s);
return SDS_HDR(16,s)->len;
case SDS_TYPE_32:
SDS_HDR_PREFETCH(32,s);
// SDS_HDR_PREFETCH(32,s);
return SDS_HDR(32,s)->len;
case SDS_TYPE_64:
SDS_HDR_PREFETCH(64,s);
// SDS_HDR_PREFETCH(64,s);
return SDS_HDR(64,s)->len;
}
return 0;

View File

@ -309,7 +309,6 @@ int getGenericCommand(client *c) {
if (checkType(c,o,OBJ_STRING)) {
return C_ERR;
}
addReplyBulk(c,o);
return C_OK;
}