plebbit / plebbit-js

A Javascript API to build applications using plebbit
GNU General Public License v2.0
41 stars 7 forks source link

If a new comment/vote is received, and no updates have published in 2 minutes, publish an update right away #16

Closed estebanabaroa closed 10 months ago

estebanabaroa commented 1 year ago

One complaint we get from people running a sub for the first time, is that their posts dont show up in the feed quickly.

We cannot update the feed every 10 seconds, that would use too much resources, but what we can do on slow subs, is that if there has been no updates in X minutes (maybe 2-5 minutes), and a new comment/vote is received, publish the update right away, so that the user can see it in less than 1 minute in his feed.

This is low priority but something to think about.

Rinse12 commented 11 months ago

As of now, the goal of plebbit.publishInterval = x is to start a publish loop of subplebbit after x timeout of the last publish loop. The publish loop at its beginning checks if there is a need to continue with the publish loop. The criteria is something like this

If the answer is yes to any of these questions, the subplebbit will begin updating all of its props and publish a new record.

The default value for it as of now is 100000ms, which 1.67 minutes. That means practically no new record will be published until 1.67 minutes has passed from the last record.

Personally I think we should just lower the default plebbit.publishInterval to something like 20s. See how much that affects the performance. It probably won't affect that much, and it would achieve the purpose of this issue

estebanabaroa commented 11 months ago

Personally I think we should just lower the default plebbit.publishInterval to something like 20s

what if it took 100 seconds to calculate the new subplebbit update (ie there's a lot of posts)? would it mean the interval would be 100s + 20s? or would it bug out because it tries to start an interval before the other interval finished?

I think that since we're using IPNS over pubsub we could probably publish updates every 1 second, the problem is how fast can the update be calculated, especially after we switch to the new comment update design, which puts every comment update in an IPFS folder that is linked from the subplebbit update

Rinse12 commented 11 months ago

what if it took 100 seconds to calculate the new subplebbit update (ie there's a lot of posts)? would it mean the interval would be 100s + 20s? or would it bug out because it tries to start an interval before the other interval finished?

Each interval is started after the last one ends, so 100s + 20s

I think that since we're using IPNS over pubsub we could probably publish updates every 1 second, the problem is how fast can the update be calculated, especially after we switch to the new comment update design, which puts every comment update in an IPFS folder that is linked from the subplebbit update

Yes the publish loop should be optimized as much as possible. I think we can drop down to 20s with no problem once rpc is integrated

estebanabaroa commented 11 months ago

Each interval is started after the last one ends, so 100s + 20s

in this case I guess I dont see any problem with dropping it to 20s

Rinse12 commented 11 months ago

I guess we should rename plebbit.publishInterval to minimumPublishInterval or something more descriptive than its current name. Right now it gives the developer the idea that it publishes every publishInterval exactly

estebanabaroa commented 11 months ago

I dont think minimumPublishInterval would be accurate, rather it would be publishDelay or something, but I dont like it, I think we should keep publishInterval as the public API, and we can document that it can be longer than the amount specified if the update calculation takes longer. I don't think it's something people should mess with anyway, it's a value only for testing and it's internal behavior will change over time.

if we learn more later we could change it but I dont think it should be changed right now