Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43AA9107CB for ; Fri, 19 Jul 2013 23:47:15 +0000 (UTC) Received: (qmail 56888 invoked by uid 500); 19 Jul 2013 23:47:15 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 56866 invoked by uid 500); 19 Jul 2013 23:47:15 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 56859 invoked by uid 99); 19 Jul 2013 23:47:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jul 2013 23:47:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jul 2013 23:47:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9EA3E2388906; Fri, 19 Jul 2013 23:46:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1505065 - in /subversion/trunk: ./ tools/dev/fsfs-access-map.c Date: Fri, 19 Jul 2013 23:46:50 -0000 To: commits@subversion.apache.org From: stefan2@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130719234650.9EA3E2388906@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: stefan2 Date: Fri Jul 19 23:46:50 2013 New Revision: 1505065 URL: http://svn.apache.org/r1505065 Log: Merge revisions r1444693,1444695,1445040,1491784 from branches/fsfs-format7. These contain all updates to the fsfs-access-map dev tool. Modified: subversion/trunk/ (props changed) subversion/trunk/tools/dev/fsfs-access-map.c Propchange: subversion/trunk/ ------------------------------------------------------------------------------ Merged /subversion/branches/fsfs-format7:r1444693,1444695,1445040,1491784 Modified: subversion/trunk/tools/dev/fsfs-access-map.c URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/fsfs-access-map.c?rev=1505065&r1=1505064&r2=1505065&view=diff ============================================================================== --- subversion/trunk/tools/dev/fsfs-access-map.c (original) +++ subversion/trunk/tools/dev/fsfs-access-map.c Fri Jul 19 23:46:50 2013 @@ -92,6 +92,9 @@ typedef struct handle_info_t typedef unsigned char byte; typedef unsigned short word; +/* an RGB color */ +typedef byte color_t[3]; + /* global const char * file name -> *file_info_t map */ static apr_hash_t *files = NULL; @@ -188,6 +191,14 @@ open_file(const char *name, int handle) else file->rev_num = -1; + /* filter out log/phys index files */ + if (file->rev_num >= 0) + { + const char *suffix = name + strlen(name) - 4; + if (strcmp(suffix, ".l2p") == 0 || strcmp(suffix, ".p2l") == 0) + file->rev_num = -1; + } + apr_hash_set(files, file->name, APR_HASH_KEY_STRING, file); } @@ -275,10 +286,17 @@ parse_line(svn_stringbuf_t *line) char *return_value = strrchr(line->data, ' '); char *first_param_end; apr_int64_t func_return = 0; + char *func_start = strchr(line->data, ' '); if (func_end == NULL || return_value == NULL) return; + if (func_start == NULL || func_start > func_end) + func_start = line->data; + else + while(*func_start == ' ') + func_start++; + first_param_end = strchr(func_end, ','); if (first_param_end == NULL) first_param_end = strchr(func_end, ')'); @@ -295,7 +313,7 @@ parse_line(svn_stringbuf_t *line) svn_error_clear(svn_cstring_atoi64(&func_return, return_value)); /* process those operations that we care about */ - if (strcmp(line->data, "open") == 0) + if (strcmp(func_start, "open") == 0) { /* remove double quotes from file name parameter */ *func_end++ = 0; @@ -303,11 +321,11 @@ parse_line(svn_stringbuf_t *line) open_file(func_end, (int)func_return); } - else if (strcmp(line->data, "read") == 0) + else if (strcmp(func_start, "read") == 0) read_file(atoi(func_end), func_return); - else if (strcmp(line->data, "lseek") == 0) + else if (strcmp(func_start, "lseek") == 0) seek_file(atoi(func_end), func_return); - else if (strcmp(line->data, "close") == 0) + else if (strcmp(func_start, "close") == 0) close_file(atoi(func_end)); } @@ -494,17 +512,82 @@ write_bitmap_header(apr_file_t *file, in apr_file_write(file, header, &written); } -/* write the cluster read map for all files in INFO as BMP image to FILE. +/* To COLOR, add the fractional value of SOURCE from fractional indexes + * SOURCE_START to SOURCE_END and apply the SCALING_FACTOR. + */ +static void +add_sample(color_t color, + color_t *source, + double source_start, + double source_end, + double scaling_factor) +{ + double factor = (source_end - source_start) / scaling_factor; + + apr_size_t i; + for (i = 0; i < sizeof(color_t) / sizeof(*color); ++i) + color[i] += (source_end - source_start < 0.5) && source_start > 1.0 + ? factor * source[(apr_size_t)source_start - 1][i] + : factor * source[(apr_size_t)source_start][i]; +} + +/* Scale the IN_LEN RGB values from IN to OUT_LEN RGB values in OUT. + */ +static void +scale_line(color_t* out, + apr_size_t out_len, + color_t *in, + apr_size_t in_len) +{ + double scaling_factor = (double)(in_len) / (double)(out_len); + + apr_size_t i; + memset(out, 0, out_len * sizeof(color_t)); + for (i = 0; i < out_len; ++i) + { + color_t color = { 0 }; + + double source_start = i * scaling_factor; + double source_end = (i + 1) * scaling_factor; + + if ((apr_size_t)source_start == (apr_size_t)source_end) + { + add_sample(color, in, source_start, source_end, scaling_factor); + } + else + { + apr_size_t k; + apr_size_t first_sample_end = (apr_size_t)source_start + 1; + apr_size_t last_sample_start = (apr_size_t)source_end; + + add_sample(color, in, source_start, first_sample_end, scaling_factor); + for (k = first_sample_end; k < last_sample_start; ++k) + add_sample(color, in, k, k + 1, scaling_factor); + + add_sample(color, in, last_sample_start, source_end, scaling_factor); + } + + memcpy(out[i], color, sizeof(color)); + } +} + +/* Write the cluster read map for all files in INFO as BMP image to FILE. + * If MAX_X is not 0, scale all lines to MAX_X pixels. Use POOL for + * allocations. */ static void -write_bitmap(apr_array_header_t *info, apr_file_t *file) +write_bitmap(apr_array_header_t *info, + apr_size_t max_x, + apr_file_t *file, + apr_pool_t *pool) { int ysize = info->nelts; int xsize = 0; int x, y; int row_size; - int padding; apr_size_t written; + color_t *line, *scaled_line; + svn_boolean_t do_scale = max_x > 0; /* xsize = max cluster number */ for (y = 0; y < ysize; ++y) @@ -516,37 +599,40 @@ write_bitmap(apr_array_header_t *info, a xsize = 0x3fff; if (ysize >= 0x4000) ysize = 0x3fff; + if (max_x == 0) + max_x = xsize; /* rows in BMP files must be aligned to 4 bytes */ - row_size = APR_ALIGN(xsize * 3, 4); - padding = row_size - xsize * 3; + row_size = APR_ALIGN(max_x * sizeof(color_t), 4); + /**/ + line = apr_pcalloc(pool, xsize * sizeof(color_t)); + scaled_line = apr_pcalloc(pool, row_size); + /* write header to file */ - write_bitmap_header(file, xsize, ysize); + write_bitmap_header(file, max_x, ysize); /* write all rows */ for (y = 0; y < ysize; ++y) { file_stats_t *file_info = APR_ARRAY_IDX(info, y, file_stats_t *); + int block_count = file_info->read_map->nelts; for (x = 0; x < xsize; ++x) { - byte color[3] = { 128, 128, 128 }; - if (x < file_info->read_map->nelts) + color_t color = { 128, 128, 128 }; + if (x < block_count) { word count = APR_ARRAY_IDX(file_info->read_map, x, word); select_color(color, count); } - written = sizeof(color); - apr_file_write(file, color, &written); + memcpy(line[x], color, sizeof(color)); } - if (padding) - { - char pad[3] = { 0 }; - written = padding; - apr_file_write(file, pad, &written); - } + scale_line(scaled_line, max_x, line, block_count ? block_count : 1); + + written = row_size; + apr_file_write(file, do_scale ? scaled_line : line, &written); } } @@ -665,7 +751,13 @@ int main(int argc, const char *argv[]) apr_file_open(&file, "access.bmp", APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED, APR_OS_DEFAULT, pool); - write_bitmap(get_rev_files(pool), file); + write_bitmap(get_rev_files(pool), 0, file, pool); + apr_file_close(file); + + apr_file_open(&file, "access_scaled.bmp", + APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BUFFERED, + APR_OS_DEFAULT, pool); + write_bitmap(get_rev_files(pool), 1024, file, pool); apr_file_close(file); apr_file_open(&file, "scale.bmp",