Comments (6)
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.
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.
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.
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.
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.
I'd recommend the one with less code, if it works, that is snippet #984.
from django-activity-stream.
Related Issues (20)
- Verb examples do not match spec
- django 4.0 support HOT 5
- django-activity-stream and django-comments-xtd HOT 2
- Activity Stream 2 JSON Feeds HOT 2
- AS2 paging
- DRF support HOT 3
- Use pluggy for customization report
- Installation breaks with pip -r HOT 2
- Django -activity stream HOT 1
- Missing migration when moving from Django 2.2 to 3.2 HOT 1
- Not working with Django 4.1 HOT 9
- Release new version HOT 1
- Filter user feed with distinct('action_object') HOT 1
- [Feature proposal] Delete Follow objects when the followed object is deleted? HOT 1
- Remove usage of `datetime_safe` HOT 4
- Field 'actor' does not generate an automatic reverse relation and therefore cannot be used for reverse querying. If it is a GenericForeignKey, consider adding a GenericRelation. HOT 4
- [Feature request ] Soft delete for action
- Registering models from third-party apps HOT 1
- Make a 2.0 release and publish to PyPI HOT 4
- Add multidatabase support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-activity-stream.