Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
5cbc73c6
Unverified
Commit
5cbc73c6
authored
Aug 30, 2019
by
jared
Committed by
GitHub
Aug 30, 2019
Browse files
Merge pull request #1 from antirez/unstable
merge redis
parents
a16aa03a
d5536e04
Changes
166
Show whitespace changes
Inline
Side-by-side
utils/install_server.sh
View file @
5cbc73c6
...
...
@@ -43,6 +43,9 @@
#
# /!\ This script should be run as root
#
# NOTE: This script will not work on Mac OSX.
# It supports Debian and Ubuntu Linux.
#
################################################################################
die
()
{
...
...
utils/releasetools/changelog.tcl
View file @
5cbc73c6
#!/usr/bin/env tclsh
if
{[
llength $::argv
]
!= 2
}
{
puts
"Usage:
$::argv0
<branch> <version>"
if
{[
llength $::argv
]
!= 2
&&
[
llength $::argv
]
!= 3
}
{
puts
"Usage:
$::argv0
<branch> <version>
\[
<num-commits>
\]
"
exit 1
}
set branch
[
lindex $::argv 0
]
set ver
[
lindex $::argv 1
]
if
{[
llength $::argv
]
== 3
}
{
set count
[
lindex ::$argv 2
]
}
else
{
set count 100
}
set template
{
================================================================================
...
...
@@ -21,7 +26,7 @@ append template "\n\n"
set date
[
clock format
[
clock seconds
]]
set template
[
string map
[
list %ver% $ver %date% $date
]
$template
]
append template
[
exec git log $branch~
100
..$branch
"--format=format:%an in commit %h:%n %s"
--shortstat
]
append template
[
exec git log $branch~
$count
..$branch
"--format=format:%an in commit %h:%n %s"
--shortstat
]
#Older, more verbose version.
#
...
...
utils/srandmember/README.md
0 → 100644
View file @
5cbc73c6
The utilities in this directory plot the distribution of SRANDMEMBER to
evaluate how fair it is.
See http://theshfl.com/redis_sets for more information on the topic that lead
to such investigation fix.
showdist.rb -- shows the distribution of the frequency elements are returned.
The x axis is the number of times elements were returned, and
the y axis is how many elements were returned with such
frequency.
showfreq.rb -- shows the frequency each element was returned.
The x axis is the element number.
The y axis is the times it was returned.
utils/srandmember/showdist.rb
0 → 100644
View file @
5cbc73c6
require
'redis'
r
=
Redis
.
new
r
.
select
(
9
)
r
.
del
(
"myset"
);
r
.
sadd
(
"myset"
,(
0
..
999
).
to_a
)
freq
=
{}
100
.
times
{
res
=
r
.
pipelined
{
1000
.
times
{
r
.
srandmember
(
"myset"
)
}
}
res
.
each
{
|
ele
|
freq
[
ele
]
=
0
if
freq
[
ele
]
==
nil
freq
[
ele
]
+=
1
}
}
# Convert into frequency distribution
dist
=
{}
freq
.
each
{
|
item
,
count
|
dist
[
count
]
=
0
if
dist
[
count
]
==
nil
dist
[
count
]
+=
1
}
min
=
dist
.
keys
.
min
max
=
dist
.
keys
.
max
(
min
..
max
).
each
{
|
x
|
count
=
dist
[
x
]
count
=
0
if
count
==
nil
puts
"
#{
x
}
->
#{
"*"
*
count
}
"
}
utils/srandmember/showfreq.rb
0 → 100644
View file @
5cbc73c6
require
'redis'
r
=
Redis
.
new
r
.
select
(
9
)
r
.
del
(
"myset"
);
r
.
sadd
(
"myset"
,(
0
..
999
).
to_a
)
freq
=
{}
500
.
times
{
res
=
r
.
pipelined
{
1000
.
times
{
r
.
srandmember
(
"myset"
)
}
}
res
.
each
{
|
ele
|
freq
[
ele
]
=
0
if
freq
[
ele
]
==
nil
freq
[
ele
]
+=
1
}
}
# Print the frequency each element was yeld to process it with gnuplot
freq
.
each
{
|
item
,
count
|
puts
"
#{
item
}
#{
count
}
"
}
utils/tracking_collisions.c
0 → 100644
View file @
5cbc73c6
/* This is a small program used in order to understand the collison rate
* of CRC64 (ISO version) VS other stronger hashing functions in the context
* of hashing keys for the Redis "tracking" feature (client side caching
* assisted by the server).
*
* The program attempts to hash keys with common names in the form of
*
* prefix:<counter>
*
* And counts the resulting collisons generated in the 24 bits of output
* needed for the tracking feature invalidation table (16 millions + entries)
*
* Compile with:
*
* cc -O2 ./tracking_collisions.c ../src/crc64.c ../src/sha1.c
* ./a.out
*
* --------------------------------------------------------------------------
*
* Copyright (C) 2019 Salvatore Sanfilippo
* This code is released under the BSD 2 clause license.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include "../src/crc64.h"
#include "../src/sha1.h"
#define TABLE_SIZE (1<<24)
int
Table
[
TABLE_SIZE
];
uint64_t
crc64Hash
(
char
*
key
,
size_t
len
)
{
return
crc64
(
0
,(
unsigned
char
*
)
key
,
len
);
}
uint64_t
sha1Hash
(
char
*
key
,
size_t
len
)
{
SHA1_CTX
ctx
;
unsigned
char
hash
[
20
];
SHA1Init
(
&
ctx
);
SHA1Update
(
&
ctx
,(
unsigned
char
*
)
key
,
len
);
SHA1Final
(
hash
,
&
ctx
);
uint64_t
hash64
;
memcpy
(
&
hash64
,
hash
,
sizeof
(
hash64
));
return
hash64
;
}
/* Test the hashing function provided as callback and return the
* number of collisions found. */
unsigned
long
testHashingFunction
(
uint64_t
(
*
hash
)(
char
*
,
size_t
))
{
unsigned
long
collisions
=
0
;
memset
(
Table
,
0
,
sizeof
(
Table
));
char
*
prefixes
[]
=
{
"object"
,
"message"
,
"user"
,
NULL
};
for
(
int
i
=
0
;
prefixes
[
i
]
!=
NULL
;
i
++
)
{
for
(
int
j
=
0
;
j
<
TABLE_SIZE
/
2
;
j
++
)
{
char
keyname
[
128
];
size_t
keylen
=
snprintf
(
keyname
,
sizeof
(
keyname
),
"%s:%d"
,
prefixes
[
i
],
j
);
uint64_t
bucket
=
hash
(
keyname
,
keylen
)
%
TABLE_SIZE
;
if
(
Table
[
bucket
])
{
collisions
++
;
}
else
{
Table
[
bucket
]
=
1
;
}
}
}
return
collisions
;
}
int
main
(
void
)
{
printf
(
"SHA1 : %lu
\n
"
,
testHashingFunction
(
sha1Hash
));
printf
(
"CRC64: %lu
\n
"
,
testHashingFunction
(
crc64Hash
));
return
0
;
}
Prev
1
…
5
6
7
8
9
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment