summaryrefslogtreecommitdiffstats
path: root/src/server/globals.h
diff options
context:
space:
mode:
authorSimon Rettberg2015-12-17 15:58:06 +0100
committerSimon Rettberg2015-12-17 15:58:06 +0100
commit1460b746b6f5482ce1c56a30af232e824e316e56 (patch)
tree12d170ec73fe3eba66db779a38be36e86052be66 /src/server/globals.h
parent[SERVER] image_markComplete now handles locking so we remove() unlocked (diff)
downloaddnbd3-1460b746b6f5482ce1c56a30af232e824e316e56.tar.gz
dnbd3-1460b746b6f5482ce1c56a30af232e824e316e56.tar.xz
dnbd3-1460b746b6f5482ce1c56a30af232e824e316e56.zip
[SERVER] Performance: Optimized some functions (gprof)
A run with gprof revealed that background replication is a huge CPU hog. The block selection was very slow and has been improved a lot. Minor improvements were made to other functions that scan the cache map of an image and are thus relatively slow.
Diffstat (limited to 'src/server/globals.h')
-rw-r--r--src/server/globals.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/server/globals.h b/src/server/globals.h
index a06e0e0..9cf349a 100644
--- a/src/server/globals.h
+++ b/src/server/globals.h
@@ -55,7 +55,8 @@ struct _dnbd3_connection
uint8_t *recvBuffer; // Buffer for receiving payload
uint32_t recvBufferLen; // Len of ^^
volatile bool shutdown; // signal this thread to stop, must only be set from uplink_shutdown() or cleanup in uplink_mainloop()
- int replicatedLastBlock; // bool telling if the last block has been replicated yet
+ bool replicatedLastBlock; // bool telling if the last block has been replicated yet
+ int nextReplicationIndex; // Which index in the cache map we should start looking for incomplete blocks at
uint64_t replicationHandle; // Handle of pending replication request
uint64_t bytesReceived; // Number of bytes received by the connection.
};
@@ -99,19 +100,21 @@ struct _dnbd3_image
{
char *path; // absolute path of the image
char *lower_name; // relative path, all lowercase, minus revision ID
- uint8_t *cache_map; // cache map telling which parts are locally cached, NULL if complete
- uint32_t *crc32; // list of crc32 checksums for each 16MiB block in image
- uint32_t masterCrc32; // CRC-32 of the crc-32 list
dnbd3_connection_t *uplink; // pointer to a server connection
+ uint8_t *cache_map; // cache map telling which parts are locally cached, NULL if complete
uint64_t virtualFilesize; // virtual size of image (real size rounded up to multiple of 4k)
uint64_t realFilesize; // actual file size on disk
+ time_t atime; // last access time
+ time_t lastWorkCheck; // last time a non-working image has been checked
+ time_t nextCompletenessEstimate; // last time the completeness estimate was updated
+ uint32_t *crc32; // list of crc32 checksums for each 16MiB block in image
+ uint32_t masterCrc32; // CRC-32 of the crc-32 list
int readFd; // used to read the image. Used from multiple threads, so use atomic operations (pread et al)
int cacheFd; // used to write to the image, in case it is relayed. ONLY USE FROM UPLINK THREAD!
int rid; // revision of image
+ int completenessEstimate; // Completeness estimate in percent
int users; // clients currently using this image
int id; // Unique ID of this image. Only unique in the context of this running instance of DNBD3-Server
- time_t atime; // last access time
- time_t lastWorkCheck; // last time a non-working image has been checked
bool working; // true if image exists and completeness is == 100% or a working upstream proxy is connected
pthread_spinlock_t lock;
};