uvw icon indicating copy to clipboard operation
uvw copied to clipboard

UVW v3

Open skypjack opened this issue 4 years ago β€’ 7 comments

A breaking change to set a tipping point for a new version of uvw, an updated coding style (with a more standard-ish snake style) and huge performance improvements during compilation. Feedback are highly appreciated. πŸ™‚

skypjack avatar Apr 07 '22 07:04 skypjack

Codecov Report

Merging #263 (c1e11a8) into master (b2ed37f) will increase coverage by 0.82%. The diff coverage is 97.01%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #263      +/-   ##
==========================================
+ Coverage   96.44%   97.27%   +0.82%     
==========================================
  Files          62       61       -1     
  Lines        2590     2420     -170     
==========================================
- Hits         2498     2354     -144     
+ Misses         92       66      -26     
Impacted Files Coverage Ξ”
src/uvw/poll.cpp 0.00% <0.00%> (ΓΈ)
src/uvw/loop.h 60.00% <69.23%> (+30.00%) :arrow_up:
src/uvw/signal.cpp 66.66% <71.42%> (ΓΈ)
src/uvw/stream.cpp 84.61% <84.61%> (-15.39%) :arrow_down:
src/uvw/util.cpp 86.58% <85.45%> (-3.93%) :arrow_down:
src/uvw/fs.h 85.71% <85.71%> (-5.96%) :arrow_down:
src/uvw/tty.cpp 87.50% <85.71%> (ΓΈ)
src/uvw/fs_event.cpp 92.85% <92.30%> (-1.27%) :arrow_down:
src/uvw/udp.cpp 93.61% <92.85%> (-1.74%) :arrow_down:
src/uvw/stream.h 93.93% <94.33%> (-1.30%) :arrow_down:
... and 57 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Apr 07 '22 07:04 codecov-commenter

@skypjack do you need any help to get the pipeline back to green too?

stefanofiorentino avatar Apr 07 '22 10:04 stefanofiorentino

Oh, well, put aside some sporadic failures mainly due to the poll tests, it depends on the reduced test coverage and I'm trying to increase it. Any help is appreciated ofc. πŸ™‚

skypjack avatar Apr 07 '22 10:04 skypjack

I really like the reduced compile time and find the multi_word_style much better than multiWordStyle for readers.

(not) just joking:

Optimal would be to have a programming language that allows spaces in identifiers and ideal if we had enough words to only ever use single word identifiers ... but these are topics left as exercises for later generations (and languages).

sthagen avatar Apr 07 '22 13:04 sthagen

@sthagen have you tried this branch already? I'm observing a huge improvement in terms of compilation time and I'm curious to know if it's a common thing. Also, feel free to drop comments, suggestions and complaints if you want. Any contribution is appreciated! πŸ™‚

skypjack avatar Apr 07 '22 22:04 skypjack

@skypjack I did not, but I hope to do it on the weekend (... there are traces of such "plans of mine" here on github where a day became a month ... πŸ€·πŸ½β€β™‚οΈ) I read through the hundred or so files in the change set and in theory it really looks good. Practice may decide differently on my machine, but I am confident and happy your machines already show the practical gains πŸš€

Sometimes when many functions change their return type from void to int (like in this PR) change sets risk to become a liability. But, typically in wrappers / proxies like this library, this only indicates the beneficial move from a hiding facade pattern to an open proxy that propagates the state info from the lower layers back to the caller instead of providing riddles to the callers :+1:

sthagen avatar Apr 08 '22 06:04 sthagen

Yeah, the idea is to make it more transparent and only add the work around memory and lifetime management on top of libuv. It doesn't make much sense to hide to the final user the error codes or any other thing, as if there wasn't libuv under the hood. πŸ˜…

skypjack avatar Apr 08 '22 06:04 skypjack

@skypjack it fails tests on my env (WSL2 ubuntu-20.04):

[ctest] ../test/uvw/loop.cpp:86: Failure
[ctest] Expected equality of these values:
[ctest]   count
[ctest]     Which is: 11
[ctest]   12u
[ctest]     Which is: 12

stefanofiorentino avatar Jan 17 '23 10:01 stefanofiorentino

Mmm any chance you can reproduce it? I don't know what's going on there otherwise. 😞

skypjack avatar Jan 17 '23 13:01 skypjack

Mmm any chance you can reproduce it? I don't know what's going on there otherwise. 😞

@stefanofiorentino ping πŸ™‚ I'd like to merge this one upstream but I can't reproduce nor fix the failure you mentioned. Any news about it?

skypjack avatar Feb 22 '23 17:02 skypjack

Some (little) investigations yield this:

  • the failing test is Loop.walk
  • by enabling USE_ASAN the "Loop" tests pass, but "616 byte(s) leaked in 5 allocation(s)".

I'm wondering, why we don't have USE_*SAN as github workflows?

stefanofiorentino avatar Feb 22 '23 21:02 stefanofiorentino

I'm wondering, why we don't have USE_*SAN as github workflows?

Testing a workflow for that on this branch. πŸ‘

skypjack avatar Feb 23 '23 15:02 skypjack

Cool @stefanofiorentino at least I can reproduce the error on the CI. Good catch. πŸ‘

skypjack avatar Feb 23 '23 15:02 skypjack

@skypjack launching them 1-by-1 with --gtest_filter only Loop.Close causes the leak.

stefanofiorentino avatar Feb 24 '23 16:02 stefanofiorentino

Probably the uv_loop_close returns UV_EBUSY. I've to stop investigations for a while.

stefanofiorentino avatar Feb 24 '23 16:02 stefanofiorentino

Oh, wait, I suspect the test is wrong actually. We're closing the handle after the loop. πŸ€¦β€β™‚οΈ Gotta go now but I'll give it a try during the weekend if possible. Thanks for checking it. ❀️

skypjack avatar Feb 24 '23 17:02 skypjack

I see the workflows here are green, but my local build (after a git force-clean) still complains:

test$ ./loop --gtest_list_tests | grep "^ " | sed 's/^ //g' | xargs -r -n1 -I '{}' bash -c "./loop --gtest_filter=*{} 2&>1 > /dev/null || echo {} test is KO" Walk test is KO

stefanofiorentino avatar Feb 24 '23 20:02 stefanofiorentino

What error do you get @stefanofiorentino Loop.walk, a wrong counter?

skypjack avatar Feb 27 '23 10:02 skypjack

What error do you get @stefanofiorentino Loop.walk, a wrong counter?

Yes, my cmake conf is

    "cmake.configureArgs": [
        "-DBUILD_TESTING:BOOL=TRUE"
    ]

and the error is still

[ctest] ../test/uvw/loop.cpp:88: Failure
[ctest] Expected equality of these values:
[ctest]   count
[ctest]     Which is: 11
[ctest]   12u
[ctest]     Which is: 12

stefanofiorentino avatar Feb 27 '23 12:02 stefanofiorentino

Yeah @stefanofiorentino that's this line:

loop->resource<uvw::tty_handle>(0, true);

If you run it from the command line, it causes your error. If you can confirm it, we can also drop the line from the test. πŸ‘

skypjack avatar Feb 28 '23 08:02 skypjack

Yeah @stefanofiorentino that's this line:

loop->resource<uvw::tty_handle>(0, true);

If you run it from the command line, it causes your error. If you can confirm it, we can also drop the line from the test. πŸ‘

Ok, as setsid sh -c "./test/loop" is working for me. I'm going to approve this ;)

stefanofiorentino avatar Feb 28 '23 10:02 stefanofiorentino

Any other concerns? I'd make this the upstream version. It has indecently faster compile times too.

skypjack avatar Mar 01 '23 08:03 skypjack

@skypjack we should definitely celebrate this day.

stefanofiorentino avatar Mar 10 '23 09:03 stefanofiorentino

Indeed, it's a huge improvement! Compilation time on the CI is already halved too. Very impressive.

skypjack avatar Mar 10 '23 15:03 skypjack