Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
trackrdrd
Commits
4286e091
Commit
4286e091
authored
Jun 27, 2015
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make the worker thread size configurable and choose a sensible small default
parent
77bc0009
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
9 deletions
+34
-9
README.rst
README.rst
+5
-0
config.c
src/config.c
+2
-0
Makefile.am
src/test/Makefile.am
+2
-0
test_worker.c
src/test/test_worker.c
+2
-4
trackrdrd.h
src/trackrdrd.h
+1
-0
worker.c
src/worker.c
+22
-5
No files found.
README.rst
View file @
4286e091
...
...
@@ -492,6 +492,11 @@ Parameter CLI Option Description
-------------------- ---------- ----------------------------------------------------------------------------------------- -------
``nworkers`` Number of worker threads used to send messages to the message broker(s). 1
-------------------- ---------- ----------------------------------------------------------------------------------------- -------
``worker.stack`` Stack size for worker threads started by trackrdrd. 131072
Note: mq modules may start additional threads to which this limit does not apply
Observed actual stack sizes are <64k, so the default leaves plenty of room. (128 KB)
Increase only if segmentation faults on stack addresses are observed
-------------------- ---------- ----------------------------------------------------------------------------------------- -------
``max.records`` The maximum number of buffered records waiting to be sent to message brokers. 1024
-------------------- ---------- ----------------------------------------------------------------------------------------- -------
``max.reclen`` The maximum length of a data record in characters. Should be at least as large the 1024
...
...
src/config.c
View file @
4286e091
...
...
@@ -140,6 +140,7 @@ CONF_Add(const char *lval, const char *rval)
confUnsigned
(
"maxkeylen"
,
maxkeylen
);
confUnsigned
(
"qlen.goal"
,
qlen_goal
);
confUnsigned
(
"nworkers"
,
nworkers
);
confUnsigned
(
"worker.stack"
,
worker_stack
);
confUnsigned
(
"restarts"
,
restarts
);
confUnsigned
(
"restart.pause"
,
restart_pause
);
confUnsigned
(
"thread.restarts"
,
thread_restarts
);
...
...
@@ -239,6 +240,7 @@ CONF_Init(void)
config
.
mq_module
[
0
]
=
'\0'
;
config
.
mq_config_file
[
0
]
=
'\0'
;
config
.
nworkers
=
1
;
config
.
worker_stack
=
128
*
1024
;
config
.
restarts
=
1
;
config
.
restart_pause
=
1
;
config
.
thread_restarts
=
1
;
...
...
src/test/Makefile.am
View file @
4286e091
...
...
@@ -99,4 +99,6 @@ test_worker_LDADD = \
../data.
$(OBJEXT)
\
../assert.
$(OBJEXT)
\
../vtim.
$(OBJEXT)
\
../config.
$(OBJEXT)
\
../config_common.
$(OBJEXT)
\
-L
${
VARNISH_PKG_LIB
}
/varnish
-lvarnish
src/test/test_worker.c
View file @
4286e091
...
...
@@ -109,11 +109,9 @@ static char
printf
(
"... testing worker initialization
\n
"
);
config
.
max_records
=
DEF_MAX_RECORDS
;
config
.
max_reclen
=
DEF_MAX_RECLEN
;
config
.
maxkeylen
=
DEF_MAXKEYLEN
;
CONF_Init
();
config
.
nworkers
=
NWORKERS
;
config
.
chunk_size
=
DEF_CHUNK_SIZE
;
strcpy
(
config
.
mq_config_file
,
MQ_CONFIG
);
error
=
mqf
.
global_init
(
config
.
nworkers
,
config
.
mq_config_file
);
...
...
src/trackrdrd.h
View file @
4286e091
...
...
@@ -219,6 +219,7 @@ struct config {
#define DEF_QLEN_GOAL 512
unsigned
nworkers
;
size_t
worker_stack
;
unsigned
restarts
;
unsigned
restart_pause
;
unsigned
thread_restarts
;
...
...
src/worker.c
View file @
4286e091
...
...
@@ -405,22 +405,37 @@ WRK_Init(void)
return
0
;
}
void
wrk_pthread_attr_init
(
pthread_attr_t
*
attr
)
{
AZ
(
pthread_attr_init
(
attr
));
AZ
(
pthread_attr_setstacksize
(
attr
,
config
.
worker_stack
));
}
void
WRK_Start
(
void
)
{
pthread_attr_t
attr
;
wrk_pthread_attr_init
(
&
attr
);
run
=
1
;
for
(
int
i
=
0
;
i
<
config
.
nworkers
;
i
++
)
{
CHECK_OBJ_NOTNULL
(
thread_data
[
i
].
wrk_data
,
WORKER_DATA_MAGIC
);
AZ
(
pthread_create
(
&
thread_data
[
i
].
worker
,
NULL
,
wrk_main
,
AZ
(
pthread_create
(
&
thread_data
[
i
].
worker
,
&
attr
,
wrk_main
,
thread_data
[
i
].
wrk_data
));
}
AZ
(
pthread_attr_destroy
(
&
attr
));
}
int
WRK_Restart
(
void
)
{
int
err
=
0
;
worker_data_t
*
wrk
;
pthread_attr_t
attr
;
wrk_pthread_attr_init
(
&
attr
);
for
(
int
i
=
0
;
i
<
config
.
nworkers
;
i
++
)
{
CHECK_OBJ_NOTNULL
(
thread_data
[
i
].
wrk_data
,
WORKER_DATA_MAGIC
);
wrk
=
thread_data
[
i
].
wrk_data
;
...
...
@@ -442,18 +457,20 @@ WRK_Restart(void)
wrk
->
restarts
++
;
MON_StatsUpdate
(
STATS_RESTART
,
0
,
0
);
wrk
->
state
=
WRK_NOTSTARTED
;
if
(
pthread_create
(
&
thread_data
[
i
].
worker
,
NULL
,
wrk_main
,
wrk
)
if
(
pthread_create
(
&
thread_data
[
i
].
worker
,
&
attr
,
wrk_main
,
wrk
)
!=
0
)
{
/* EAGAIN means we've hit a system limit trying to restart
threads, so it's time to give up. Any other errno is a
programming error.
*/
assert
(
errno
==
EAGAIN
);
return
errno
;
err
=
errno
;
break
;
}
}
}
return
0
;
AZ
(
pthread_attr_destroy
(
&
attr
));
return
err
;
}
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment