ActivityPub-federated video streaming platform using P2P directly in your web browser
Forward views in parallel
Chocobozzz8be308ae0b7d
diff --git a/server/core/lib/activitypub/process/process-announce.ts b/server/core/lib/activitypub/process/process-announce.tsindex c842d99050..5b48919049 100644--- a/server/core/lib/activitypub/process/process-announce.ts+++ b/server/core/lib/activitypub/process/process-announce.ts@@ -55,7 +55,7 @@ async function processVideoShare (actorAnnouncer: MActorSignature, activity: Act// Don't resend the activity to the senderconst exceptions = [ actorAnnouncer ]- await forwardVideoRelatedActivity({ activity, transaction: t, followersException: exceptions, video })+ await forwardVideoRelatedActivity({ activity, transaction: t, followersException: exceptions, video, parallelizable: false })}return undefineddiff --git a/server/core/lib/activitypub/process/process-create.ts b/server/core/lib/activitypub/process/process-create.tsindex 3f6e6b053f..f5664bf167 100644--- a/server/core/lib/activitypub/process/process-create.ts+++ b/server/core/lib/activitypub/process/process-create.ts@@ -103,7 +103,7 @@ async function processCreateCacheFile (if (video.isLocal()) {// Don't resend the activity to the senderconst exceptions = [ byActor ]- await forwardVideoRelatedActivity({ activity, transaction: undefined, followersException: exceptions, video })+ await forwardVideoRelatedActivity({ activity, transaction: undefined, followersException: exceptions, video, parallelizable: false })}}@@ -174,7 +174,7 @@ async function processCreateVideoComment (// Don't resend the activity to the senderconst exceptions = [ byActor ]- await forwardVideoRelatedActivity({ activity, transaction: undefined, followersException: exceptions, video })+ await forwardVideoRelatedActivity({ activity, transaction: undefined, followersException: exceptions, video, parallelizable: false })}}diff --git a/server/core/lib/activitypub/process/process-delete.ts b/server/core/lib/activitypub/process/process-delete.tsindex 918baf1eed..2663435507 100644--- a/server/core/lib/activitypub/process/process-delete.ts+++ b/server/core/lib/activitypub/process/process-delete.ts@@ -147,7 +147,13 @@ function processDeleteVideoComment (byActor: MActorSignature, videoComment: MComif (videoComment.Video.isLocal()) {// Don't resend the activity to the senderconst exceptions = [ byActor ]- await forwardVideoRelatedActivity({ activity, transaction: t, followersException: exceptions, video: videoComment.Video })+ await forwardVideoRelatedActivity({+ activity,+ transaction: t,+ followersException: exceptions,+ video: videoComment.Video,+ parallelizable: false+ })}logger.info('Remote video comment %s removed.', videoComment.url)diff --git a/server/core/lib/activitypub/process/process-undo.ts b/server/core/lib/activitypub/process/process-undo.tsindex b5de680947..3312ca69fc 100644--- a/server/core/lib/activitypub/process/process-undo.ts+++ b/server/core/lib/activitypub/process/process-undo.ts@@ -136,7 +136,7 @@ async function processUndoCacheFile (// Don't resend the activity to the senderconst exceptions = [ byActor ]- await forwardVideoRelatedActivity({ activity, transaction: t, followersException: exceptions, video })+ await forwardVideoRelatedActivity({ activity, transaction: t, followersException: exceptions, video, parallelizable: false })}})}@@ -157,7 +157,13 @@ function processUndoAnnounce (byActor: MActorSignature, announceActivity: Activi// Don't resend the activity to the senderconst exceptions = [ byActor ]- await forwardVideoRelatedActivity({ activity: announceActivity, transaction: t, followersException: exceptions, video: share.Video })+ await forwardVideoRelatedActivity({+ activity: announceActivity,+ transaction: t,+ followersException: exceptions,+ video: share.Video,+ parallelizable: false+ })}})}diff --git a/server/core/lib/activitypub/process/process-update.ts b/server/core/lib/activitypub/process/process-update.tsindex 9fef91e5bc..71910a6f12 100644--- a/server/core/lib/activitypub/process/process-update.ts+++ b/server/core/lib/activitypub/process/process-update.ts@@ -116,7 +116,7 @@ async function processUpdateCacheFile (// Don't resend the activity to the senderconst exceptions = [ byActor ]- await forwardVideoRelatedActivity({ activity, transaction: undefined, followersException: exceptions, video })+ await forwardVideoRelatedActivity({ activity, transaction: undefined, followersException: exceptions, video, parallelizable: false })}}diff --git a/server/core/lib/activitypub/process/process-view.ts b/server/core/lib/activitypub/process/process-view.tsindex 338114ecc3..faf76a19d1 100644--- a/server/core/lib/activitypub/process/process-view.ts+++ b/server/core/lib/activitypub/process/process-view.ts@@ -41,7 +41,7 @@ async function processCreateView (activity: ActivityView, byActor: MActorSignatuif (video.isLocal()) {// Forward the view but don't resend the activity to the senderconst exceptions = [ byActor ]- await forwardVideoRelatedActivity({ activity, transaction: undefined, followersException: exceptions, video })+ await forwardVideoRelatedActivity({ activity, transaction: undefined, followersException: exceptions, video, parallelizable: true })}}diff --git a/server/core/lib/activitypub/send/shared/send-utils.ts b/server/core/lib/activitypub/send/shared/send-utils.tsindex 6cd6d4ca0a..fb4f8532a7 100644--- a/server/core/lib/activitypub/send/shared/send-utils.ts+++ b/server/core/lib/activitypub/send/shared/send-utils.ts@@ -94,8 +94,9 @@ async function forwardVideoRelatedActivity (options: {transaction: TransactionfollowersException: MActorWithInboxes[]video: MVideoId+ parallelizable?: boolean}) {- const { activity, transaction, followersException, video } = options+ const { activity, transaction, followersException, parallelizable, video } = options// Mastodon does not add our announces in audience, so we forward to them manuallyconst additionalActors = await getActorsInvolvedInVideo(video, transaction)@@ -121,7 +122,14 @@ async function forwardVideoRelatedActivity (options: {contextType: null}- return afterCommitIfTransaction(transaction, () => JobQueue.Instance.createJobAsync({ type: 'activitypub-http-broadcast', payload }))+ return afterCommitIfTransaction(transaction, () => {+ JobQueue.Instance.createJobAsync({+ type: parallelizable+ ? 'activitypub-http-broadcast-parallel'+ : 'activitypub-http-broadcast',+ payload+ })+ })}// ---------------------------------------------------------------------------diff --git a/server/core/lib/worker/parent-process.ts b/server/core/lib/worker/parent-process.tsindex 24e605ec86..cdbf28089d 100644--- a/server/core/lib/worker/parent-process.ts+++ b/server/core/lib/worker/parent-process.ts@@ -16,7 +16,7 @@ export function parallelHTTPBroadcastFromWorker (options: Parameters<typeof httpif (!parallelHTTPBroadcastWorker) {parallelHTTPBroadcastWorker = new Piscina({filename: new URL(join('workers', 'http-broadcast.js'), import.meta.url).href,- // Keep it sync with job concurrency so the worker will accept all the requests sent by the parallelized jobs+ // Keep it sync with job concurrency so the worker will accept all the requests sent by the jobconcurrentTasksPerWorker: JOB_CONCURRENCY['activitypub-http-broadcast-parallel'],maxThreads: 1,minThreads: 1,@@ -39,7 +39,7 @@ export function sequentialHTTPBroadcastFromWorker (if (!sequentialHTTPBroadcastWorker) {sequentialHTTPBroadcastWorker = new Piscina({filename: new URL(join('workers', 'http-broadcast.js'), import.meta.url).href,- // Keep it sync with job concurrency so the worker will accept all the requests sent by the parallelized jobs+ // Keep it sync with job concurrency so the worker will accept all the requests sent by the jobconcurrentTasksPerWorker: JOB_CONCURRENCY['activitypub-http-broadcast'],maxThreads: 1,minThreads: 1,