Git Product home page Git Product logo

Comments (6)

justquick avatar justquick commented on June 1, 2024

it seems like a good patch. are you measuring or benchmarking the number of queries generated? some benchmarks would be good. it sounds like this would be beneficial for any django model with generic foreign key relationships which kind of puts it outside the scope of this project. im not against including it, but maybe it would be worth it to put together a proper patch for django itself to implement this?

from django-activity-stream.

jpic avatar jpic commented on June 1, 2024

I totally agree that it's not the role of actstream to "host" such code because in the end it got generic. I'm leaving for long hollidays (again - sorry for the late reply heh) tomorrow so there's no chance i can get it into Django anytime soon. But it would benefit actstream users and that's the only reason why i posted it here. At least a users

About the benchmark: activities are displayed through endless pagination, by groups of 7. Results come from django-debug-toolbar.

With prefetch relations:

  • CPU time: 1599.90ms (1680.29ms)
  • queries: 49 (86.59ms)

Without prefetch relations:

  • CPU time: 2076.53ms (2180.02ms)
  • queries: 71 in 109.80ms

That's a 23% improvement of actual page generation time.

from django-activity-stream.

justquick avatar justquick commented on June 1, 2024

looks like smart code but i have some more notes.

first and foremost for this project, i need to see a patch against this codebase maybe adding the snippet and then using it where the streams are generated (where most of the relational lookups happen). id also like to see an example benchmark with test code and data. eventually having more unittests from that would be great.

lastly, i think the snippet needs a little work. the code complexity in the part at the end is geometric :( there's no reason why this cant' be light on both the database and application load.

from django-activity-stream.

jpic avatar jpic commented on June 1, 2024

I understand that you'd like to see it clean and finished - i would too. That said, I don't think there is a realist future for this 35 SLOC quick hack/POC. But if someone searches "performance" in actstream's github, he can find this match which may help him. So i think we can close it.

Maybe much later, i re-do it in the context of our public repo (that will be with the identity map), but that's not happenning anytime soon (and I'm not convinced that unit tests would help keep 35 lines of code under control ...).

Thanks a lot for your feedback. I hope Django will provide such optimisation features one day !

from django-activity-stream.

justquick avatar justquick commented on June 1, 2024

it seems there are many incarnations of this solution

http://djangosnippets.org/snippets/984/
http://djangosnippets.org/snippets/1079/

one fork actually implements some of it in the stream logic

https://github.com/bolster/django-activity-stream/blob/master/actstream/genericforeignkey.py

now to weigh the options...

from django-activity-stream.

jpic avatar jpic commented on June 1, 2024

I'd recommend the one with less code, if it works, that is snippet #984.

from django-activity-stream.

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.