-
Notifications
You must be signed in to change notification settings - Fork 136
Conversation
I assume this is still a work in progress? |
yeah, I'm actually stuck at trying to get this linked with libuv |
@AshfordN The "My" prefix for disambiguation might be better as "Raft". Just a thought. Would also like to get some darwin love in on these changes but I guess that can happen with a followup after this lands. |
Codecov Report
@@ Coverage Diff @@
## master #119 +/- ##
==========================================
- Coverage 86.1% 86.08% -0.03%
==========================================
Files 47 47
Lines 7436 6892 -544
Branches 1166 1142 -24
==========================================
- Hits 6403 5933 -470
+ Misses 1028 959 -69
+ Partials 5 0 -5
Continue to review full report at Codecov.
|
What's the status of this branch? Is it ready for review and possibly landing? |
@AshfordN ? ^^^ |
Hey, |
No worries!
The article itself has this comment at the bottom:
So can't use use
Not sure I'll be able to provide much feedback, since I'm not familiar with Windows. From my point of view, as long as the code works on Windows (something which I trust you to test) and does not break Linux (something which will be tested automatically by Travis), I've no objection merging your work. |
It's not as straight forward. I made a short comment in my version of |
Ah I see. There are very few cases were aligned_malloc is needed (basically just for direct I/O), it should not be too bad to special-case them and use a dedicated free(). |
#ifdef _WIN32 | ||
int UvOsFallocate(uv_file fd, off_t offset, off_t len) | ||
{ | ||
//TODO: implement functionality | ||
return 0; | ||
} | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like posix_fallocate
is also missing on OSX, I found out that mozilla is faking it by using ftruncate
under the hood.
https://stackoverflow.com/a/11497568/1941280
EDIT: I found a better implementation, even if I can't find why I can't bootstrap the raft on OSX, probably due to this function.
EDIT: It seems to work on OSX now, thanks to your PR, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's now a:
static int uvOsFallocateEmulation(int fd, off_t offset, off_t len)
in uv_os.c
that can be used to emulate posix_fallocate
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately, statfs
and pwrite
used by uvOsFallocateEmulation
are not available in mingw
.
Hey @AshfordN / @Kerollmops , what's the status of this PR? As far as I can tell, with the introduction of |
Hey, @Kerollmops am I to understand that your branch is working on OSX? |
@freeekanayaka also, does my fallback code here look sensible? |
That might be enough in practice, although it does not completely match the current semantics: for example Considering that the current implementation already has fallback support for performing the writes using libuv's threadpool (which is exactly how the |
It seems to do the work but I didn't tried it, I didn't tried to create a wrapper of this API around the Rust Allocator API, sorry. I will neither be able to test that in a near futur, but in my understading this
I wouldn't say that it works but at least it compiles and kind of run until it locks or something. No more messages are passed between peer. It is really hard to debug this kind of stuff and don't have much time to allocate to it :/ |
This might be due to the questionable implementation of the fallback code discussed above. The fix might not be too difficult based on what @freeekanayaka said, but I'd have to figure out the build process so that I can at least test the code. Unfortunately I can't give a definite timeline for this PR, but I will try to complete the work. |
Has there been any non-public work on this lately? While I don't have a lot of time, it would be cool to get this running on OSX. I have it compiled and kind-of working... but I definitely don't trust it. |
Not that I'm aware of. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to cross compile this branch, with a few changes using mingw. It seems to work. The changes I made can be viewed here:
https://github.com/gabriel-samfira/raft/tree/hack
This branch rebases your changes and adds a few changes that were needed to get dqlite to build against it. The dqlite branch (if you're curious), is here:
https://github.com/gabriel-samfira/dqlite/pull/new/hack-it-to-bits
I have to mention that my C skills are extremely lacking. I essentially learned enough C to hack this with an axe in an attempt to get it to build with mingw. The goal was not to make a merge-able PR. So as you go through my branch(es), prepare to cringe...a lot.
# The libuv raft_io implementation is built by default if libuv is found, unless | ||
# explicitely disabled. | ||
AC_ARG_ENABLE(uv, AS_HELP_STRING([--disable-uv], [do not build the libuv-based raft_io implementation])) | ||
AS_IF([test "x$enable_uv" != "xno"], | ||
[PKG_CHECK_MODULES(UV, [libuv >= 1.8.0], [have_uv=yes], [have_uv=no])], | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not needed. The reason you've had a hard time linking raft to libuv is because there is a bug in the pkg-config wrapper for cross-building. There is a discussion about it here:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492
It should be fixed by this:
https://salsa.debian.org/mingw-w64-team/mingw-w64/commit/17f8832bff1d2e6eadfb878f7d5afb056d200364
but that change does not seem to be available in Focal.
In any case, you can get around it by simply doing:
export PKG_CONFIG_LIBDIR=/usr/x86_64-w64-mingw32/lib/
@@ -101,6 +123,7 @@ CC_CHECK_CFLAGS_APPEND([-Wendif-labels]) | |||
CC_CHECK_CFLAGS_APPEND([-Wdate-time]) | |||
CC_CHECK_CFLAGS_APPEND([-Wnested-externs]) | |||
CC_CHECK_CFLAGS_APPEND([-Wconversion]) | |||
AS_CASE([$host_os],[mingw*],[CC_CHECK_CFLAGS_APPEND([-D__USE_MINGW_ANSI_STDIO])]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aparently, using -D__USE_MINGW_ANSI_STDIO
is deprecated. I added:
case $host in
*mingw*)
# -D__USE_MINGW_ANSI_STDIO is deprecated it seems.
CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[-D_POSIX])
;;
esac
to get rid of the formatting warnings.
#ifdef _WIN32 | ||
int UvOsFallocate(uv_file fd, off_t offset, off_t len) | ||
{ | ||
//TODO: implement functionality | ||
return 0; | ||
} | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately, statfs
and pwrite
used by uvOsFallocateEmulation
are not available in mingw
.
Interesting PR, tempting to crack open my Windows development environment which has been lying dormant for over a year now. clang is also worth a consideration for windows, it compiles native Windows binaries now (though I think you still need to use a different linker, unless that's changed since I last looked at it). Although mingw is a nice alternative also, clang is more native. If you compile directly on Windows also, it might make it easier to run the test suite on Windows. |
No description provided.