View Issue Details

IDProjectCategoryView StatusLast Update
4876Composrcore_cnspublic2022-09-07 23:18
ReporterPDStig Assigned ToPDStig  
PrioritynormalSeverityminor 
Status resolvedResolutionfixed 
Summary4876: Make point weighting calculations more efficient
DescriptionThe current method of calculating point weights in 4775 is very inefficient. It is possible on large sites for polls to have up to a million votes. It is not reasonable to tally all 1,000,000 vote records in the database to process voting power / weighted results.

A possible suggestion is to utilize the same method used to cache the number of votes for each answer (and the poll itself) via cns_topics_recache by cacheing total voting power and updating it accordingly when necessary (simple addition or subtraction on new votes or revoked votes, etc).
TagsAutonomousOrganisation, Pseudo-addon: Forum topic polls, Roadmap: v11
Attach Tags
Time estimation (hours)3
Sponsorship open

Sponsor

Date Added Member Amount Sponsored

Relationships

related to 4775 ResolvedPDStig Point-normalised poll results 

Activities

PDStig

2022-08-07 00:52

administrator   ~7409

Actually, cacheing voting power is a bad idea because the formula can be changed. Perhaps cache total points of voters who voted for each answer + the poll itself instead.

Chris Graham

2022-08-08 23:45

administrator   ~7410

Last edited: 2022-08-08 23:49

Discussed this with Patrick.

Regarding Patrick's reply:
Caching points for each answer doesn't work as there is no linear relationship to calculate voting power from the combined points of each member.

The real solution would be:
1) Add a nullable field cache_voting_power on each answer row.
2) Add a nullable field cache_voting_power on each vote row.
3) If the cache_voting_power value is set when loading polls in topicview, use it, don't do a full calculation
4) If the cache_voting_power value is null on an answer row when loading polls the topicview, do the full calculation as we do now, updating cache_voting_power on the voter rows at the same time
5) If the cache_voting_power value is set when showing voters, use it, don't do a full calculation
6) If the cache_voting_power value is null on an answer row when showing voters, do the full calculation as we do now
7) When a vote is cast, the cache_voting_power on the answer row should be set and the cache_voting_power value on the answer row should be raised as appropriate
8) When a vote is revoked, the cache_voting_power value should be lowered based on the value of the vote row being revoked.
9) If the configuration changes on any of the relevant config options, flush out these field values from the database (nullify them). This should be done via a hook that listens to particular config options changing. If we don't yet have such a hook type, we should add it.

Additionally:
1) Viewing voters does not need to do an in-memory sort if ordering by voting power. Voting power is strictly proportional to number of points, so it can just do an in-DB sort on the points column.

Update docs to reflect the efficiency no longer exists.

Issue History

Date Modified Username Field Change
2022-08-07 00:50 PDStig New Issue
2022-08-07 00:50 PDStig Tag Attached: AutonomousOrganisation
2022-08-07 00:50 PDStig Tag Attached: Pseudo-addon: Forum topic polls
2022-08-07 00:50 PDStig Tag Attached: Roadmap: v12
2022-08-07 00:50 PDStig Relationship added related to 4775
2022-08-07 00:52 PDStig Note Added: 0007409
2022-08-08 23:35 Chris Graham Assigned To => user4172
2022-08-08 23:35 Chris Graham Status Not Assigned => Assigned
2022-08-08 23:45 Chris Graham Note Added: 0007410
2022-08-08 23:47 Chris Graham Time estimation (hours) 1 => 3
2022-08-08 23:49 Chris Graham Note Edited: 0007410
2022-08-15 15:49 Chris Graham Tag Attached: Roadmap: v11
2022-08-15 15:49 Chris Graham Tag Detached: Roadmap: v12
2022-09-07 22:17 PDStig Status Assigned => Resolved
2022-09-07 22:17 PDStig Resolution open => fixed