From 6b66296d3d5b9d427b62e18339d81f04e2e2386a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 26 Nov 2014 16:14:40 +0000 Subject: [PATCH] logger: Add optimization to avoid calling slow Boost interval_map too often. We can remove this optimization once Boost performance problems are resolved. --- logger.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/logger.c b/logger.c index 0cee8cf..c6a9c80 100644 --- a/logger.c +++ b/logger.c @@ -163,6 +163,8 @@ logger_unload (void) /* See log_operation below. */ struct operation { int is_read; + uint32_t count; + uint64_t offset; int priority; uint64_t start; uint64_t end; @@ -270,9 +272,21 @@ log_callback (uint64_t start, uint64_t end, const char *object, void *opaque) static void log_operation (struct handle *h, uint64_t offset, uint32_t count, int is_read) { + /* Because Boost interval_map is really bloody slow, implement a + * shortcut here. We can remove this once Boost performance + * problems have been fixed. + */ + if (h->current.is_read == is_read && + h->current.count == count && + h->current.offset == offset) + goto skip_find_range; + h->current.is_read = is_read; + h->current.count = count; + h->current.offset = offset; h->current.priority = 0; find_range (ranges, offset, offset+count, log_callback, h); + skip_find_range: if (h->current.priority > 0) { FILE *fp = logfp ? logfp : stdout; -- 1.8.3.1