Ported Redis to Windows

453 views
Skip to first unread message

Dušan Majkić

unread,
Oct 15, 2010, 9:26:50 PM10/15/10
to rubyin...@googlegroups.com
Hi.

Just inform people here that I ported redis db
to Windows using Mingw from ruby devkit.

Redis is fairly new NoSQL Key-Value datastore.
More about it on http://redis.io

If you have ruby DevKit you can clone my repository
and build redis using make from devkit command line.

For running tests you will need Tcl that is not inlcluded
in Devkit installation, but I installed it from source.

Source code

http://github.com/dmajkic/redis

Prebuild binaries (Win32)

http://github.com/dmajkic/redis/downloads

--
Regards
Dusan Majkic

sgwong

unread,
Oct 16, 2010, 8:02:57 AM10/16/10
to RubyInstaller
I tried to compile the src but it doesn't work because cc not
available. After looking at the Makefile, seems like the uname doesn't
match. I am using Win7 64bit and uname return "MINGW32_NT-6.1". After
fixing this and it able to compile successfully.

On Oct 16, 9:26 am, Dušan Majkić <dmaj...@gmail.com> wrote:
> Hi.
>
> Just inform people here that I ported redis db
> to Windows using Mingw from ruby devkit.
>
> Redis is fairly new NoSQL Key-Value datastore.
> More about it onhttp://redis.io

sgwong

unread,
Oct 16, 2010, 8:46:30 AM10/16/10
to RubyInstaller
I run the test with activestate tcl and the tcl bin name is tclsh85
(not tclsh8.5 in the makefile).

I tried to run the test but it seems like having little problem on
test execution(I am using 64bit tcl 8.5 not sure it has issue or not).
First the test hang after:

#213 intsets implementation stress
testing PASSED

I cancel the test and comment all the passing test and rerun again.
then it hang again at:

#148 WATCH will not consider touched expired
keys PASSED

BTW, all test PASSED which is really good. :)


On Oct 16, 8:02 pm, sgwong <sgwong...@gmail.com> wrote:
> I tried to compile the src but it doesn't work because cc not
> available. After looking at the Makefile, seems like the uname doesn't
> match. I am using Win7 64bit and uname return "MINGW32_NT-6.1". After
> fixing this and it able to compile successfully.
>

Jon

unread,
Oct 16, 2010, 9:09:05 AM10/16/10
to rubyin...@googlegroups.com

Very nice! Will have to give it a try.

I'm assuming you built it with DevKit 4.5.0? Have you had a chance to try building with the "edge" DevKit 4.5.1 that can be create from running "rake devkit sfx=1" from the http://github.com/oneclick/rubyinstaller/tree/dk32-451 branch?

If you're really feeling adventurous and want to burn some time, you could try build an edge DevKit based upon LLVM-GCC v2.8 and see how it works by running "rake devkit sfx=1 dkver=llvm-32-2.8" from the same dk32-451 branch. Of course you'd need to tell Redis's configure/make that CC=llvm-gcc, CXX=llvm-g++, and maybe CPP=llvm-cpp. And then watch out for any calls to dllwrap (needs --driver-name=llvm-gcc) and windres (needs --preprocessor="llvm-gcc -E -xc") and probably a few other things ;)

Thanks,
Jon

sgwong

unread,
Oct 16, 2010, 12:17:41 PM10/16/10
to RubyInstaller
I'm using DevKit 4.5.0. I just have a try on llvm-32-2.8. It fails to
compile b'coz missing usleep. So, I implement usleep with sleep like
this(copy from sqlite src if I remember it correctly ):

void usleep(microseconds){
int seconds = (microseconds+999999)/1000000;
sleep(seconds);
}

I compare the redis-benchmark for llvm and gcc, llvm is much
faster(dunno why): gcc(4421 req/sec) llvm-gcc(5651 req/sec).
However, llvm version fails couple of test :(, too bad....

#004 ZRANGE
basics !! ERROR
Expected 'c a b d' to be equal to 'a b c d'
#005 ZREVRANGE
basics EXCEPTION

Caught error: ERR value is not a double
Logged warnings (pid 5992):

#056 SORT sorted set: +inf and -inf
handling EXCEPTION

Caught error: ERR value is not a double
Logged warnings (pid 4640):

=== ("other") Starting server 127.0.0.1:16381 ok
#013 SAVE - make sure there are all the types as
values EXCEPTION

Caught error: Bad protocol, as reply type byte
Logged warnings (pid 5332):

=== ("repl") Starting server 127.0.0.1:16381 ok
=== () Starting server 127.0.0.1:16382 ok
#015 First server should have role slave after
SLAVEOF EXCEPTION

Caught error: Bad protocol, as reply type byte
Logged warnings (pid 4912):

On Oct 16, 9:09 pm, Jon <jon.for...@gmail.com> wrote:
> > Hi.
>
> > Just inform people here that I ported redis db
> > to Windows using Mingw from ruby devkit.
>
> > Redis is fairly new NoSQL Key-Value datastore.
> > More about it onhttp://redis.io

Dušan Majkić

unread,
Oct 16, 2010, 2:42:48 PM10/16/10
to rubyin...@googlegroups.com
> I'm using DevKit 4.5.0. I just have a try on llvm-32-2.8. It fails to
> compile b'coz missing usleep.

I checked where redis is using usleep, and it is used in vm.c
in three places: once to usleep(1), which is in Windows
pronounced as Sleep(0) (give time slice to thread).

And in other two places it waits 10000 and 100000 which can
be directly translated to Sleep() from windows api.

That is good news: No fine-grain picosecod timer is actually
needed. This two lines should work for both llvm and mingw:

#undef usleep
#define usleep(x) (x == 1) ? Sleep(0) : Sleep((int)((x)/1000))

Basicly it translates usleep(1) -> Sleep(0) and others
usleep(x) -> Sleep(x/1000).


> However, llvm version fails couple of test :(, too bad....

Will check that also.
I Installed llvm devkit, and there are a few more warnings.

Stay tuned.

Dušan Majkić

unread,
Oct 16, 2010, 2:47:31 PM10/16/10
to rubyin...@googlegroups.com
> I tried to run the test but it seems like having little problem on
> test execution(I am using 64bit tcl 8.5 not sure it has issue or not).
> First the test hang after:

Could you check if there are log files in tests/tmp/server.XXXX
Check stdout or stderr files for error messages.

If you have process id from hanged server, that can help also.
Every line in stdout file starts with it. Like: [6004] 16 Oct 20:..

Luis Lavena

unread,
Oct 16, 2010, 3:30:43 PM10/16/10
to rubyin...@googlegroups.com
Hello Dušan,

2010/10/15 Dušan Majkić <dma...@gmail.com>:


> Hi.
>
> Just inform people here that I ported redis db
> to Windows using Mingw from ruby devkit.
>

Thank you. this is an impressive amount of work that I wanted to
tackle long ago but neither my skills or time allowed me to.

I hope this work can be integrated in antirez's repository so other
benefits from it.

Something I noticed from your announcement in redis group is that
commands that depend on fork() are executed in-process.

I was thinking perhaps a separate thread can be spawned so calls to
BGSAVE and BGREWRITEAOF do not interfere with redis accepting
requests.

Again, thank you. Impressive work you have done on this.

I was wondering if you're interested in help Brian Ford on port
Rubinius to Windows? I wish I can be involved more but work has been
pretty much climbing up.

Anyhow, thank you!
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Dušan Majkić

unread,
Oct 16, 2010, 4:22:33 PM10/16/10
to rubyin...@googlegroups.com
> Something I noticed from your announcement in redis group is that
> commands that depend on fork() are executed in-process.

Fork() itself is not so much important here. Redis uses nice side effect
of fork and that is that modern unix/linux will provide memory snapshot
virtually for free, in no time. Copy-On-Write protected.

That means that both processes work with same memory, but
when parent writes something, kernel will copy that mem block so that
child process is not affected in any way.

In fact, these forked calls are transaction replacement.
In SQL DB kind of thinking.

You can CreateProcess (or Thread) in Windows, but you can't give
Copy-On-Write protected access to memory to child process.
If you want Copy-On-Write you must use CreateFileMapping.

Cygwin fork() will copy all memory from parent to child.
Not efficent in case of redis, since BGSAVE will than copy mem+copy
to disk. Slow, double work, with great risk from "Out of memory" error.

> I was thinking perhaps a separate thread can be spawned so calls to
> BGSAVE and BGREWRITEAOF do not interfere with redis accepting
> requests.

Yup. Same thinking here.
Just need to find a way to protect objects beings saved from altering
or deletion from main thread. I needed redis for in-memory only
helper storage, so this solution did the job.

> I was wondering if you're interested in help Brian Ford on port
> Rubinius to Windows? I wish I can be involved more but work
> has been pretty much climbing up.

I am not that much skilled in cpp to be of any usable help.
Will take a look. No promises.

Jon

unread,
Oct 17, 2010, 11:36:51 AM10/17/10
to rubyin...@googlegroups.com


I think you both are doing very cool things here with Redis, DevKit, and the RubyInstaller.

When you two get things working and are both happy with the results, would you mind linking a tutorial blog to our project wiki at http://github.com/oneclick/rubyinstaller/wiki/Tutorials

Thank you,
Jon

intellectdev

unread,
Oct 17, 2010, 3:34:39 PM10/17/10
to RubyInstaller
I was waiting for a windows port. This is highly appreciated. I hope
work on this continues to keep it on par with the unix version.

On Oct 16, 6:26 am, Dušan Majkić <dmaj...@gmail.com> wrote:
> Hi.
>
> Just inform people here that I ported redis db
> to Windows using Mingw from ruby devkit.
>
> Redis is fairly new NoSQL Key-Value datastore.
> More about it onhttp://redis.io
Reply all
Reply to author
Forward
0 new messages