Repository navigation
Add optional Redis secondary storage backend - #875
Conversation
677e26e to
7394b0c
Compare
Requires the "hiredis" library. Tests also requires redis-server and redis-cli. The attributes have not yet been implemented. Closes ccache#859.
7394b0c to
e93e8b4
Compare
That is: pkgconfig/hiredis.pc instead of
cmake/Hiredis/HiredisConfig.cmake
Needed for Homebrew, not needed for Ubuntu
7f812e9 to
1631f99
Compare
The include directory is supposed to be added to the search path (and it is, both for cmake and pkg-config) Unfortunately this exposes a "pedantic" warning about some C code not being valid C++ code, so suppress that.
|
Unfortunately there are some issues with the headers. The included "HiredisConfig.cmake" is broken, returning wrong include dir: find_path(HIREDIS_INCLUDE_DIRS hiredis/hiredis.h HINTS "/usr/include")
find_library(HIREDIS_LIB_HIREDIS NAMES hiredis HINTS "/usr/lib")Since you are supposed to include <hiredis.h> (as per the example code), the include directory needs to be "/usr/include/hiredis" However, when you do - you get an error from the pedantic C++ treating warnings as errors. (When parsing system header)
Final straw is that the different clang-format versions seem to argue about include order:
-#include <hiredis/hiredis.h>
#include <storage/SecondaryStorage.hpp>
#include <storage/types.hpp>
+#include <hiredis/hiredis.h>
+When it comes to system headers, as compared to local headers (such as storage) |
You could try making that include dir as a Another option is surrounding the include in your code with: #if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wall"
#endif
#include <hiredis.h>
#if defined(__clang__)
#pragma clang diagnostic pop
#endifBut with multiple compilers that gets ugly pretty fast. |
This comment has been minimized.
This comment has been minimized.
Since it doesn't work, use pkg-config
Making it more like the secondary_file
Issued from older (18.04) versions of clang
Otherwise it doesn't work for static lib
|
No idea why Redis won't shut down on Mac, would be thankful if someone could check it ?
Here (on Ubuntu) it runs faster than the file test, and shuts down happily once test is done. Added a 10 second timeout, that should kill the redis-server. Possibly we should mock the file access and redis access ? |
They are all optional (for now), though.
|
Thanks for working on this! The title says "WIP" but the PR is not marked as a draft. Do you want me to start reviewing or is it still WIP?
I would spontaneously say that setting up the include path so that you
I think that's not different clang-format versions but different configuration since I changed how include grouping works on master very recently.
I have no idea either, but if it blocks you I'd say just disable the test on macOS for now. |
Sorry, some other github projects use "WIP" with a bot that sets a "work-in-progress-do-not-merge" label... It is ready for review now, but could possibly need some squashing and rebasing before eventually merging ?
There are no immediate downsides, it should work on "both" platforms (Ubuntu and Homebrew) It is just that it is documented (examples and pkg-config) as And we would need to add the homebrew prefix, if not relying on pkg-config for the include dir. I seem to recall similar issues earlier when using glib, with <glib/glib.h> versus <glib.h> ?
The tests do pass, the only downside is that the test takedown takes an extra ~9 (10 - 1) seconds... Instead of shutting down immediately when test is done (1s), it waits for the timeout (10s) to happen |
|
It seems that there is a <module>_PREFIX variable set up in cmake when using So if we don't want to use I have no idea why CMake adds two similar variables, and they don't seem to match the documentation: deb (from CMakeCache.txt, some variables not shown) brew (from CMakeCache.txt, some variables not shown) include_directories(${HIREDIS_INCLUDEDIR}) EDIT: |
Changed it, and it fell apart. So there is definitely some difference between Locally: $ VERBOSE=1 misc/format-files --all --check
clang-format version 10.0.1 (https://github.com/muttleyxd/clang-format-static-binaries 22538c65f5523303768249afb8b52742bd0b7f32)
$GitHub CI: Would it help, if it the local files didn't use system includes ? #pragma once
#include "storage/SecondaryStorage.hpp"
#include "storage/types.hpp"
#include <hiredis/hiredis.h> |
Unfortunately this exposes a "pedantic" warning about some C code not being valid C++ code, so suppress that.
|
Looks like it doesn't build on Windows after all.
Inclined to going back to just disabling Redis there. EDIT: Seems that I had just missed to include a hiredis <win32.h> header. Except that the whole thing is guarded by #include <winsock2.h> /* for struct timeval */ |
Issued from older (18.04) versions of clang
8368cbb to
5e6afb2
Compare
It was added in hiredis 1.0.0
|
There are still test flakes on Mac, the server starts up in 3 us but it still cannot contact Redis ?
And the new
After 10 seconds the timeout kicks in, and stops the server. |
I think you should add #ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endifto |
|
Right, I included the local headers before the system headers.. <DOH> But since we're not using CLI defines, I guess I also need config.h in there ? Should try to get a MinGW build environment setup again, failing for some reason...
Looks like that cmake output is "normal", but still ended up with a compile error. Seems like this compiler is too old for ccache. ../../src/Stat.cpp:67:38: error: ‘FILE_ATTRIBUTE_TAG_INFO’ does not name a type; did you mean ‘FILE_ATTRIBUTE_OFFLINE’? ../../src/Stat.cpp:144:12: error: ‘GetFileInformationByHandleEx’ was not declared in this scope; did you mean ‘GetFileInformationByHandle’? |
Also do it in the header, before timeval
Right, we need a static library with
It seems like there is a static library target on hiredis master but it's not included in a release yet. Maybe we should just give up and bundle dependencies instead... 🤔 |
For this library we could go back to making it optional, and disable it on Windows. I would be fine with making it compile on Windows of course, like this You could (as a user) use something like MSYS2, to handle the system dependencies. |
ccache/cmake/StandardSettings.cmake Lines 7 to 10 in 39c2589 |
I'm OK with it being optional (as in "opt out"), but it should be easy enough to create a static library of our own for the Windows build. But I think you can leave the Redis backend disabled for the Windows builds for now so that it doesn't block your PR progress. Then I can have a look at improving this later. Sounds OK? |
|
Sounds good, then I can remove some of the other hacks as well. Maybe leave Maybe this was apparent, but the aim was to do a squash and rebase before merging this work-in-progress :-D |
Sure. And you don't have to squash unless you want to – I always do that as part of merging anyway (unless it's obvious that the PR author has separated stuff in clean commits). |
|
I mostly meant the merges and the reverts, but there were some other minor fixes that could be squashed together. |
62d91c0 to
e0f6b2c
Compare
|
Thanks! |
Requires the "hiredis" library.
https://github.com/redis/hiredis
Tests also requires redis-server and redis-cli.
Closes #859.