Skip to content

Cache channel users to avoid redundant API calls and reduce bottleneck#646

Merged
rusq merged 1 commit intorusq:masterfrom
volker-fr:cache-user
Mar 19, 2026
Merged

Cache channel users to avoid redundant API calls and reduce bottleneck#646
rusq merged 1 commit intorusq:masterfrom
volker-fr:cache-user

Conversation

@volker-fr
Copy link
Copy Markdown
Contributor

@volker-fr volker-fr commented Mar 17, 2026

When fetching threads with threadOnly=true, procChannelUsers was called for each thread in the same channel, making redundant GetUsersInConversation API calls. This adds a userCache similar to chanCache to store channel users and skip the API call when already fetched.

On slackdump resume -threads this significantly increases the speed. In a simple test slack where only one channel was backed up with slackdump archive, this double the speed.

This issue fixes one of the root causes of the slowness reported in #560

NOTE: At the same time it is unclear how beneficial this change really is. In #647 the bottleneck of slackdump resume -threads got improved by not having to fetch users -- and therefore this caching. If #647 is merged, this leaves the usage of this caching probably to only 1-2 edge cases -- if et al. I didn't fully understand the other uses cases here and if it would benefit from caching.

Speed testing

4.1.0 takes 24sec

% ./slackdump-4.1.0 \
        resume \
        -threads \
        test-slackdump-dev
...
0.69user 0.47system 0:24.44elapsed 4%CPU (0avgtext+0avgdata 52144maxresident)k
0inputs+91440outputs (0major+10474minor)pagefaults 0swaps

with caching it only takes around 8 seconds

% ./slackdump-this-pr \
        resume \
        -threads \
        test-slackdump-dev
...
0.55user 0.34system 0:07.90elapsed 11%CPU (0avgtext+0avgdata 51716maxresident)k
0inputs+56112outputs (0major+9244minor)pagefaults 0swaps

When fetching threads with threadOnly=true, procChannelUsers was called
for each thread in the same channel, making redundant GetUsersInConversation
API calls. This adds a userCache similar to chanCache to store channel
users and skip the API call when already fetched.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@rusq rusq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rusq rusq merged commit d2de440 into rusq:master Mar 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants