From: Timo Sirainen Date: Thu, 2 Dec 2021 09:35:20 +0000 (+0200) Subject: lib-index: Use ATTR_COLD for error/corruption handling functions X-Git-Tag: 2.3.18~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fb3dda9ac1b89b4fce737066895edb0b0d5f580;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Use ATTR_COLD for error/corruption handling functions This could reduce CPU usage due to better branch prediction. --- diff --git a/src/lib-index/mail-cache-private.h b/src/lib-index/mail-cache-private.h index 4871c9bbb8..c2fee17612 100644 --- a/src/lib-index/mail-cache-private.h +++ b/src/lib-index/mail-cache-private.h @@ -416,6 +416,6 @@ int mail_cache_expunge_handler(struct mail_index_sync_map_ctx *sync_ctx, const void *data, void **sync_context); void mail_cache_set_syscall_error(struct mail_cache *cache, - const char *function); + const char *function) ATTR_COLD; #endif diff --git a/src/lib-index/mail-cache.h b/src/lib-index/mail-cache.h index a42baf8432..09fde2941f 100644 --- a/src/lib-index/mail-cache.h +++ b/src/lib-index/mail-cache.h @@ -179,9 +179,10 @@ int mail_cache_lookup_headers(struct mail_cache_view *view, string_t *dest, /* "Error in index cache file %s: ...". */ void mail_cache_set_corrupted(struct mail_cache *cache, const char *fmt, ...) - ATTR_FORMAT(2, 3); + ATTR_FORMAT(2, 3) ATTR_COLD; void mail_cache_set_seq_corrupted_reason(struct mail_cache_view *cache_view, - uint32_t seq, const char *reason); + uint32_t seq, const char *reason) + ATTR_COLD; /* Returns human-readable reason for why a cached field is missing for the specified mail. This is mainly for debugging purposes, so the exact diff --git a/src/lib-index/mail-index-private.h b/src/lib-index/mail-index-private.h index 7efaf6bf5d..e0736daf5c 100644 --- a/src/lib-index/mail-index-private.h +++ b/src/lib-index/mail-index-private.h @@ -412,15 +412,16 @@ void mail_index_fsck_locked(struct mail_index *index); /* Log an error and set it as the index's current error that is available with mail_index_get_error_message(). */ void mail_index_set_error(struct mail_index *index, const char *fmt, ...) - ATTR_FORMAT(2, 3); + ATTR_FORMAT(2, 3) ATTR_COLD; /* Same as mail_index_set_error(), but don't log the error. */ -void mail_index_set_error_nolog(struct mail_index *index, const char *str); +void mail_index_set_error_nolog(struct mail_index *index, const char *str) + ATTR_COLD; /* "%s failed with index file %s: %m" */ void mail_index_set_syscall_error(struct mail_index *index, - const char *function); + const char *function) ATTR_COLD; /* "%s failed with file %s: %m" */ void mail_index_file_set_syscall_error(struct mail_index *index, const char *filepath, - const char *function); + const char *function) ATTR_COLD; #endif diff --git a/src/lib-index/mail-index-strmap.h b/src/lib-index/mail-index-strmap.h index 5366a97479..c61afa629a 100644 --- a/src/lib-index/mail-index-strmap.h +++ b/src/lib-index/mail-index-strmap.h @@ -56,7 +56,8 @@ mail_index_strmap_view_open(struct mail_index_strmap *strmap, const ARRAY_TYPE(mail_index_strmap_rec) **recs_r, const struct hash2_table **hash_r); void mail_index_strmap_view_close(struct mail_index_strmap_view **view); -void mail_index_strmap_view_set_corrupted(struct mail_index_strmap_view *view); +void mail_index_strmap_view_set_corrupted(struct mail_index_strmap_view *view) + ATTR_COLD; /* Return the highest used string index. */ uint32_t mail_index_strmap_view_get_highest_idx(struct mail_index_strmap_view *view); diff --git a/src/lib-index/mail-index-sync-private.h b/src/lib-index/mail-index-sync-private.h index 4dbf37be75..094c83d90b 100644 --- a/src/lib-index/mail-index-sync-private.h +++ b/src/lib-index/mail-index-sync-private.h @@ -94,7 +94,8 @@ mail_index_sync_keywords_reset(struct mail_index_sync_map_ctx *ctx, const struct mail_transaction_keyword_reset *r); void mail_index_sync_set_corrupted(struct mail_index_sync_map_ctx *ctx, - const char *fmt, ...) ATTR_FORMAT(2, 3); + const char *fmt, ...) + ATTR_FORMAT(2, 3) ATTR_COLD; #ifdef DEBUG void mail_index_map_check(struct mail_index_map *map); diff --git a/src/lib-index/mail-index.h b/src/lib-index/mail-index.h index 4a397f4810..de8c285b81 100644 --- a/src/lib-index/mail-index.h +++ b/src/lib-index/mail-index.h @@ -556,10 +556,10 @@ bool mail_index_is_locked(struct mail_index *index); /* Mark index file corrupted in memory and delete it from disk. Invalidates all views. This should be called only for index files that can safely be recreated without any data loss. */ -void mail_index_mark_corrupted(struct mail_index *index); +void mail_index_mark_corrupted(struct mail_index *index) ATTR_COLD; /* Check and fix any found problems. Returns -1 if we couldn't lock for sync, 0 if everything went ok. */ -int mail_index_fsck(struct mail_index *index); +int mail_index_fsck(struct mail_index *index) ATTR_COLD; /* Returns TRUE if mail_index_fsck() has been called since the last mail_index_reset_fscked() call. */ bool mail_index_reset_fscked(struct mail_index *index); diff --git a/src/lib-index/mail-transaction-log-private.h b/src/lib-index/mail-transaction-log-private.h index f08aefb025..4961fe0ab1 100644 --- a/src/lib-index/mail-transaction-log-private.h +++ b/src/lib-index/mail-transaction-log-private.h @@ -141,7 +141,7 @@ struct mail_transaction_log { void mail_transaction_log_file_set_corrupted(struct mail_transaction_log_file *file, const char *fmt, ...) - ATTR_FORMAT(2, 3); + ATTR_FORMAT(2, 3) ATTR_COLD; void mail_transaction_log_get_dotlock_set(struct mail_transaction_log *log, struct dotlock_settings *set_r); diff --git a/src/lib-index/mail-transaction-log.h b/src/lib-index/mail-transaction-log.h index 59a6e93cb4..c19bb206a0 100644 --- a/src/lib-index/mail-transaction-log.h +++ b/src/lib-index/mail-transaction-log.h @@ -450,7 +450,7 @@ bool mail_transaction_log_view_is_last(struct mail_transaction_log_view *view); void mail_transaction_log_view_set_corrupted(struct mail_transaction_log_view *view, const char *fmt, ...) - ATTR_FORMAT(2, 3); + ATTR_FORMAT(2, 3) ATTR_COLD; bool mail_transaction_log_view_is_corrupted(struct mail_transaction_log_view *view);