Merge lp:~mwhudson/libmemcached/misc-memaslap-fixes into lp:libmemcached

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: 1108
Proposed branch: lp:~mwhudson/libmemcached/misc-memaslap-fixes
Merge into: lp:libmemcached
Diff against target: 142 lines (+19/-14)
7 files modified
clients/include.am (+4/-0)
clients/memaslap.c (+4/-5)
clients/ms_memslap.h (+3/-3)
clients/ms_setting.c (+1/-1)
clients/ms_stats.c (+5/-2)
clients/ms_task.c (+2/-2)
m4/ax_harden_compiler_flags.m4 (+0/-1)
To merge this branch: bzr merge lp:~mwhudson/libmemcached/misc-memaslap-fixes
Reviewer Review Type Date Requested Status
Tangent Trunk Pending
Review via email: mp+188753@code.launchpad.net

Description of the change

Hi,

I've been using memaslap a bit and ran into an assortment of little problems, all fixed in this branch. Please see the individual commits for details. I can split this up into more single-purpose branches if that would be preferable.

Cheers,
mwh

To post a comment you must log in.
Revision history for this message
Brian Aker (brianaker) wrote :

memaslap was written by some folks who didn't maintain it... and frankly it is so ugly I tend to not to want to either.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Well, I can make another merge proposal that deletes it if that would be better :)

It seemed more capable and informative than memslap.

Revision history for this message
Brian Aker (brianaker) wrote :

BTW I am looking into why this seems to be failing in the build system.

Revision history for this message
Brian Aker (brianaker) wrote :

Why did you comment out -Wunsuffixed-float-constants?

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Brian Aker <email address hidden> writes:

> Why did you comment out -Wunsuffixed-float-constants?

Because putting 'd' after all the floating point constants seemed really
tedious and the syntax is only supported by relatively new versions of
gcc (gcc.gnu.org/bugzilla/show_bug.cgi?id=39027 -- well, 4.5, I guess
that's fairly old now).

FWIW, memaslap contains the only floaing point constants in the entire
codebase, as far as I could tell.

Cheers,
mwh

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clients/include.am'
2--- clients/include.am 2013-06-11 12:31:47 +0000
3+++ clients/include.am 2013-10-02 01:01:19 +0000
4@@ -94,9 +94,13 @@
5 clients_memaslap_SOURCES+= clients/ms_thread.c
6
7 clients_memaslap_SOURCES+= clients/generator.cc clients/execute.cc
8+
9+clients_memaslap_CXXFLAGS= @PTHREAD_CFLAGS@
10+
11 clients_memaslap_LDADD=
12 clients_memaslap_LDADD+= @LIBEVENT_LIB@
13 clients_memaslap_LDADD+= $(CLIENTS_LDADDS)
14+clients_memaslap_LDADD+= @PTHREAD_LIBS@
15
16 clients_memcapable_SOURCES=
17 clients_memcapable_SOURCES+= clients/memcapable.cc
18
19=== modified file 'clients/memaslap.c'
20--- clients/memaslap.c 2013-02-23 10:17:33 +0000
21+++ clients/memaslap.c 2013-10-02 01:01:19 +0000
22@@ -753,12 +753,12 @@
23
24 pos+= snprintf(pos,
25 sizeof(buf) - (size_t)(pos -buf),
26- "written_bytes: %lu\n",
27- (unsigned long) ms_stats.bytes_written);
28+ "written_bytes: %llu\n",
29+ (unsigned long long) ms_stats.bytes_written);
30 pos+= snprintf(pos,
31 sizeof(buf) - (size_t)(pos -buf),
32- "read_bytes: %lu\n",
33- (unsigned long) ms_stats.bytes_read);
34+ "read_bytes: %llu\n",
35+ (unsigned long long) ms_stats.bytes_read);
36 pos+= snprintf(pos,
37 sizeof(buf) - (size_t)(pos -buf),
38 "object_bytes: %lu\n",
39@@ -799,7 +799,6 @@
40 ms_stats.bytes_written
41 + ms_stats.bytes_read) / 1024 / 1024
42 / ((double)time_diff / 1000000));
43- assert(pos <= buf);
44
45 fprintf(stdout, "%s", buf);
46 fflush(stdout);
47
48=== modified file 'clients/ms_memslap.h'
49--- clients/ms_memslap.h 2011-04-28 00:28:00 +0000
50+++ clients/ms_memslap.h 2013-10-02 01:01:19 +0000
51@@ -72,9 +72,9 @@
52 typedef struct stats
53 {
54 volatile uint32_t active_conns; /* active connections */
55- size_t bytes_read; /* read bytes */
56- size_t bytes_written; /* written bytes */
57- size_t obj_bytes; /* object bytes */
58+ uint64_t bytes_read; /* read bytes */
59+ uint64_t bytes_written; /* written bytes */
60+ uint64_t obj_bytes; /* object bytes */
61 size_t pre_cmd_get; /* previous total get command count */
62 size_t pre_cmd_set; /* previous total set command count */
63 size_t cmd_get; /* current total get command count */
64
65=== modified file 'clients/ms_setting.c'
66--- clients/ms_setting.c 2012-11-19 04:57:41 +0000
67+++ clients/ms_setting.c 2013-10-02 01:01:19 +0000
68@@ -11,7 +11,7 @@
69
70 #include "mem_config.h"
71
72-#include <libmemcached/memcached.h>
73+#include <libmemcached-1.2/memcached.h>
74
75 #include <ctype.h>
76 #include <inttypes.h>
77
78=== modified file 'clients/ms_stats.c'
79--- clients/ms_stats.c 2012-11-19 04:57:41 +0000
80+++ clients/ms_stats.c 2013-10-02 01:01:19 +0000
81@@ -186,6 +186,8 @@
82 }
83 }
84
85+#pragma GCC diagnostic push
86+#pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
87 for (int i= min_non_zero; i <= max_non_zero; i++)
88 {
89 if ((i % 4) == 0)
90@@ -194,6 +196,7 @@
91 }
92 printf(" %6" PRIu64 , stat->dist[i]);
93 }
94+#pragma GCC diagnostic pop
95
96 printf("\n\n");
97 } /* ms_dump_stats */
98@@ -271,7 +274,7 @@
99 freq,
100 (long long)diff_events,
101 (long long)period_tps,
102- global_rate,
103+ period_rate,
104 (long long)(stat->get_miss - stat->pre_get_miss),
105 (long long)stat->period_min_time,
106 (long long)stat->period_max_time,
107@@ -285,7 +288,7 @@
108 run_time,
109 (long long)events,
110 (long long)global_tps,
111- period_rate,
112+ global_rate,
113 (long long)stat->get_miss,
114 (long long)stat->min_time,
115 (long long)stat->max_time,
116
117=== modified file 'clients/ms_task.c'
118--- clients/ms_task.c 2012-11-19 04:57:41 +0000
119+++ clients/ms_task.c 2013-10-02 01:01:19 +0000
120@@ -690,8 +690,8 @@
121 */
122 int64_t ms_time_diff(struct timeval *start_time, struct timeval *end_time)
123 {
124- int64_t endtime= end_time->tv_sec * 1000000 + end_time->tv_usec;
125- int64_t starttime= start_time->tv_sec * 1000000 + start_time->tv_usec;
126+ int64_t endtime= ((int64_t)end_time->tv_sec) * 1000000 + end_time->tv_usec;
127+ int64_t starttime= ((int64_t)start_time->tv_sec) * 1000000 + start_time->tv_usec;
128
129 assert(endtime >= starttime);
130
131
132=== modified file 'm4/ax_harden_compiler_flags.m4'
133--- m4/ax_harden_compiler_flags.m4 2013-09-16 06:38:46 +0000
134+++ m4/ax_harden_compiler_flags.m4 2013-10-02 01:01:19 +0000
135@@ -162,7 +162,6 @@
136 _APPEND_COMPILE_FLAGS_ERROR([-Wthis-test-should-fail])
137 # Anything below this comment please keep sorted.
138 # _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-format-attribute])
139- _APPEND_COMPILE_FLAGS_ERROR([-Wunsuffixed-float-constants])
140 _APPEND_COMPILE_FLAGS_ERROR([-Wjump-misses-init])
141 _APPEND_COMPILE_FLAGS_ERROR([-Wno-attributes])
142 _APPEND_COMPILE_FLAGS_ERROR([-Waddress])

Subscribers

People subscribed via source and target branches

to all changes: