Skip to content

optimize Identify (a bit)#1620

Merged
TheArcaneBrony merged 5 commits intospacebarchat:masterfrom
oh64:master
Apr 6, 2026
Merged

optimize Identify (a bit)#1620
TheArcaneBrony merged 5 commits intospacebarchat:masterfrom
oh64:master

Conversation

@oh64
Copy link
Copy Markdown
Contributor

@oh64 oh64 commented Mar 27, 2026

I'll write a proper description tomorrow
I plan to look into checkToken and userQuery too

@TheArcaneBrony
Copy link
Copy Markdown
Member

checkToken doesnt have much that could be optimised, it does a whole 2 things:

  • parse/validate an access token
  • check whether the user is disabled/"deleted" (this is the slow part)

Comment on lines +378 to +408
for (const c of memberGuildChannels) {
const arr = channelsByGuild.get(c.guild_id!);
if (arr) arr.push(c);
else channelsByGuild.set(c.guild_id!, [c]);
}
for (const e of memberGuildEmojis) {
const arr = emojisByGuild.get(e.guild_id!);
if (arr) arr.push(e);
else emojisByGuild.set(e.guild_id!, [e]);
}
for (const r of memberGuildRoles) {
const arr = rolesByGuild.get(r.guild_id!);
if (arr) arr.push(r);
else rolesByGuild.set(r.guild_id!, [r]);
}
for (const s of memberGuildStickers) {
const arr = stickersByGuild.get(s.guild_id!);
if (arr) arr.push(s);
else stickersByGuild.set(s.guild_id!, [s]);
}
for (const v of memberGuildVoiceStates) {
const arr = voiceStatesByGuild.get(v.guild_id!);
if (arr) arr.push(v);
else voiceStatesByGuild.set(v.guild_id!, [v]);
}
for (const t of allThreads) {
const arr = threadsByGuild.get(t.guild_id!);
if (arr) arr.push(t);
else threadsByGuild.set(t.guild_id!, [t]);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

missing traces for each

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also, we have an arrayGroupBy function for this :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Me happy when arrayGroupBy

add(other: ElapsedTime): ElapsedTime {
return new ElapsedTime(this.timeNanos + other.totalNanoseconds);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this class is supposed to be read-only :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wat

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done :)

@oh64 oh64 changed the title optimise gateway optimize Identify with arrayGroupBy + parallel relations Apr 2, 2026
@oh64 oh64 changed the title optimize Identify with arrayGroupBy + parallel relations optimize Identify (a bit) Apr 2, 2026
@oh64 oh64 marked this pull request as ready for review April 2, 2026 00:03
@oh64
Copy link
Copy Markdown
Contributor Author

oh64 commented Apr 2, 2026

I will make a test just in case

@oh64
Copy link
Copy Markdown
Contributor Author

oh64 commented Apr 2, 2026

Seems to still work fine

@TheArcaneBrony
Copy link
Copy Markdown
Member

will merge, worst case i revert i guess

@TheArcaneBrony TheArcaneBrony merged commit 07bdc33 into spacebarchat:master Apr 6, 2026
0 of 2 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