C++ slow build and early tester

I’m trying redis challenge with C++ and love it so far. Suddenly, around 10 stage, I’ve started to see in testrunner logs that build fails. I’ve tried to add -j2 to make and made it through couple of stages, but totally stuck for now.

I’m actively using separated modules, as it good for any project. As I see, with 10 modules (here, translation units for purists) build takes some time, but test runner tries to connect to server too early, finds that connection is refused and terminates build. Thus failing testing finally.

I think it may be real to bypass problem by squishing all in single module. But I feel extremely uncomfortable around testing system that forces me to do this. Also problem anyway will be present with more complex code, I think.

Thanks in advance, maybe I’ve oversaw something and somewhere exists simple solution for my problem.

Here’s sample log with uncommented cmake and make logs:

remote: [replication-4] Running tests for Replication > Stage #4: Initial Replication ID and Offset
remote: [replication-4] $ ./spawn_redis_server.sh
remote: [your_program] -- The C compiler identification is GNU 12.2.0
remote: [your_program] -- The CXX compiler identification is GNU 12.2.0
remote: [your_program] -- Detecting C compiler ABI info
remote: [your_program] -- Detecting C compiler ABI info - done
remote: [your_program] -- Check for working C compiler: /usr/bin/cc - skipped
remote: [your_program] -- Detecting C compile features
remote: [your_program] -- Detecting C compile features - done
remote: [your_program] -- Detecting CXX compiler ABI info
remote: [your_program] -- Detecting CXX compiler ABI info - done
remote: [your_program] -- Check for working CXX compiler: /usr/local/bin/c++ - skipped
remote: [your_program] -- Detecting CXX compile features
remote: [your_program] -- Detecting CXX compile features - done
remote: [your_program] -- Configuring done
remote: [your_program] -- Generating done
remote: [your_program] -- Build files have been written to: /app
remote: [your_program] Scanning dependencies of target server
remote: [your_program] [  9%] Building CXX object CMakeFiles/server.dir/src/client.cpp.o
remote: [your_program] [ 18%] Building CXX object CMakeFiles/server.dir/src/command.cpp.o
remote: [your_program] [ 27%] Building CXX object CMakeFiles/server.dir/src/main.cpp.o
remote: [your_program] [ 36%] Building CXX object CMakeFiles/server.dir/src/message.cpp.o
remote: [replication-4] dial tcp 127.0.0.1:6379: connect: connection refused
remote: [replication-4] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
remote: [your_program] make[2]: *** [CMakeFiles/server.dir/build.make:121: CMakeFiles/server.dir/src/message.cpp.o] Terminated
remote: [your_program] make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/server.dir/all] Terminated
remote: [your_program] make: *** [Makefile:103: all] Terminated
1 Like

@KpoxaPy thanks for reporting! This looks like a caching issue on our end - building should happen in a “[compile]” step that happens before the first test runs. We’ll look into this!

1 Like

@rohitpaulk Oh, I see! Thanks for clarifying! If I can help somehow, feel free to contact!

1 Like

Hey @KpoxaPy!

We’ve fixed this, but unfortunately the fix isn’t backward-compatible with cpp-20 (the version that your repository is currently on).

Could you try creating a new repository (you should get cpp-23 this time) and running tests there? The caching mechanism should work correctly there.

Alternatively I can manually upgrade your repository to cpp-23 (you might need to copy in some files like vcpkg.json etc). Let me know!

This was the PR, for reference: C++: cache entire build dir by ryan-gang · Pull Request #186 · codecrafters-io/build-your-own-redis · GitHub.

1 Like

Hey @rohitpaulk !

I’ve recreated repo and moved my work. Now it works nice!

Thanks a lot!

1 Like

Awesome, glad to hear!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.