Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed Aug 3, 2024
1 parent 496706b commit 03f2453
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
10 changes: 6 additions & 4 deletions ww/shiftbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include <stdint.h>
#include <string.h>

#define LEFTPADDING (RAM_PROFILE >= kRamProfileS2Memory ? (1U << 13) : ((1U << 8) + 512))
#define RIGHTPADDING (RAM_PROFILE >= kRamProfileS2Memory ? (1U << 10) : (1U << 8))
#define LEFTPADDING (RAM_PROFILE >= kRamProfileS2Memory ? (1U << 10) : (1U << 8))
#define RIGHTPADDING (RAM_PROFILE >= kRamProfileS2Memory ? (1U << 9) : (1U << 7))

#define REFC_SIZE sizeof(shiftbuffer_refc_t)

Expand Down Expand Up @@ -50,7 +50,9 @@ shift_buffer_t *newShiftBuffer(uint8_t tid, unsigned int pre_cap) // NOLINT
{
if (pre_cap != 0 && pre_cap % 16 != 0)
{
pre_cap = (unsigned int) pow(2, ceil(log2((double) max(16, pre_cap))));
// pre_cap = (unsigned int) pow(2, ceil(log2((double) max(16, pre_cap))));
pre_cap = (max(16, pre_cap) + 15) & ~0x0F;

}

unsigned int real_cap = (pre_cap + LEFTPADDING + RIGHTPADDING) - REFC_SIZE;
Expand Down Expand Up @@ -86,7 +88,7 @@ void reset(shift_buffer_t *self, unsigned int pre_cap)

if (pre_cap != 0 && pre_cap % 16 != 0)
{
pre_cap = (unsigned int) pow(2, ceil(log2(((double) max(16, pre_cap)))));
pre_cap = (max(16, pre_cap) + 15) & ~0x0F;
}

unsigned int real_cap = (pre_cap + LEFTPADDING + RIGHTPADDING) - REFC_SIZE;
Expand Down
5 changes: 5 additions & 0 deletions ww/shiftbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ static inline bool isShallow(shift_buffer_t *self)
return (*(self->refc) > 1);
}

static inline unsigned int bufCap(shift_buffer_t *const self)
{
return self->full_cap;
}

// caps mean how much memory we own to be able to shift left/right
static inline unsigned int lCap(shift_buffer_t *const self)
{
Expand Down
2 changes: 1 addition & 1 deletion ww/ww.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void initalizeSocketManagerWorker(worker_t *worker, tid_t tid)
newGenericPoolWithCap((64) + GSTATE.ram_profile, allocShiftBufferPoolHandle, destroyShiftBufferPoolHandle);
GSTATE.shortcut_shift_buffer_pools[tid] = getWorker(tid)->shift_buffer_pool;

worker->buffer_pool = createSmallBufferPool(worker->tid);
worker->buffer_pool = createBufferPool(worker->tid);
GSTATE.shortcut_buffer_pools[tid] = getWorker(tid)->buffer_pool;

worker->loop = hloop_new(HLOOP_FLAG_AUTO_FREE, worker->buffer_pool, 0);
Expand Down

0 comments on commit 03f2453

Please sign in to comment.