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

Performance improvements for C++ #1364

Open
2 of 5 tasks
Rangi42 opened this issue Mar 20, 2024 · 0 comments
Open
2 of 5 tasks

Performance improvements for C++ #1364

Rangi42 opened this issue Mar 20, 2024 · 0 comments
Assignees
Labels
optimization This increases performance or decreases size rgbasm This affects RGBASM rgblink This affects RGBLINK
Milestone

Comments

@Rangi42
Copy link
Contributor

Rangi42 commented Mar 20, 2024

In the past few weeks we've been transitioning from C-style manual malloc and free (with over a dozen manually realloced collections, and known memory leaks in RGBASM, including some intentional ones essential to how it works) to C++-style STL generic (containers, algorithms, etc). This has in some cases reduced performance (particularly with older compilers).

Some possibilities for optimization:

  • assume instead of assert to allow optimizing out the failed-assertion case.
  • reserve an expected capacity for containers before filling them.
  • Make sure values are being std::moved instead of copied when possible.
  • std::visit uses a table of function pointers in older compilers (try some in this example). We could just be sure to compile the release builds with more recent gcc/clang, but that still wouldn't help the popular Windows builds. We could also write our own solution to visit a std::variant; there are many ways to do so (the linked example has some).
  • Bison's C++ parser, using its own variant instead of a union and allowing tokens to have nontrivial constructors, significantly slows things down. We might be able to switch back to a C-style one and add manual allocation of nontrivial token values (plus %destructors).
@Rangi42 Rangi42 added rgbasm This affects RGBASM rgblink This affects RGBLINK optimization This increases performance or decreases size labels Mar 20, 2024
@Rangi42 Rangi42 added this to the v0.7.1 milestone Mar 20, 2024
@Rangi42 Rangi42 self-assigned this Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization This increases performance or decreases size rgbasm This affects RGBASM rgblink This affects RGBLINK
Projects
None yet
Development

No branches or pull requests

1 participant