Logo
Explore Help
Sign In
bytemark/flexnbd-c
1
0
Fork 0
You've already forked flexnbd-c
Code Issues Pull Requests Releases Wiki Activity
Files
d87af93cecc73abe7f6fd7a856ddd993290ae965
flexnbd-c/src/prefetch.h

15 lines
201 B
C
Raw Normal View History

Add a trivial read buffer to flexnbd-proxy. Since the vast majority (something like 94% on boot) are sequential small reads, and since network latency is a major factor in determining how fast the exposed device appears to the client, it makes sense for us to try to minimise the number of network requests where we safely can. This patch implements the simplest possible read cache in flexnbd-proxy. When it receives a read request, if it's a small request then flexnbd-proxy will double the length of data requested. On receiving the data from the upstream server, flexnbd-proxy will return the first half to the downstream as normal, and stash the second half in a buffer. If the very next request is a read, and the offset and length match those of what we have stored, that second request will be satisfied from the buffer without going out over the network. The cache is invalidated by any non-read request, or by a disconnection.
2013-04-29 14:50:42 +01:00
#ifndef PREFETCH_H
#define PREFETCH_H
#define PREFETCH_BUFSIZE 4096
struct prefetch {
int is_full;
__be64 from;
__be32 len;
char buffer[PREFETCH_BUFSIZE];
};
#endif
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.5 Page: 43ms Template: 3ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API