[master] c180d47 Start sharing vsmw_clusters for static backends in same VCL.
Poul-Henning Kamp
phk at FreeBSD.org
Tue Jan 9 09:30:19 UTC 2018
commit c180d472a8bcac687bb32ff812b870cf92db8faa
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jan 9 09:13:10 2018 +0000
Start sharing vsmw_clusters for static backends in same VCL.
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index d8914cb..e4c0261 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -42,6 +42,9 @@
#include "vtcp.h"
#include "vtim.h"
+#include "common/heritage.h"
+#include "common/vsmw.h"
+
const void * const vrt_magic_string_end = &vrt_magic_string_end;
const void * const vrt_magic_string_unset = &vrt_magic_string_unset;
@@ -628,10 +631,17 @@ VRT_purge(VRT_CTX, double ttl, double grace, double keep)
struct vsmw_cluster * v_matchproto_()
VRT_VSM_Cluster_New(VRT_CTX, size_t sz)
{
+ struct vsmw_cluster *vc;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- AN(sz);
- return ((void*)VRT_VSM_Cluster_New);
+ assert(sz > 0);
+ AN(vsc_lock);
+ AN(vsc_unlock);
+ AN(heritage.proc_vsmw);
+ vsc_lock();
+ vc = VSMW_NewCluster(heritage.proc_vsmw, sz, "VSC_cluster");
+ vsc_unlock();
+ return (vc);
}
void v_matchproto_()
diff --git a/bin/varnishd/common/common_vsmw.c b/bin/varnishd/common/common_vsmw.c
index 68f854e..ec58bbd 100644
--- a/bin/varnishd/common/common_vsmw.c
+++ b/bin/varnishd/common/common_vsmw.c
@@ -75,6 +75,7 @@ struct vsmw_cluster {
char *fn;
size_t len;
void *ptr;
+ size_t next;
int refs;
};
@@ -239,12 +240,15 @@ VSMW_Allocv(struct vsmw *vsmw, struct vsmw_cluster *vc,
AZ(VSB_finish(vsmw->vsb));
REPLACE(seg->id, VSB_data(vsmw->vsb));
- vc = VSMW_NewCluster(vsmw, 64 + len, class);
+ if (vc == NULL)
+ vc = VSMW_NewCluster(vsmw, len, class);
AN(vc);
vc->refs++;
seg->cluster = vc;
- seg->off = 64;
+ seg->off = vc->next;
+ vc->next += len;
+ assert(vc->next <= vc->len);
seg->ptr = seg->off + (char*)vc->ptr;
VTAILQ_INSERT_TAIL(&vsmw->segs, seg, list);
More information about the varnish-commit
mailing list