Comments (10)
Currently the thinking is:
- Make a new base collection module that powers collections and subcollections called indexed-list
- Break subcollections out into two modules
ampersand-paged-collection
andampersand-filtered-collection
(subcollection can combine these and maintain its current api)
indexed-list will need to maintain both its current named indexing of models (to deal with add/update duplication checks etc) as well as a new offset index (to make indexOf a quick lookup). We need a fast indexOf for most of the things subcollection does (for instance determining if an event needs to bubble up i.e. is this model now a part of the new subcollection). It would still maintain an array of models so that the current exposed array methods would still all work, and also so that subcollections could easily paginate.
There is a branch in subcollection called performance
that contains the current wips of getting some of the optimizations ironed out. This branch will likely never be merged in, it's a sandbox for sharing code between those who are working on this problem.
paged-collection would take limit/offset and then slice its parent
filtered-collection would apply a filter to its parent, maintaining parent order unless overridden by its own comparator.
from ampersand-collection.
indexed-list add
would need to use a binary-search + comparator to find the intended index of the new model. Current javascript sorting functions do not allow us to know where our items ended up without a second complete iteration through the list.
This will make all adds with a comparator O(log n) speed (adds without a comparator are simpler of course).
from ampersand-collection.
If we have ampersand-paged-collection
, we really don't need that to emit anything other than reset
events. Something changed? Throw out everything, reslice and emit 'reset'. Any collection view will have the existing item views cached. If it is still slow then, there's really not much we can do. Caveat emptor.
We already made the filtered collection fast in the peformance branch: it was trying to maintain indexes after slicing for paging that was the still-be-solved problem.
from ampersand-collection.
So performance branch can become ampersand-filtered-collection and then subcollection can intelligently tie them together.
from ampersand-collection.
Here is paged collection https://github.com/wraithgar/paged-collection
Discussion is now open and welcome for that repo, we can move it to this org as ampersand-paged-collection if we like it.
from ampersand-collection.
Here is filtered collection https://github.com/wraithgar/filtered-collection
Discussion is now open and welcome for that repo, we can move it to this org as ampersand-filtered-collection if we like it.
from ampersand-collection.
These two PRs are required for this project AmpersandJS/amp#76 AmpersandJS/amp#74
from ampersand-collection.
Here are the performance metrics http://artifice.danger.computer/perusinuve.txt
from ampersand-collection.
@wraithgar any updates on this? I've been quite curious about perf & tracking perf over time for ampersand-collection
for quite a bit. Has there been any discussion about switching the under-the-hood manipulation to use crossfilter, pourover, ndarray or the like?
from ampersand-collection.
@imlucas a great deal of effort was put into refactoring subcollection which resulted in https://github.com/AmpersandJS/ampersand-filtered-subcollection and https://github.com/AmpersandJS/ampersand-paginated-subcollection. Currently ampersand-collection doesn't have any plans for more optimization. I'll be closing this as it was primarily about the subcollection performance issues (which were huge). If there is a specific performance problem w/ collection please open a new issue to discuss it since this one's run its course.
from ampersand-collection.
Related Issues (20)
- deIndex is being called wrong HOT 8
- -nothing-to-see-here- HOT 1
- Tracking collection state. HOT 13
- .get(id) can't find object with id 0 HOT 2
- .find(query, [indexName]) to retrieve multiple models HOT 4
- using ES5 `bind` for double argument comparator causes Phantom.js to fail HOT 2
- adding element with id:0 results in duplicates
- Upgrade from 1.4.2 to 1.4.3 causes jasmine tests to fail HOT 3
- Consistent sorting functions HOT 4
- Collection of Collections HOT 3
- index issue during collection.set
- Iterable via for...of HOT 1
- Document `parse` method HOT 1
- Collection does not sort itself when elements change HOT 4
- No good hook for when models are inserted
- No "update" event like in Backbone
- lodash helper do not support second parameter binding HOT 1
- Feature Proposal: "cancel" callback in fetch options? HOT 1
- When null is passed as value, it instantiates an empty model in the collection 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 ampersand-collection.