Commit 79101ecc authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Dridi Boukelmoune

Move the wrk+pool summed stats into group 'wrk'.

This eliminates read-add-zero-write on counters outside this group.
parent 737d6c2d
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
.. varnish_vsc_begin:: main .. varnish_vsc_begin:: main
:oneliner: Main counters :oneliner: Main counters
:order: 10 :order: 10
:sumfunction: :sumfunction: wrk_wrk wrk
.. varnish_vsc:: summs .. varnish_vsc:: summs
:level: debug :level: debug
:group: wrk
:oneliner: stat summ operations :oneliner: stat summ operations
Number of times per-thread statistics were summed into the Number of times per-thread statistics were summed into the
...@@ -21,16 +22,19 @@ ...@@ -21,16 +22,19 @@
How long the child process has been running. How long the child process has been running.
.. varnish_vsc:: sess_conn .. varnish_vsc:: sess_conn
:group: wrk
:oneliner: Sessions accepted :oneliner: Sessions accepted
Count of sessions successfully accepted Count of sessions successfully accepted
.. varnish_vsc:: sess_drop .. varnish_vsc:: sess_drop
:group: wrk
:oneliner: Sessions dropped :oneliner: Sessions dropped
Count of sessions silently dropped due to lack of worker thread. Count of sessions silently dropped due to lack of worker thread.
.. varnish_vsc:: sess_fail .. varnish_vsc:: sess_fail
:group: wrk
:oneliner: Session accept failures :oneliner: Session accept failures
Count of failures to accept TCP connection. Count of failures to accept TCP connection.
...@@ -39,64 +43,75 @@ ...@@ -39,64 +43,75 @@
give more detailed information. give more detailed information.
.. varnish_vsc:: sess_fail_econnaborted .. varnish_vsc:: sess_fail_econnaborted
:group: wrk
:oneliner: Session accept failures: connection aborted :oneliner: Session accept failures: connection aborted
Detailed reason for sess_fail: Connection aborted by the Detailed reason for sess_fail: Connection aborted by the
client, usually harmless. client, usually harmless.
.. varnish_vsc:: sess_fail_eintr .. varnish_vsc:: sess_fail_eintr
:group: wrk
:oneliner: Session accept failures: interrupted system call :oneliner: Session accept failures: interrupted system call
Detailed reason for sess_fail: The accept() call was Detailed reason for sess_fail: The accept() call was
interrupted, usually harmless interrupted, usually harmless
.. varnish_vsc:: sess_fail_emfile .. varnish_vsc:: sess_fail_emfile
:group: wrk
:oneliner: Session accept failures: too many open files :oneliner: Session accept failures: too many open files
Detailed reason for sess_fail: No file descriptor was Detailed reason for sess_fail: No file descriptor was
available. Consider raising RLIMIT_NOFILE (see ulimit -n). available. Consider raising RLIMIT_NOFILE (see ulimit -n).
.. varnish_vsc:: sess_fail_ebadf .. varnish_vsc:: sess_fail_ebadf
:group: wrk
:oneliner: Session accept failures: bad file descriptor :oneliner: Session accept failures: bad file descriptor
Detailed reason for sess_fail: The listen socket file Detailed reason for sess_fail: The listen socket file
descriptor was invalid. Should never happen. descriptor was invalid. Should never happen.
.. varnish_vsc:: sess_fail_enomem .. varnish_vsc:: sess_fail_enomem
:group: wrk
:oneliner: Session accept failures: not enough memory :oneliner: Session accept failures: not enough memory
Detailed reason for sess_fail: Most likely insufficient Detailed reason for sess_fail: Most likely insufficient
socket buffer memory. Should never happen socket buffer memory. Should never happen
.. varnish_vsc:: sess_fail_other .. varnish_vsc:: sess_fail_other
:group: wrk
:oneliner: Session accept failures: other :oneliner: Session accept failures: other
Detailed reason for sess_fail: neither of the above, see Detailed reason for sess_fail: neither of the above, see
Debug log (varnishlog -g raw -I Debug:^Accept). Debug log (varnishlog -g raw -I Debug:^Accept).
.. varnish_vsc:: client_req_400 .. varnish_vsc:: client_req_400
:group: wrk
:oneliner: Client requests received, subject to 400 errors :oneliner: Client requests received, subject to 400 errors
400 means we couldn't make sense of the request, it was malformed 400 means we couldn't make sense of the request, it was malformed
in some drastic way. in some drastic way.
.. varnish_vsc:: client_req_417 .. varnish_vsc:: client_req_417
:group: wrk
:oneliner: Client requests received, subject to 417 errors :oneliner: Client requests received, subject to 417 errors
417 means that something went wrong with an Expect: header. 417 means that something went wrong with an Expect: header.
.. varnish_vsc:: client_req .. varnish_vsc:: client_req
:group: wrk
:oneliner: Good client requests received :oneliner: Good client requests received
The count of parseable client requests seen. The count of parseable client requests seen.
.. varnish_vsc:: cache_hit .. varnish_vsc:: cache_hit
:group: wrk
:oneliner: Cache hits :oneliner: Cache hits
Count of cache hits. A cache hit indicates that an object has been Count of cache hits. A cache hit indicates that an object has been
delivered to a client without fetching it from a backend server. delivered to a client without fetching it from a backend server.
.. varnish_vsc:: cache_hit_grace .. varnish_vsc:: cache_hit_grace
:group: wrk
:oneliner: Cache grace hits :oneliner: Cache grace hits
Count of cache hits with grace. A cache hit with grace is a cache Count of cache hits with grace. A cache hit with grace is a cache
...@@ -104,6 +119,7 @@ ...@@ -104,6 +119,7 @@
included in the cache_hit counter. included in the cache_hit counter.
.. varnish_vsc:: cache_hitpass .. varnish_vsc:: cache_hitpass
:group: wrk
:oneliner: Cache hits for pass. :oneliner: Cache hits for pass.
Count of hits for pass. A cache hit for pass indicates that Varnish Count of hits for pass. A cache hit for pass indicates that Varnish
...@@ -112,6 +128,7 @@ ...@@ -112,6 +128,7 @@
decision is being used. decision is being used.
.. varnish_vsc:: cache_hitmiss .. varnish_vsc:: cache_hitmiss
:group: wrk
:oneliner: Cache hits for miss. :oneliner: Cache hits for miss.
Count of hits for miss. A cache hit for miss indicates that Varnish Count of hits for miss. A cache hit for miss indicates that Varnish
...@@ -120,6 +137,7 @@ ...@@ -120,6 +137,7 @@
cached decision is being used. cached decision is being used.
.. varnish_vsc:: cache_miss .. varnish_vsc:: cache_miss
:group: wrk
:oneliner: Cache misses :oneliner: Cache misses
Count of misses. A cache miss indicates the object was fetched from Count of misses. A cache miss indicates the object was fetched from
...@@ -161,56 +179,67 @@ ...@@ -161,56 +179,67 @@
.. varnish_vsc:: fetch_head .. varnish_vsc:: fetch_head
:group: wrk
:oneliner: Fetch no body (HEAD) :oneliner: Fetch no body (HEAD)
beresp with no body because the request is HEAD. beresp with no body because the request is HEAD.
.. varnish_vsc:: fetch_length .. varnish_vsc:: fetch_length
:group: wrk
:oneliner: Fetch with Length :oneliner: Fetch with Length
beresp.body with Content-Length. beresp.body with Content-Length.
.. varnish_vsc:: fetch_chunked .. varnish_vsc:: fetch_chunked
:group: wrk
:oneliner: Fetch chunked :oneliner: Fetch chunked
beresp.body with Chunked. beresp.body with Chunked.
.. varnish_vsc:: fetch_eof .. varnish_vsc:: fetch_eof
:group: wrk
:oneliner: Fetch EOF :oneliner: Fetch EOF
beresp.body with EOF. beresp.body with EOF.
.. varnish_vsc:: fetch_bad .. varnish_vsc:: fetch_bad
:group: wrk
:oneliner: Fetch bad T-E :oneliner: Fetch bad T-E
beresp.body length/fetch could not be determined. beresp.body length/fetch could not be determined.
.. varnish_vsc:: fetch_none .. varnish_vsc:: fetch_none
:group: wrk
:oneliner: Fetch no body :oneliner: Fetch no body
beresp.body empty beresp.body empty
.. varnish_vsc:: fetch_1xx .. varnish_vsc:: fetch_1xx
:group: wrk
:oneliner: Fetch no body (1xx) :oneliner: Fetch no body (1xx)
beresp with no body because of 1XX response. beresp with no body because of 1XX response.
.. varnish_vsc:: fetch_204 .. varnish_vsc:: fetch_204
:group: wrk
:oneliner: Fetch no body (204) :oneliner: Fetch no body (204)
beresp with no body because of 204 response. beresp with no body because of 204 response.
.. varnish_vsc:: fetch_304 .. varnish_vsc:: fetch_304
:group: wrk
:oneliner: Fetch no body (304) :oneliner: Fetch no body (304)
beresp with no body because of 304 response. beresp with no body because of 304 response.
.. varnish_vsc:: fetch_failed .. varnish_vsc:: fetch_failed
:group: wrk
:oneliner: Fetch failed (all causes) :oneliner: Fetch failed (all causes)
beresp fetch failed. beresp fetch failed.
.. varnish_vsc:: fetch_no_thread .. varnish_vsc:: fetch_no_thread
:group: wrk
:oneliner: Fetch failed (no thread) :oneliner: Fetch failed (no thread)
beresp fetch failed, no thread available. beresp fetch failed, no thread available.
...@@ -259,12 +288,14 @@ ...@@ -259,12 +288,14 @@
per second. See also parameter thread_queue_limit. per second. See also parameter thread_queue_limit.
.. varnish_vsc:: busy_sleep .. varnish_vsc:: busy_sleep
:group: wrk
:oneliner: Number of requests sent to sleep on busy objhdr :oneliner: Number of requests sent to sleep on busy objhdr
Number of requests sent to sleep without a worker thread because Number of requests sent to sleep without a worker thread because
they found a busy object. they found a busy object.
.. varnish_vsc:: busy_wakeup .. varnish_vsc:: busy_wakeup
:group: wrk
:oneliner: Number of requests woken after sleep on busy objhdr :oneliner: Number of requests woken after sleep on busy objhdr
Number of requests taken off the busy object sleep list and rescheduled. Number of requests taken off the busy object sleep list and rescheduled.
...@@ -295,6 +326,7 @@ ...@@ -295,6 +326,7 @@
.. varnish_vsc:: n_object .. varnish_vsc:: n_object
:type: gauge :type: gauge
:group: wrk
:oneliner: object structs made :oneliner: object structs made
Approximate number of HTTP objects (headers + body, if present) in Approximate number of HTTP objects (headers + body, if present) in
...@@ -303,12 +335,14 @@ ...@@ -303,12 +335,14 @@
.. varnish_vsc:: n_vampireobject .. varnish_vsc:: n_vampireobject
:type: gauge :type: gauge
:level: diag :level: diag
:group: wrk
:oneliner: unresurrected objects :oneliner: unresurrected objects
Number of unresurrected objects Number of unresurrected objects
.. varnish_vsc:: n_objectcore .. varnish_vsc:: n_objectcore
:type: gauge :type: gauge
:group: wrk
:oneliner: objectcore structs made :oneliner: objectcore structs made
Approximate number of object metadata elements in the cache. Each Approximate number of object metadata elements in the cache. Each
...@@ -317,6 +351,7 @@ ...@@ -317,6 +351,7 @@
.. varnish_vsc:: n_objecthead .. varnish_vsc:: n_objecthead
:type: gauge :type: gauge
:group: wrk
:oneliner: objecthead structs made :oneliner: objecthead structs made
Approximate number of different hash entries in the cache. Approximate number of different hash entries in the cache.
...@@ -358,72 +393,83 @@ ...@@ -358,72 +393,83 @@
.. varnish_vsc:: s_sess .. varnish_vsc:: s_sess
:group: wrk
:oneliner: Total sessions seen :oneliner: Total sessions seen
.. varnish_vsc:: s_pipe .. varnish_vsc:: s_pipe
:group: wrk
:oneliner: Total pipe sessions seen :oneliner: Total pipe sessions seen
.. varnish_vsc:: s_pass .. varnish_vsc:: s_pass
:group: wrk
:oneliner: Total pass-ed requests seen :oneliner: Total pass-ed requests seen
.. varnish_vsc:: s_fetch .. varnish_vsc:: s_fetch
:group: wrk
:oneliner: Total backend fetches initiated :oneliner: Total backend fetches initiated
.. varnish_vsc:: s_synth .. varnish_vsc:: s_synth
:group: wrk
:oneliner: Total synthetic responses made :oneliner: Total synthetic responses made
.. varnish_vsc:: s_req_hdrbytes .. varnish_vsc:: s_req_hdrbytes
:oneliner: Request header bytes
:format: bytes :format: bytes
:group: wrk
:oneliner: Request header bytes
Total request header bytes received Total request header bytes received
.. varnish_vsc:: s_req_bodybytes .. varnish_vsc:: s_req_bodybytes
:oneliner: Request body bytes
:format: bytes :format: bytes
:group: wrk
:oneliner: Request body bytes
Total request body bytes received Total request body bytes received
.. varnish_vsc:: s_resp_hdrbytes .. varnish_vsc:: s_resp_hdrbytes
:oneliner: Response header bytes
:format: bytes :format: bytes
:group: wrk
:oneliner: Response header bytes
Total response header bytes transmitted Total response header bytes transmitted
.. varnish_vsc:: s_resp_bodybytes .. varnish_vsc:: s_resp_bodybytes
:oneliner: Response body bytes
:format: bytes :format: bytes
:group: wrk
:oneliner: Response body bytes
Total response body bytes transmitted Total response body bytes transmitted
:format: bytes
.. varnish_vsc:: s_pipe_hdrbytes .. varnish_vsc:: s_pipe_hdrbytes
:oneliner: Pipe request header bytes
:format: bytes :format: bytes
:group: wrk
:oneliner: Pipe request header bytes
Total request bytes received for piped sessions Total request bytes received for piped sessions
.. varnish_vsc:: s_pipe_in .. varnish_vsc:: s_pipe_in
:oneliner: Piped bytes from client
:format: bytes :format: bytes
:group: wrk
:oneliner: Piped bytes from client
Total number of bytes forwarded from clients in pipe sessions Total number of bytes forwarded from clients in pipe sessions
.. varnish_vsc:: s_pipe_out .. varnish_vsc:: s_pipe_out
:oneliner: Piped bytes to client
:format: bytes :format: bytes
:group: wrk
:oneliner: Piped bytes to client
Total number of bytes forwarded to clients in pipe sessions Total number of bytes forwarded to clients in pipe sessions
.. varnish_vsc:: sess_closed .. varnish_vsc:: sess_closed
:group: wrk
:oneliner: Session Closed :oneliner: Session Closed
.. varnish_vsc:: sess_closed_err .. varnish_vsc:: sess_closed_err
:oneliner: Session Closed with error :oneliner: Session Closed with error
...@@ -431,11 +477,12 @@ ...@@ -431,11 +477,12 @@
for detailed breakdown for detailed breakdown
.. varnish_vsc:: sess_readahead .. varnish_vsc:: sess_readahead
:group: wrk
:oneliner: Session Read Ahead :oneliner: Session Read Ahead
.. varnish_vsc:: sess_herd .. varnish_vsc:: sess_herd
:level: diag :level: diag
:group: wrk
:oneliner: Session herd :oneliner: Session herd
Number of times the timeout_linger triggered Number of times the timeout_linger triggered
...@@ -589,6 +636,7 @@ ...@@ -589,6 +636,7 @@
.. varnish_vsc:: vcl_fail .. varnish_vsc:: vcl_fail
:group: wrk
:oneliner: VCL failures :oneliner: VCL failures
Count of failures which prevented VCL from completing. Count of failures which prevented VCL from completing.
...@@ -754,6 +802,7 @@ ...@@ -754,6 +802,7 @@
Number of objects received by expiry thread for handling. Number of objects received by expiry thread for handling.
.. varnish_vsc:: hcb_nolock .. varnish_vsc:: hcb_nolock
:group: wrk
:level: debug :level: debug
:oneliner: HCB Lookups without lock :oneliner: HCB Lookups without lock
......
...@@ -86,6 +86,7 @@ enum { ...@@ -86,6 +86,7 @@ enum {
struct VSC_lck; struct VSC_lck;
struct VSC_main; struct VSC_main;
struct VSC_main_wrk;
struct backend; struct backend;
struct ban; struct ban;
struct ban_proto; struct ban_proto;
...@@ -246,7 +247,7 @@ struct worker { ...@@ -246,7 +247,7 @@ struct worker {
struct objhead *nobjhead; struct objhead *nobjhead;
struct objcore *nobjcore; struct objcore *nobjcore;
void *nhashpriv; void *nhashpriv;
struct VSC_main *stats; struct VSC_main_wrk *stats;
struct vsl_log *vsl; // borrowed from req/bo struct vsl_log *vsl; // borrowed from req/bo
struct pool_task task; struct pool_task task;
......
...@@ -50,20 +50,12 @@ static VTAILQ_HEAD(,pool) pools = VTAILQ_HEAD_INITIALIZER(pools); ...@@ -50,20 +50,12 @@ static VTAILQ_HEAD(,pool) pools = VTAILQ_HEAD_INITIALIZER(pools);
* Summing of stats into global stats counters * Summing of stats into global stats counters
*/ */
static void
pool_sumstat(const struct VSC_main *src)
{
Lck_AssertHeld(&wstat_mtx);
VSC_main_Summ(VSC_C_main, src);
}
void void
Pool_Sumstat(const struct worker *wrk) Pool_Sumstat(const struct worker *wrk)
{ {
Lck_Lock(&wstat_mtx); Lck_Lock(&wstat_mtx);
pool_sumstat(wrk->stats); VSC_main_Summ_wrk(VSC_C_main, wrk->stats);
Lck_Unlock(&wstat_mtx); Lck_Unlock(&wstat_mtx);
memset(wrk->stats, 0, sizeof *wrk->stats); memset(wrk->stats, 0, sizeof *wrk->stats);
} }
...@@ -73,7 +65,7 @@ Pool_TrySumstat(const struct worker *wrk) ...@@ -73,7 +65,7 @@ Pool_TrySumstat(const struct worker *wrk)
{ {
if (Lck_Trylock(&wstat_mtx)) if (Lck_Trylock(&wstat_mtx))
return (0); return (0);
pool_sumstat(wrk->stats); VSC_main_Summ_wrk(VSC_C_main, wrk->stats);
Lck_Unlock(&wstat_mtx); Lck_Unlock(&wstat_mtx);
memset(wrk->stats, 0, sizeof *wrk->stats); memset(wrk->stats, 0, sizeof *wrk->stats);
return (1); return (1);
...@@ -121,14 +113,14 @@ Pool_PurgeStat(unsigned nobj) ...@@ -121,14 +113,14 @@ Pool_PurgeStat(unsigned nobj)
void v_matchproto_(task_func_t) void v_matchproto_(task_func_t)
pool_stat_summ(struct worker *wrk, void *priv) pool_stat_summ(struct worker *wrk, void *priv)
{ {
struct VSC_main *src; struct VSC_main_wrk *src;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(wrk->pool, POOL_MAGIC); CHECK_OBJ_NOTNULL(wrk->pool, POOL_MAGIC);
AN(priv); AN(priv);
src = priv; src = priv;
Lck_Lock(&wstat_mtx); Lck_Lock(&wstat_mtx);
pool_sumstat(src); VSC_main_Summ_wrk(VSC_C_main, src);
Lck_Unlock(&wstat_mtx); Lck_Unlock(&wstat_mtx);
memset(src, 0, sizeof *src); memset(src, 0, sizeof *src);
AZ(wrk->pool->b_stat); AZ(wrk->pool->b_stat);
......
...@@ -53,8 +53,8 @@ struct pool { ...@@ -53,8 +53,8 @@ struct pool {
uintmax_t sdropped; uintmax_t sdropped;
uintmax_t rdropped; uintmax_t rdropped;
uintmax_t nqueued; uintmax_t nqueued;
struct VSC_main *a_stat; struct VSC_main_wrk *a_stat;
struct VSC_main *b_stat; struct VSC_main_wrk *b_stat;
struct mempool *mpl_req; struct mempool *mpl_req;
struct mempool *mpl_sess; struct mempool *mpl_sess;
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "vtim.h" #include "vtim.h"
void void
Req_AcctLogCharge(struct VSC_main *ds, struct req *req) Req_AcctLogCharge(struct VSC_main_wrk *ds, struct req *req)
{ {
struct acct_req *a; struct acct_req *a;
......
...@@ -318,7 +318,7 @@ void Req_Release(struct req *); ...@@ -318,7 +318,7 @@ void Req_Release(struct req *);
void Req_Rollback(struct req *req); void Req_Rollback(struct req *req);
void Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req); void Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req);
void Req_Fail(struct req *req, enum sess_close reason); void Req_Fail(struct req *req, enum sess_close reason);
void Req_AcctLogCharge(struct VSC_main *, struct req *); void Req_AcctLogCharge(struct VSC_main_wrk *, struct req *);
/* cache_req_body.c */ /* cache_req_body.c */
int VRB_Ignore(struct req *); int VRB_Ignore(struct req *);
......
...@@ -61,7 +61,7 @@ wrk_bgthread(void *arg) ...@@ -61,7 +61,7 @@ wrk_bgthread(void *arg)
{ {
struct bgthread *bt; struct bgthread *bt;
struct worker wrk; struct worker wrk;
struct VSC_main ds; struct VSC_main_wrk ds;
CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC); CAST_OBJ_NOTNULL(bt, arg, BGTHREAD_MAGIC);
THR_SetName(bt->name); THR_SetName(bt->name);
...@@ -98,7 +98,7 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace) ...@@ -98,7 +98,7 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace)
{ {
// child_signal_handler stack overflow check uses struct worker addr // child_signal_handler stack overflow check uses struct worker addr
struct worker *w, ww; struct worker *w, ww;
struct VSC_main ds; struct VSC_main_wrk ds;
unsigned char ws[thread_workspace]; unsigned char ws[thread_workspace];
AN(qp); AN(qp);
...@@ -133,11 +133,11 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace) ...@@ -133,11 +133,11 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace)
*/ */
static void static void
pool_addstat(struct VSC_main *dst, struct VSC_main *src) pool_addstat(struct VSC_main_wrk *dst, struct VSC_main_wrk *src)
{ {
dst->summs++; dst->summs++;
VSC_main_Summ(dst, src); VSC_main_Summ_wrk_wrk(dst, src);
memset(src, 0, sizeof *src); memset(src, 0, sizeof *src);
} }
......
...@@ -93,6 +93,7 @@ class CounterSet(object): ...@@ -93,6 +93,7 @@ class CounterSet(object):
self.head = m self.head = m
self.completed = False self.completed = False
self.off = 0 self.off = 0
self.gnames = None
def addmbr(self, m, g): def addmbr(self, m, g):
'''Add a counter''' '''Add a counter'''
...@@ -168,7 +169,13 @@ class CounterSet(object): ...@@ -168,7 +169,13 @@ class CounterSet(object):
fo.write(self.struct + " {\n") fo.write(self.struct + " {\n")
for i in self.mbrs: for i in self.mbrs:
fo.write("\tuint64_t\t%s;\n" % i.arg) s = "\tuint64_t\t%s;" % i.arg
g = i.param.get("group")
if g is not None:
while len(s.expandtabs()) < 64:
s += "\t"
s += "/* %s */" % g
fo.write(s + "\n")
fo.write("};\n") fo.write("};\n")
fo.write("\n") fo.write("\n")
...@@ -189,14 +196,19 @@ class CounterSet(object): ...@@ -189,14 +196,19 @@ class CounterSet(object):
fo.write("void VSC_" + self.name + "_Destroy") fo.write("void VSC_" + self.name + "_Destroy")
fo.write("(struct vsc_seg **);\n") fo.write("(struct vsc_seg **);\n")
if 'sumfunction' in self.head.param: sf = self.head.param.get('sumfunction')
fo.write("void VSC_" + self.name + "_Summ") if sf is not None:
fo.write("(" + self.struct + " *, ") for i in sf.split():
fo.write("const " + self.struct + " *);\n") j = i.split("_")
for i in self.gnames: assert len(j) <= 2
fo.write("void VSC_" + self.name + "_Summ_" + i) if len(j) == 1:
fo.write("(" + self.struct + " *, ") fo.write("void VSC_" + self.name + "_Summ_" + i)
fo.write("const " + self.struct + "_" + i + " *);\n") fo.write("(" + self.struct + " *, ")
fo.write("const " + self.struct + "_" + i + " *);\n")
else:
fo.write("void VSC_" + self.name + "_Summ_" + i)
fo.write("(" + self.struct + "_" + j[0] + " *, ")
fo.write("const " + self.struct + "_" + j[1] + " *);\n")
def emit_c_paranoia(self, fo): def emit_c_paranoia(self, fo):
'''Emit asserts to make sure compiler gets same byte index''' '''Emit asserts to make sure compiler gets same byte index'''
...@@ -211,27 +223,23 @@ class CounterSet(object): ...@@ -211,27 +223,23 @@ class CounterSet(object):
fo.write("#undef PARANOIA\n") fo.write("#undef PARANOIA\n")
def emit_c_sumfunc(self, fo, g=None): def emit_c_sumfunc(self, fo, tgt):
'''Emit a function summ up countersets''' '''Emit a function summ up countersets'''
fo.write("\n") fo.write("\n")
fo.write("void\n") fo.write("void\n")
fo.write("VSC_" + self.name + "_Summ") fo.write("VSC_" + self.name + "_Summ")
if g is not None: fo.write("_" + tgt[0])
fo.write("_" + g) if len(tgt) > 1:
fo.write("(" + self.struct + " *dst, ") fo.write("_" + tgt[1])
fo.write("const " + self.struct) fo.write("(" + self.struct + "_" + tgt[1])
if g is not None: else:
fo.write("_" + g) fo.write("(" + self.struct)
fo.write(" *src)\n") fo.write(" *dst, const " + self.struct + "_" + tgt[0] + " *src)\n")
fo.write("{\n") fo.write("{\n")
fo.write("\n") fo.write("\n")
fo.write("\tAN(dst);\n") fo.write("\tAN(dst);\n")
fo.write("\tAN(src);\n") fo.write("\tAN(src);\n")
if g: for i in self.groups[tgt[0]]:
l = self.groups[g]
else:
l = self.mbrs
for i in l:
s1 = "\tdst->" + i.arg + " +=" s1 = "\tdst->" + i.arg + " +="
s2 = "src->" + i.arg + ";" s2 = "src->" + i.arg + ";"
if len((s1 + " " + s2).expandtabs()) < 79: if len((s1 + " " + s2).expandtabs()) < 79:
...@@ -300,10 +308,10 @@ class CounterSet(object): ...@@ -300,10 +308,10 @@ class CounterSet(object):
self.emit_json(fo) self.emit_json(fo)
self.emit_c_newfunc(fo) self.emit_c_newfunc(fo)
self.emit_c_destroyfunc(fo) self.emit_c_destroyfunc(fo)
if 'sumfunction' in self.head.param: sf = self.head.param.get('sumfunction')
self.emit_c_sumfunc(fo) if sf is not None:
for i in self.gnames: for i in sf.split():
self.emit_c_sumfunc(fo, i) self.emit_c_sumfunc(fo, i.split("_"))
####################################################################### #######################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment