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

Codegen: convert Arc<Box<T>> to Arc<T> #235

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Conversation

Xynnn007
Copy link
Contributor

This commit changes the generated ttrpc server from Arc<Box> to Arc. This helps the type conversion and also avoids extra runtime cost caused by double pointer.

Fixes #234

@Xynnn007 Xynnn007 force-pushed the arcer branch 2 times, most recently from ec8a6f6 to d88f833 Compare August 19, 2024 09:13
@Xynnn007 Xynnn007 marked this pull request as draft August 19, 2024 09:17
@Xynnn007 Xynnn007 marked this pull request as ready for review August 19, 2024 09:32
@Xynnn007
Copy link
Contributor Author

@wllenyj sry please wait a moment. Let me test locally if sync version works fine with this.

@Xynnn007
Copy link
Contributor Author

@wllenyj Add the line of sync version create_xxx_server

@Xynnn007
Copy link
Contributor Author

Hi @wllenyj @Tim-Zhang What should I do else to move this forward?

This commit changes the generated ttrpc server from Arc<Box<T>>
to Arc<T>. This helps the type conversion and also avoids extra runtime
cost caused by double pointer.

Fixes containerd#234

Signed-off-by: Xynnn007 <[email protected]>
Copy link
Member

@Tim-Zhang Tim-Zhang left a comment

Choose a reason for hiding this comment

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

It will simplify the code:
before:

    let h = Box::new(HealthService {}) as Box<dyn health_ttrpc::Health + Send + Sync>;
    let h = Arc::new(h);
    let hservice = health_ttrpc::create_health(h);

after:

    let hservice = health_ttrpc::create_health(Arc::new(HealthService {}));

it also will cut down heap allocations, thanks @Xynnn007

example/Cargo.toml Outdated Show resolved Hide resolved
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 24.74%. Comparing base (a9198f2) to head (444a490).
Report is 17 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #235      +/-   ##
==========================================
- Coverage   24.97%   24.74%   -0.23%     
==========================================
  Files          16       16              
  Lines        2651     2675      +24     
==========================================
  Hits          662      662              
- Misses       1989     2013      +24     

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

update for commit 1f2a26

Signed-off-by: Tim Zhang <[email protected]>
@Tim-Zhang Tim-Zhang merged commit 663d4d7 into containerd:master Sep 25, 2024
12 of 13 checks passed
@Xynnn007 Xynnn007 deleted the arcer branch September 25, 2024 09:09
Tim-Zhang added a commit to Tim-Zhang/ttrpc-rust that referenced this pull request Sep 26, 2024
Cut the release for containerd#235.

Signed-off-by: Tim Zhang <[email protected]>
jokemanfire pushed a commit to jokemanfire/ttrpc-rust that referenced this pull request Sep 27, 2024
Cut the release for containerd#235.

Signed-off-by: Tim Zhang <[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.

Codegen with Arc<dyn ..> instead of Arc<Box<..>>
3 participants