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

Why is header propagation in Rhai faster than via the config? #3068

Closed
lleadbet opened this issue May 9, 2023 · 1 comment · Fixed by #3721
Closed

Why is header propagation in Rhai faster than via the config? #3068

lleadbet opened this issue May 9, 2023 · 1 comment · Fixed by #3721
Assignees
Labels
component/rhai performance Performance or scalability issues

Comments

@lleadbet
Copy link
Contributor

lleadbet commented May 9, 2023

Describe the solution you'd like

I'm working on load testing the various extensibility options available, and noticing an odd discrepancy when comparing a relatively simple config vs. Rhai: Rhai is actually better performance-wise when setting a static header to subgraphs.

Config for reference:

supergraph:
  listen: 0.0.0.0:4040
  path: /
  introspection: true
headers:
  all:
    request:
      - insert:
          name: "source"
          value: "config"

And the Rhai script:

fn subgraph_service(service,subgraph){
    service.map_request(|request|{
        request.subgraph.headers["source"] = "rhai";
    });
}

Data using 1 min load test with 150 rps; order is [min, mean, 50, 90, 95, 99, max]

No customizations (e.g. a baseline):
1.187ms, 4.296ms, 3.615ms, 6.616ms, 7.924ms, 14.763ms, 124.662ms

Config:
1.291ms, 6.471ms, 4.036ms, 10.814ms, 12.345ms, 26.019ms, 513.332ms

Rhai:
1.191ms, 5.026ms, 3.805ms, 8.685ms, 10.404ms, 16.506ms, 223.113ms

As you can see - Rhai is about 2ms faster for p95s than the config.

Describe alternatives you've considered

Config is preferably more performant than Rhai, or at least understood why this is the case.

Additional context

Working to get profiler in place for this, however wanted to file this ticket for tracking purposes.

@garypen garypen added component/rhai performance Performance or scalability issues labels May 19, 2023
@Geal
Copy link
Contributor

Geal commented Sep 1, 2023

I can confirm, rhai is faster than the headers plugin. I don't know why yet though

@Geal Geal self-assigned this Sep 1, 2023
@Geal Geal closed this as completed in #3721 Sep 4, 2023
Geal added a commit that referenced this issue Sep 4, 2023
Fix #3068 

the operations were cloned for every subgraph query, this is a bit
wasteful so we create them only once, and store them under an Arc
garypen pushed a commit that referenced this issue Sep 12, 2023
Fix #3068 

the operations were cloned for every subgraph query, this is a bit
wasteful so we create them only once, and store them under an Arc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/rhai performance Performance or scalability issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants