Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add UDS support #2206

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

*: add UDS support #2206

wants to merge 9 commits into from

Conversation

BusyJay
Copy link

@BusyJay BusyJay commented Jun 16, 2024

A new module named net is added to unify TCP socket and UDS. By default, sccache server is still listen on local TCP port, user can choose to listen on UDS by setting environment variable SCCACHE_SERVER_UDS.

Generic is used in server implementation for best performance, trait object is used in client implementation for simplicity and better readability.

Close #933.

@sylvestre
Copy link
Collaborator

I guess you saw that a bunch of jobs are failing

@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2024

Codecov Report

Attention: Patch coverage is 38.77551% with 150 lines in your changes missing coverage. Please review.

Project coverage is 54.41%. Comparing base (0cc0c62) to head (6039160).
Report is 74 commits behind head on main.

Files with missing lines Patch % Lines
src/server.rs 20.33% 32 Missing and 15 partials ⚠️
src/util.rs 38.02% 14 Missing and 30 partials ⚠️
src/net.rs 39.68% 38 Missing ⚠️
src/commands.rs 26.08% 5 Missing and 12 partials ⚠️
src/client.rs 75.00% 1 Missing and 2 partials ⚠️
src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2206       +/-   ##
===========================================
+ Coverage   30.91%   54.41%   +23.49%     
===========================================
  Files          53       55        +2     
  Lines       20112    20865      +753     
  Branches     9755     9866      +111     
===========================================
+ Hits         6217    11353     +5136     
- Misses       7922     8068      +146     
+ Partials     5973     1444     -4529     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/net.rs Show resolved Hide resolved
@sylvestre
Copy link
Collaborator

Generic is used in server implementation for best performance

Did you do any benchmark to confirm this ? thanks

@BusyJay
Copy link
Author

BusyJay commented Jun 16, 2024

Did you do any benchmark to confirm this ? thanks

No, just theory analysis. By using generic, the generated machine code is almost the same as before.

@BusyJay BusyJay force-pushed the support-uds branch 2 times, most recently from 78b5737 to 3d02761 Compare June 16, 2024 17:01
@sylvestre
Copy link
Collaborator

I don't think the gcc issue is your fault
we have intermittent issues when hitting the rate limit

Copy link
Collaborator

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

env::var("SCCACHE_SERVER_PORT")
fn get_addr() -> crate::net::SocketAddr {
#[cfg(unix)]
if let Ok(addr) = env::var("SCCACHE_SERVER_UDS") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rather than add another configuration know, SCCACHE_SERVER_PORT should be parsed as an int, and if that doesn't work, try as a UDS, and if that doesn't work, use the default TCP port.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, actually, if parsing doesn't work, it should be an error, rather than fallback. Only fallback when nothing is explicitly given.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying not to break compatibility here. And it seems confusing to me to parse something named "port" as a path. If we want to use one single environment variable, we should choose some name like "SCCACHE_SERVER_ADDR" instead.

src/commands.rs Outdated
.unwrap_or(DEFAULT_PORT)
.unwrap_or(DEFAULT_PORT);
crate::net::SocketAddr::Net(std::net::SocketAddr::new(
"127.0.0.1".parse().unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the 127.0.0.1 address here & inside src/server.rs:567? Is it OK to duplicate the default address in a few places?

Maybe we should add a const &str for this or just use the result of get_addr() inside the src/server.rs, isn't it?

src/commands.rs Outdated
"sccache: Listening on port {} instead of {}",
actualport,
port
"sccache: Listening on port {actual_addr} instead of {addr}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"sccache: Listening on port {actual_addr} instead of {addr}"
"sccache: Listening on address {actual_addr} instead of {addr}"

@AJIOB
Copy link
Contributor

AJIOB commented Jul 4, 2024

Hi @Xuanwo

Looks like this PR is ready.

Should we merge it?

A new module named `net` is added to unify TCP socket and UDS.
By default, sccache server is still listen on local TCP port,
user can choose to listen on UDS by setting environment variable
`SCCACHE_SERVER_UDS`.

Generic is used in server implementation for best performance,
trait object is used in client implementation for simplicity and
better readability.

Close mozilla#933.

Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Signed-off-by: Jay Lee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: support for listening on a unix socket.
6 participants