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

perf: dynamic dispatch overhead #1922

Closed
PSeitz opened this issue Mar 2, 2023 · 3 comments
Closed

perf: dynamic dispatch overhead #1922

PSeitz opened this issue Mar 2, 2023 · 3 comments

Comments

@PSeitz
Copy link
Contributor

PSeitz commented Mar 2, 2023

This flamegraph is an term query aggregation on 10mio documents selected via a "*" query.
Only around 60% is spent in the aggregation, a large chunk seems to be calling overhead, e.g the dynamic dispatch on the callback in for_each_docset.

pub(crate) fn for_each_docset<T: DocSet + ?Sized>(docset: &mut T, callback: &mut dyn FnMut(DocId)) {
    let mut doc = docset.doc();
    while doc != TERMINATED {
        callback(doc);
        doc = docset.advance();
    }
}

flamegraph

@fulmicoton
Copy link
Collaborator

considering you do buffering in the aggregation layer, should we add some buffering solution in at the DocSet level maybe? can you experiment?

@PSeitz
Copy link
Contributor Author

PSeitz commented Mar 2, 2023

Yes, I think we have two options

  • Buffering like in aggregations. It probably needs to be on the Collector, but could be combined with DocSet
  • Remove the callback dynamic dispatch (maybe not feasible)

Buffering may have some free positive side effects on the generated code, but the (sometimes unused) score may complicate things a bit

@PSeitz
Copy link
Contributor Author

PSeitz commented Mar 20, 2023

#1937

@PSeitz PSeitz closed this as completed Mar 21, 2023
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

No branches or pull requests

2 participants