Git Product home page Git Product logo

Comments (3)

eqinox76 avatar eqinox76 commented on May 18, 2024

v0.34.0 shows the same behavior.

from go-cloud.

vangent avatar vangent commented on May 18, 2024

I'd try adding some logging near here: https://github.com/google/go-cloud/blob/master/docstore/mongodocstore/query.go#L124 to see if you can determine where the pauses are coming from. I am also not familiar with the docstore/mongodocstore code, but it looks like we're just iterating calling cursor.Next and then decoding it.

from go-cloud.

eqinox76 avatar eqinox76 commented on May 18, 2024

Thank you for the pointer. After some more debugging and some dead ends i think i understand whats happening. Especially the golang trace is helpful:
image
The green-pink-brown stacks are io operations (syscall.read from within go.mongodb.org/mongo-driver/mongo.(*Cursor).Next:133).
The light blue stacks are decode operations (gocloud.dev/docstore/mongodocstore.decodeDoc:125).

I would have expected the documents to be decoded from the moment the first element of a batch arrives. But it seems the mongo driver waits for the complete batch to arrive. Thereafter the gocloud decode operation is applied to all elements and only then the next batch is requested. That explains the above pattern in the io graph.

Not much that can be done about it. Using func (c *Cursor) TryNext(ctx context.Context) bool as a noneblocking alternative could be feasible. This would allow decoding to continue while the next batch is already in flight. But that would require at least parallelized code.

Thanks for having a look and helping me understand the issue.

from go-cloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.