node icon indicating copy to clipboard operation
node copied to clipboard

src: modernize cleanup queue to use c++20

Open anonrig opened this issue 11 months ago β€’ 8 comments
trafficstars

Getting the idea from @jasnell on https://github.com/nodejs/node/pull/56059, let's use std::ranges::sort and spaceship operator to sort with std::ranges::sort which is available on C++20.

anonrig avatar Nov 28 '24 18:11 anonrig

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 87.99%. Comparing base (4cf6fab) to head (2a94e99). Report is 438 commits behind head on main.

Files with missing lines Patch % Lines
src/cleanup_queue-inl.h 71.42% 1 Missing and 1 partial :warning:
src/cleanup_queue.cc 75.00% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56063      +/-   ##
==========================================
- Coverage   88.00%   87.99%   -0.01%     
==========================================
  Files         656      656              
  Lines      188988   189002      +14     
  Branches    35992    35988       -4     
==========================================
- Hits       166315   166310       -5     
- Misses      15838    15849      +11     
- Partials     6835     6843       +8     
Files with missing lines Coverage Ξ”
src/cleanup_queue.h 100.00% <ΓΈ> (ΓΈ)
src/cleanup_queue.cc 81.25% <75.00%> (-4.47%) :arrow_down:
src/cleanup_queue-inl.h 85.00% <71.42%> (-7.31%) :arrow_down:

... and 27 files with indirect coverage changes

codecov[bot] avatar Nov 28 '24 20:11 codecov[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/63785/

nodejs-github-bot avatar Nov 29 '24 17:11 nodejs-github-bot

cc @nodejs/build is there a limitation in macOS regarding this?

12:42:22 ../src/cleanup_queue-inl.h:35:17: error: no member named 'strong_ordering' in namespace 'std'
12:42:22     return std::strong_ordering::greater;
12:42:22            ~~~~~^
12:42:22 ../src/cleanup_queue-inl.h:39:17: error: no member named 'strong_ordering' in namespace 'std'
12:42:22     return std::strong_ordering::less;
12:42:22            ~~~~~^
12:42:22 ../src/cleanup_queue-inl.h:41:15: error: no member named 'strong_ordering' in namespace 'std'
12:42:22   return std::strong_ordering::equivalent;
12:42:22          ~~~~~^

anonrig avatar Nov 29 '24 20:11 anonrig

Are you missing an #include <compare>

jasnell avatar Nov 29 '24 20:11 jasnell

Are you missing an #include <compare>

Yes, but is it only required on macOS?

anonrig avatar Nov 29 '24 21:11 anonrig

CI: https://ci.nodejs.org/job/node-test-pull-request/63793/

nodejs-github-bot avatar Nov 29 '24 22:11 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/63801/

nodejs-github-bot avatar Nov 30 '24 01:11 nodejs-github-bot

cc @nodejs/build This is blocked my macOS infrastructure as well.

20:44:45 ../src/cleanup_queue.cc:3:10: fatal error: 'ranges' file not found
20:44:45 #include <ranges>
20:44:45          ^~~~~~~~
20:44:46 1 error generated.

anonrig avatar Dec 02 '24 14:12 anonrig

@anonrig do you know if this is still being blocked by macos test runners?

jasnell avatar Jan 22 '25 19:01 jasnell

@anonrig do you know if this is still being blocked by macos test runners?

Yes it is still blocked

anonrig avatar Jan 23 '25 00:01 anonrig

@nodejs/platform-macos

jasnell avatar Jan 23 '25 01:01 jasnell

CI: https://ci.nodejs.org/job/node-test-pull-request/64844/

nodejs-github-bot avatar Jan 30 '25 15:01 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/64860/

nodejs-github-bot avatar Jan 31 '25 01:01 nodejs-github-bot

Landed in 581b44421ac399c0b9ed051b1779e69f5b2457df

nodejs-github-bot avatar Jan 31 '25 13:01 nodejs-github-bot

It seems this broke the "Test Linux" workflow. Is a GCC update needed?

lpinca avatar Jan 31 '25 14:01 lpinca

It's probably the opposite: I guess GCC was updated in the GitHub runners since the last push (two months ago) and includes new warnings.

targos avatar Jan 31 '25 14:01 targos

It seems this broke the "Test Linux" action. Is a GCC update needed?

No the only blocker for this was the macOS build. So Linux shouldn't break unless something changed that's outside of the scope of this Pr in the past 2 months, that broke this pr when it landed.

anonrig avatar Jan 31 '25 14:01 anonrig

@targos I am away from keyboard. Can you revert this PR? I can re-land it later. Right now your v8 work is more important.

anonrig avatar Jan 31 '25 14:01 anonrig

FWIW the error is:

../src/cleanup_queue.cc:18:32: error: 'greater' may not intend to support class template argument deduction [-Werror,-Wctad-maybe-unsupported]
   18 |   std::ranges::sort(callbacks, std::greater());
      |                                ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/stl_function.h:390:12: note: add a deduction guide to suppress this warning
  390 |     struct greater : public binary_function<_Tp, _Tp, bool>
      |            ^
1 error generated.

lpinca avatar Jan 31 '25 14:01 lpinca

The "Test Linux" workflow uses clang, not GCC. https://github.com/nodejs/node/blob/261624bb06f40b4fab410211148f8fdcfa33d209/.github/workflows/test-linux.yml#L28-L29

richardlau avatar Jan 31 '25 14:01 richardlau

The "Test Linux" workflow uses clang, not GCC.

Although FWIW https://github.com/actions/runner-images/pull/11197 back in December updated GNU C++ from 13.2.0 to 13.3.0.

richardlau avatar Jan 31 '25 14:01 richardlau

I am away from keyboard. Can you revert this PR? I can re-land it later. Right now your v8 work is more important.

https://github.com/nodejs/node/pull/56846

richardlau avatar Jan 31 '25 15:01 richardlau