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

refactor: http #2386

Closed
wants to merge 11 commits into from
Closed

refactor: http #2386

wants to merge 11 commits into from

Conversation

Shylock-Hg
Copy link
Contributor

@Shylock-Hg Shylock-Hg commented Jul 9, 2024

Summary:
Create http for each thread

Issue Reference(s):
Close #2370
/claim #2370

Build & Testing:

  • I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • I have performed a self-review of my code.
  • PR follows the naming convention of <type>(<optional scope>): <title>

@github-actions github-actions bot added the ci: benchmark Runs benchmarks label Jul 9, 2024
@Shylock-Hg Shylock-Hg changed the title Refact/http refact: http Jul 9, 2024
@@ -182,8 +183,41 @@ impl HttpIO for NativeHttp {
)
.await?)
}

fn cl(&self) -> Box<dyn HttpIO> {
Box::new(self.clone())
Copy link
Contributor

Choose a reason for hiding this comment

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

Cloning isn't going to help, ideally we want to create separate connection pools and caches for each http-client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a question about this. According to https://docs.rs/reqwest/0.12.5/reqwest/struct.Client.html, reqwest::Client has a connection pool in it already. Do we need more work?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing special needs to be done for pooling.

@Shylock-Hg Shylock-Hg changed the title refact: http refactor: http Jul 9, 2024
if let Some(http) = self.map.get(&thread_id) {
http.value().execute(request).await
} else {
let new_http = self.http.cl();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should call init_http instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok


pub struct ConcurrentHttp {
http: Box<dyn HttpIO>,
map: DashMap<std::thread::ThreadId, Box<dyn HttpIO>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of map we can use a thread local.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

Copy link

github-actions bot commented Jul 9, 2024

🐰Bencher

ReportThu, July 11, 2024 at 03:17:03 UTC
Projecttailcall
Branch2386/merge
Testbedbenchmarking-runner
Click to view all benchmark results
BenchmarkLatencyLatency Results
nanoseconds (ns) | (Δ%)
Latency Upper Boundary
nanoseconds (ns) | (%)
from_json_bench✅ (view plot)6,125,900.00 (-10.75%)7,787,675.01 (78.66%)
group_by✅ (view plot)486.00 (-11.59%)624.18 (77.86%)
input/args.missing✅ (view plot)25.55 (+5.61%)27.75 (92.07%)
input/args.nested.existing✅ (view plot)52.24 (+10.07%)61.13 (85.45%)
input/args.nested.missing✅ (view plot)37.47 (-1.50%)40.83 (91.76%)
input/args.root✅ (view plot)50.42 (+15.10%)58.09 (86.81%)
input/headers.existing✅ (view plot)30.39 (-3.97%)34.04 (89.26%)
input/headers.missing✅ (view plot)29.28 (-4.80%)33.91 (86.37%)
input/value.missing✅ (view plot)23.43 (+0.09%)24.96 (93.87%)
input/value.nested.existing✅ (view plot)42.04 (+0.85%)45.17 (93.06%)
input/value.nested.missing✅ (view plot)36.85 (-0.29%)39.60 (93.08%)
input/value.root✅ (view plot)38.02 (+0.44%)41.39 (91.86%)
input/vars.existing✅ (view plot)7.75 (+0.75%)9.07 (85.40%)
input/vars.missing✅ (view plot)7.78 (-22.35%)13.44 (57.86%)
synth_nested✅ (view plot)154,830.00 (+121.74%)209,402.78 (73.94%)
test_batched_body✅ (view plot)1,982.10 (-87.92%)337,319.79 (0.59%)
test_batched_body #2✅ (view plot)1,633,700.00 (-3.55%)1,817,439.01 (89.89%)
test_data_loader✅ (view plot)387,390.00 (-14.93%)525,843.52 (73.67%)
test_handle_request✅ (view plot)144,150.00 (-6.50%)172,369.45 (83.63%)
test_handle_request_jit✅ (view plot)91,685.00 (-0.11%)94,720.38 (96.80%)
test_http_execute_method✅ (view plot)14,023.00 (-19.52%)20,740.88 (67.61%)
with_mustache_expressions✅ (view plot)1,139.10 (-1.76%)1,236.53 (92.12%)
with_mustache_literal✅ (view plot)769.23 (+6.37%)781.41 (98.44%)

Bencher - Continuous Benchmarking
View Public Perf Page
Docs | Repo | Chat | Help

Copy link

codecov bot commented Jul 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.27%. Comparing base (c89690f) to head (3460edd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2386   +/-   ##
=======================================
  Coverage   87.26%   87.27%           
=======================================
  Files         243      243           
  Lines       22524    22531    +7     
=======================================
+ Hits        19656    19663    +7     
  Misses       2868     2868           

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

@github-actions github-actions bot added the type: chore Routine tasks like conversions, reorganization, and maintenance work. label Jul 10, 2024
@tusharmath tusharmath marked this pull request as draft July 10, 2024 13:55
@tusharmath
Copy link
Contributor

Moving to draft to reduce noise and improve CI efficiency. Once you are ready just mark it as "ready to review". Feel free to give a shoutout on the #contributors channel on Discord if you want immediate attention.

Let me know once the comments are fixed. Thanks!

@Shylock-Hg Shylock-Hg marked this pull request as ready for review July 11, 2024 03:50
@Shylock-Hg
Copy link
Contributor Author

@tusharmath I think it's ok now. But the CI of benchmark went wrong.

@tusharmath
Copy link
Contributor

@Shylock-Hg The PR isn't doing whats expected:

  1. Benchmarks are failing, meaning the server doesn't work correctly.
  2. There is use of unsafe code such as panic.
  3. You are still creating a single client and then cloning it in an arch which is exactly what we don't want.

For these reasons, I am closing this PR for now. Feel free to create a new PR and ask questions on discord if the requirement isn't clear, always happy to help!

@tusharmath tusharmath closed this Jul 11, 2024
@Shylock-Hg
Copy link
Contributor Author

@Shylock-Hg The PR isn't doing whats expected:

  1. Benchmarks are failing, meaning the server doesn't work correctly.
  2. There is use of unsafe code such as panic.
  3. You are still creating a single client and then cloning it in an arch which is exactly what we don't want.

For these reasons, I am closing this PR for now. Feel free to create a new PR and ask questions on discord if the requirement isn't clear, always happy to help!

Ok, I misunderstand it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 Bounty claim ci: benchmark Runs benchmarks type: chore Routine tasks like conversions, reorganization, and maintenance work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create a HTTP client per thread
2 participants