Remove mutex profiling code

Mutex profiling code (used when the ISC_MUTEX_PROFILE preprocessor macro
is set to 1) has been broken for the past 3 years (since commit
0bed9bfc28) and nobody complained, which
is a strong indication that this code is not being used these days any
more.  External tools for both measuring performance and detecting
locking issues are already wired into various GitLab CI checks.  Drop
all code depending on the ISC_MUTEX_PROFILE preprocessor macro being
set.
This commit is contained in:
Michał Kępień
2021-12-09 12:24:12 +01:00
parent ea0b5dbd5d
commit 0964a94ad5
5 changed files with 2 additions and 271 deletions

View File

@@ -35,15 +35,9 @@ typedef pthread_cond_t isc_condition_t;
isc_condition_strbuf); \
}
#if ISC_MUTEX_PROFILE
#define isc_condition_wait(cp, mp) \
((pthread_cond_wait((cp), &((mp)->mutex)) == 0) ? ISC_R_SUCCESS \
: ISC_R_UNEXPECTED)
#else /* if ISC_MUTEX_PROFILE */
#define isc_condition_wait(cp, mp) \
((pthread_cond_wait((cp), (mp)) == 0) ? ISC_R_SUCCESS \
: ISC_R_UNEXPECTED)
#endif /* if ISC_MUTEX_PROFILE */
#define isc_condition_signal(cp) \
((pthread_cond_signal((cp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)

View File

@@ -37,30 +37,8 @@ extern pthread_mutexattr_t isc__mutex_attrs;
/* XXX We could do fancier error handling... */
/*!
* Define ISC_MUTEX_PROFILE to turn on profiling of mutexes by line. When
* enabled, isc_mutex_stats() can be used to print a table showing the
* number of times each type of mutex was locked and the amount of time
* waiting to obtain the lock.
*/
#ifndef ISC_MUTEX_PROFILE
#define ISC_MUTEX_PROFILE 0
#endif /* ifndef ISC_MUTEX_PROFILE */
#if ISC_MUTEX_PROFILE
typedef struct isc_mutexstats isc_mutexstats_t;
typedef struct {
pthread_mutex_t mutex; /*%< The actual mutex. */
isc_mutexstats_t *stats; /*%< Mutex statistics. */
} isc_mutex_t;
#else /* if ISC_MUTEX_PROFILE */
typedef pthread_mutex_t isc_mutex_t;
#endif /* if ISC_MUTEX_PROFILE */
#if ISC_MUTEX_PROFILE
#define isc_mutex_init(mp) isc_mutex_init_profile((mp), __FILE__, __LINE__)
#else /* if ISC_MUTEX_PROFILE */
#if ISC_MUTEX_DEBUG && defined(PTHREAD_MUTEX_ERRORCHECK)
#define isc_mutex_init(mp) isc_mutex_init_errcheck((mp))
#else /* if ISC_MUTEX_DEBUG && defined(PTHREAD_MUTEX_ERRORCHECK) */
@@ -68,56 +46,17 @@ typedef pthread_mutex_t isc_mutex_t;
void
isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line);
#endif /* if ISC_MUTEX_DEBUG && defined(PTHREAD_MUTEX_ERRORCHECK) */
#endif /* if ISC_MUTEX_PROFILE */
#if ISC_MUTEX_PROFILE
#define isc_mutex_lock(mp) isc_mutex_lock_profile((mp), __FILE__, __LINE__)
#else /* if ISC_MUTEX_PROFILE */
#define isc_mutex_lock(mp) \
((pthread_mutex_lock((mp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
#endif /* if ISC_MUTEX_PROFILE */
#if ISC_MUTEX_PROFILE
#define isc_mutex_unlock(mp) isc_mutex_unlock_profile((mp), __FILE__, __LINE__)
#else /* if ISC_MUTEX_PROFILE */
#define isc_mutex_unlock(mp) \
((pthread_mutex_unlock((mp)) == 0) ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
#endif /* if ISC_MUTEX_PROFILE */
#if ISC_MUTEX_PROFILE
#define isc_mutex_trylock(mp) \
((pthread_mutex_trylock((&(mp)->mutex)) == 0) ? ISC_R_SUCCESS \
: ISC_R_LOCKBUSY)
#else /* if ISC_MUTEX_PROFILE */
#define isc_mutex_trylock(mp) \
((pthread_mutex_trylock((mp)) == 0) ? ISC_R_SUCCESS : ISC_R_LOCKBUSY)
#endif /* if ISC_MUTEX_PROFILE */
#if ISC_MUTEX_PROFILE
#define isc_mutex_destroy(mp) \
RUNTIME_CHECK(pthread_mutex_destroy((&(mp)->mutex)) == 0)
#else /* if ISC_MUTEX_PROFILE */
#define isc_mutex_destroy(mp) RUNTIME_CHECK(pthread_mutex_destroy((mp)) == 0)
#endif /* if ISC_MUTEX_PROFILE */
#if ISC_MUTEX_PROFILE
#define isc_mutex_stats(fp) isc_mutex_statsprofile(fp);
#else /* if ISC_MUTEX_PROFILE */
#define isc_mutex_stats(fp)
#endif /* if ISC_MUTEX_PROFILE */
#if ISC_MUTEX_PROFILE
void
isc_mutex_init_profile(isc_mutex_t *mp, const char *_file, int _line);
isc_result_t
isc_mutex_lock_profile(isc_mutex_t *mp, const char *_file, int _line);
isc_result_t
isc_mutex_unlock_profile(isc_mutex_t *mp, const char *_file, int _line);
void
isc_mutex_statsprofile(FILE *fp);
#endif /* ISC_MUTEX_PROFILE */
void
isc_mutex_init_errcheck(isc_mutex_t *mp);