redmine

Added auto-adjustment of "HL_LOCK_TRIES"

... ... @@ -158,7 +158,23 @@ filesz:1M\n\
// How long to wait on highloaded locks before fallback to mutexes
// See: doc/devel/thread-splitting/highload-locks/clsync-graph-comma.odc
#define HL_LOCK_TRYES (1<<13)
// But optimal value can be very different on different systems
#define HL_LOCK_TRIES_INITIAL (1<<13)
// Enable run-time auto-adjustment
#define HL_LOCK_TRIES_AUTO
// Iterations delay between adjustments (power of 2; 2^x)
#define HL_LOCK_AUTO_INTERVAL 10 /* 1024 */
// Initial adjustment factor
#define HL_LOCK_AUTO_K 1.1
// Delay detection error threshold
#define HL_LOCK_AUTO_THREADHOLD 0.2
// Adjustment factor denominator
#define HL_LOCK_AUTO_DECELERATION 1.1
// Don't adjust if the factor is less than
#define HL_LOCK_AUTO_K_FINISH 1.001
// Upper limit
#define HL_LOCK_AUTO_LIMIT_HIGH (1<<20)
//#define READWRITE_SIGNALLING
... ...
... ... @@ -108,6 +108,7 @@ enum flags_enum {
DETACH_NETWORK = 32|OPTION_LONGOPTONLY,
DETACH_MISCELLANEA = 33|OPTION_LONGOPTONLY,
ADDPERMITTEDHOOKFILES = 34|OPTION_LONGOPTONLY,
HL_LOCK_LIMIT = 35|OPTION_LONGOPTONLY,
};
typedef enum flags_enum flags_t;
... ...
... ... @@ -68,7 +68,7 @@ static inline uint32_t recognize_event(uint32_t event) {
int inotify_add_watch_dir(ctx_t *ctx_p, indexes_t *indexes_p, const char *const accpath) {
int inotify_d = (int)(long)ctx_p->fsmondata;
return privileged_inotify_add_watch(inotify_d, accpath, INOTIFY_MARKMASK);
return privileged_inotify_add_watch(inotify_d, accpath, INOTIFY_MARKMASK, PC_INOTIFY_ADD_WATCH_DIR);
}
int inotify_wait(ctx_t *ctx_p, struct indexes *indexes_p, struct timeval *tv_p) {
... ...
This diff is collapsed. Click to expand it.
... ... @@ -17,44 +17,107 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HL_LOCK_TRIES_AUTO
# define IF_HL_LOCK_TRIES_AUTO(a) a
#else
# define IF_HL_LOCK_TRIES_AUTO(a) {}
#endif
#ifdef CAPABILITIES_SUPPORT
extern FTS *(*privileged_fts_open) (
enum priv_callid {
PC_DEFAULT = 0,
PC_SYNC_INIIALSYNC_WALK_FTS_OPEN,
PC_SYNC_INIIALSYNC_WALK_FTS_READ,
PC_SYNC_INIIALSYNC_WALK_FTS_CLOSE,
PC_SYNC_MARK_WALK_FTS_OPEN,
PC_SYNC_MARK_WALK_FTS_READ,
PC_SYNC_MARK_WALK_FTS_CLOSE,
PC_INOTIFY_ADD_WATCH_DIR,
PC_MAX
};
extern FTS *(*_privileged_fts_open) (
char * const *path_argv,
int options,
int (*compar)(const FTSENT **, const FTSENT **)
# ifdef HL_LOCK_TRIES_AUTO
, int callid
# endif
);
extern FTSENT *(*_privileged_fts_read) (
FTS *ftsp
# ifdef HL_LOCK_TRIES_AUTO
, int callid
# endif
);
extern FTSENT *(*privileged_fts_read) (FTS *ftsp);
extern int (*privileged_fts_close) (FTS *ftsp);
extern int (*privileged_inotify_init) ();
extern int (*privileged_inotify_init1) (int flags);
extern int (*_privileged_fts_close) (
FTS *ftsp
# ifdef HL_LOCK_TRIES_AUTO
, int callid
# endif
);
extern int (*privileged_inotify_add_watch) (
extern int (*_privileged_inotify_init) ();
extern int (*_privileged_inotify_init1) (int flags);
extern int (*_privileged_inotify_add_watch) (
int fd,
const char *pathname,
uint32_t mask
# ifdef HL_LOCK_TRIES_AUTO
, int callid
# endif
);
extern int (*privileged_inotify_rm_watch) (
extern int (*_privileged_inotify_rm_watch) (
int fd,
int wd
);
# ifdef HL_LOCK_TRIES_AUTO
# define privileged_fts_open(a,b,c,d) _privileged_fts_open(a,b,c,d)
# define privileged_fts_read(a,b) _privileged_fts_read(a,b)
# define privileged_fts_close(a,b) _privileged_fts_close(a,b)
# define privileged_inotify_add_watch(a,b,c,d) _privileged_inotify_add_watch(a,b,c,d)
# else
# define privileged_fts_open(a,b,c,d) _privileged_fts_open(a,b,c)
# define privileged_fts_read(a,b) _privileged_fts_read(a)
# define privileged_fts_close(a,b) _privileged_fts_close(a)
# define privileged_inotify_add_watch(a,b,c,d) _privileged_inotify_add_watch(a,b,c)
# endif
# define privileged_inotify_init _privileged_inotify_init
# define privileged_inotify_init1 _privileged_inotify_init1
# define privileged_inotify_rm_watch _privileged_inotify_rm_watch
#else
#define privileged_fts_open fts_open
#define privileged_fts_read fts_read
#define privileged_fts_close fts_close
#define privileged_inotify_init inotify_init
#define privileged_inotify_init1 inotify_init1
#define privileged_inotify_add_watch inotify_add_watch
#define privileged_inotify_rm_watch inotify_rm_watch
# define privileged_fts_open(a,b,c,d) fts_open(a,b,c)
# define privileged_fts_read(a,b) fts_read(a)
# define privileged_fts_close(a,b) fts_close(a)
# define privileged_inotify_init inotify_init
# define privileged_inotify_init1 inotify_init1
# define privileged_inotify_add_watch(a,b,c,d) inotify_add_watch(a,b,c)
# define privileged_inotify_rm_watch inotify_rm_watch
#endif
extern int (*privileged_kill_child)(pid_t pid, int sig);
extern int (*privileged_fork_execvp)(const char *file, char *const argv[]);
extern int (*_privileged_kill_child)(
pid_t pid,
int sig
);
extern int (*_privileged_fork_execvp)(
const char *file,
char *const argv[]
);
#define privileged_kill_child _privileged_kill_child
#define privileged_fork_execvp _privileged_fork_execvp
extern int privileged_init(struct ctx *ctx_p);
extern int privileged_deinit(struct ctx *ctx_p);
... ...
... ... @@ -1342,7 +1342,7 @@ int sync_initialsync_walk(ctx_t *ctx_p, const char *dirpath, indexes_t *indexes_
debug(3, "fts_opts == %p", (void *)(long)fts_opts);
tree = privileged_fts_open((char *const *)&rootpaths, fts_opts, NULL);
tree = privileged_fts_open((char *const *)&rootpaths, fts_opts, NULL, PC_SYNC_INIIALSYNC_WALK_FTS_OPEN);
if (tree == NULL) {
error("Cannot privileged_fts_open() on \"%s\".", dirpath);
... ... @@ -1355,7 +1355,7 @@ int sync_initialsync_walk(ctx_t *ctx_p, const char *dirpath, indexes_t *indexes_
char *path_rel = NULL;
size_t path_rel_len = 0;
while ((node = privileged_fts_read(tree))) {
while ((node = privileged_fts_read(tree, PC_SYNC_INIIALSYNC_WALK_FTS_READ))) {
switch (node->fts_info) {
// Duplicates:
case FTS_DP:
... ... @@ -1458,7 +1458,7 @@ int sync_initialsync_walk(ctx_t *ctx_p, const char *dirpath, indexes_t *indexes_
goto l_sync_initialsync_walk_end;
}
if (privileged_fts_close(tree)) {
if (privileged_fts_close(tree, PC_SYNC_INIIALSYNC_WALK_FTS_CLOSE)) {
error("Got error while privileged_fts_close().");
ret = errno;
goto l_sync_initialsync_walk_end;
... ... @@ -1746,7 +1746,7 @@ int sync_mark_walk(ctx_t *ctx_p, const char *dirpath, indexes_t *indexes_p) {
int fts_opts = FTS_NOCHDIR|FTS_PHYSICAL|FTS_NOSTAT|(ctx_p->flags[ONEFILESYSTEM]?FTS_XDEV:0);
debug(3, "fts_opts == %p", (void *)(long)fts_opts);
tree = privileged_fts_open((char *const *)&rootpaths, fts_opts, NULL);
tree = privileged_fts_open((char *const *)&rootpaths, fts_opts, NULL, PC_SYNC_MARK_WALK_FTS_OPEN);
if (tree == NULL) {
error_or_debug((ctx_p->state == STATE_STARTING) ?-1:2, "Cannot privileged_fts_open() on \"%s\".", dirpath);
... ... @@ -1757,7 +1757,7 @@ int sync_mark_walk(ctx_t *ctx_p, const char *dirpath, indexes_t *indexes_p) {
char *path_rel = NULL;
size_t path_rel_len = 0;
while ((node = privileged_fts_read(tree))) {
while ((node = privileged_fts_read(tree, PC_SYNC_MARK_WALK_FTS_READ))) {
#ifdef CLUSTER_SUPPORT
int ret;
#endif
... ... @@ -1828,7 +1828,7 @@ int sync_mark_walk(ctx_t *ctx_p, const char *dirpath, indexes_t *indexes_p) {
goto l_sync_mark_walk_end;
}
if (privileged_fts_close(tree)) {
if (privileged_fts_close(tree, PC_SYNC_MARK_WALK_FTS_CLOSE)) {
error_or_debug((ctx_p->state == STATE_STARTING) ?-1:2, "Got error while privileged_fts_close().");
ret = errno;
goto l_sync_mark_walk_end;
... ...