Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Reduce the number of branches in NodeEncoder #211

Merged
merged 3 commits into from
Nov 8, 2024

Conversation

Ostrzyciel
Copy link
Member

@Ostrzyciel Ostrzyciel commented Nov 8, 2024

Yet another experiment in the NodeEncoder which could improve performance.

This focuses on removing as many branches from the code as possible through 2 optimizations:

  • Remove the newEntry field in lookup entries and instead of getOrAddEntry use the split getEntry and addEntry. This API, although less elegant, does reduce the number of branches by 1, because we have to check if the entry is new or not only once, instead of twice. This also makes it so that we can store just one integer in the hashmap per entry, instead of an object with 3 fields. This should help with memory bandwidth slightly.
  • More crazy: use branchless code instead of snippets like lastId + 1 == id ? 0 : id. It should help, especially because these branches were close to returns.

@Ostrzyciel Ostrzyciel merged commit e508ee5 into main Nov 8, 2024
4 checks passed
@Ostrzyciel Ostrzyciel deleted the node-encoder-again-sigh branch November 8, 2024 12:32
Ostrzyciel added a commit that referenced this pull request Nov 8, 2024
In some cases it was indeed faster, but most of the time, this is slower...

This reverts commit e508ee5.
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.

1 participant