Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Memory optimizations: User struct #538

Closed
jchristgit opened this issue Apr 19, 2024 · 1 comment · Fixed by #567
Closed

Memory optimizations: User struct #538

jchristgit opened this issue Apr 19, 2024 · 1 comment · Fixed by #567
Assignees

Comments

@jchristgit
Copy link
Collaborator

At present we store the following attributes on the user struct that are
technically not used since we do not really provide OAuth2 functionality at the
moment (and apart from that, Nostrum is a bit big to provide that, although I
think using it as a library instead of an application would be a great
improvement):

  • email
  • mfa_enabled
  • verified

The discriminator field has been deprecated by Discord and - to my knowledge,
but we should verify this - we can remove it, as it is just 0 for
compatibility reasons now. That said, I do remember seeing user accounts with
discriminators still set, but I believe these to be accounts that haven't logged
in for a while. If we're unsure, we should probably keep it.

Finally, the public_flags field should just be an integer used as a bitset,
and we should provide a function either in the user or in the flags module to
parse said bitset into a struct. I am not aware of people really using this
field in the first place.

In an ideal world, we could also save memory by not including the bot field
with every user object, as it will be false in > 99.99% of cases. But likely,
we can not sanely do it because structs require all their fields to be present.

The goal is to make nostrum the most efficient library on the planet. The BEAM
and its engineering marvels are on our side.

@jb3
Copy link
Collaborator

jb3 commented Apr 19, 2024

Discriminator is still in use by bots, until that changes we should keep it for that purpose, once that changes we can drop it.

Public flags will be a huge saving so we should work on that.

@jchristgit jchristgit self-assigned this May 1, 2024
@jchristgit jchristgit linked a pull request May 1, 2024 that will close this issue
@jb3 jb3 closed this as completed in #567 May 4, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants