Skip to content

Commit 3561f8c

Browse files
committed
Use MIN_CACHE_THRESHOLD and MAX_CACHE_THRESHOLD to test
1 parent 9e607c2 commit 3561f8c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ggml/src/ggml-rpc/ggml-rpc.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,13 @@ static std::shared_ptr<socket_t> create_server_socket(const char * host, int por
429429
}
430430

431431
// Try use the volatile cache when data size is larger than this threshold
432-
const size_t CACHE_THRESHOLD = 1024 * 1024;
432+
const size_t MIN_CACHE_THRESHOLD = 20 * 1024;
433+
const size_t MAX_CACHE_THRESHOLD = 1024 * 1024;
433434

434435
static bool send_data(sockfd_t sockfd, const void * data, size_t size) {
435436
static std::unordered_set<uint64_t> sent_hashes;
436437

437-
if (size >= CACHE_THRESHOLD) {
438+
if (size > MIN_CACHE_THRESHOLD && size < MAX_CACHE_THRESHOLD) {
438439
uint64_t hash = generate_hash((const uint8_t*)data, size);
439440
bool is_new = sent_hashes.find(hash) == sent_hashes.end();
440441

@@ -471,7 +472,7 @@ static bool recv_data(sockfd_t sockfd, void * data, size_t size) {
471472

472473
uint64_t hash = 0;
473474

474-
if (size >= CACHE_THRESHOLD) {
475+
if (size > MIN_CACHE_THRESHOLD && size < MAX_CACHE_THRESHOLD) {
475476
uint8_t flag;
476477
if (recv(sockfd, (char*)&flag, sizeof(flag), 0) != sizeof(flag)) {
477478
return false;
@@ -506,7 +507,7 @@ static bool recv_data(sockfd_t sockfd, void * data, size_t size) {
506507
bytes_recv += (size_t)n;
507508
}
508509

509-
if (size >= CACHE_THRESHOLD) {
510+
if (size > MIN_CACHE_THRESHOLD && size < MAX_CACHE_THRESHOLD) {
510511
recv_cache[hash] = std::vector<uint8_t>((uint8_t*)data, (uint8_t*)data + size);
511512
}
512513

0 commit comments

Comments
 (0)