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

Replace C++ STDLib functions / reduce overhead #20

Open
seisatsu opened this issue Dec 21, 2021 · 10 comments
Open

Replace C++ STDLib functions / reduce overhead #20

seisatsu opened this issue Dec 21, 2021 · 10 comments

Comments

@seisatsu
Copy link
Owner

seisatsu commented Dec 21, 2021

The C++ STDLib might be taking up too much space. Over 50% of the program storage space is already taken at this point.

@seisatsu
Copy link
Owner Author

seisatsu commented Dec 21, 2021

I should note it is possible if absolutely necessary to change the partitioning scheme of the ESP32 chip so that more space is reserved for the program and less for data storage. You can do this at Tools -> Partition Scheme from the Arduino IDE, or probably from some project settings in ESP-IDF.

@seisatsu seisatsu changed the title Replace C++ STDLib functions Replace C++ STDLib functions / reduce overhead Dec 21, 2021
@pmer
Copy link
Collaborator

pmer commented Dec 21, 2021

I have a low-space-overhead C++ replacement library for vector that we can bring in. I have one for unordered_map, too, but we'd have to test it to see how much space it saves compared to map.

@seisatsu
Copy link
Owner Author

seisatsu commented Dec 21, 2021

I see that we are also using over 100kb on global variables, which is over 30% of our RAM and seems ludicrous.

For reference, base uLisp uses 22% of our program space and 10% of our RAM. So our overhead has doubled the program space and tripled the RAM usage. I suspect that the third-party C++ STDLib (ArduinoSTL) is a major source of extra beef in our implementation, and we can probably use our knowledge of basic data-structures to reimplement everything in a slightly less pretty fashion but using far less program space and RAM.

@seisatsu
Copy link
Owner Author

I have a low-space-overhead C++ replacement library for vector that we can bring in. I have one for unordered_map, too, but we'd have to test it to see how much space it saves compared to map.

This is good, our maps do not have to be ordered and vectors make life a lot easier, though I was considering using a simple linked list instead. We also will need a low-space-overhead replacement for STD::Pair.

@seisatsu
Copy link
Owner Author

Can you link these libraries in this issue?

@seisatsu
Copy link
Owner Author

If we change the Partition Scheme to "No OTA (2MB APP/2MB FATFS)" we get a lot of extra space to work with. OTA is a piece of firmware that allows flashing the chip over wifi; it takes up a lot of space and we probably don't need it.

@pmer
Copy link
Collaborator

pmer commented Dec 21, 2021

@pmer
Copy link
Collaborator

pmer commented Dec 21, 2021

Do our builds pass -O to GCC to do any optimization? The STDLib functions get massively smaller with even a basic optimization pass.

@pmer
Copy link
Collaborator

pmer commented Dec 21, 2021

The vector library that I use for all my new projects is at #22, although linked-lists might be good, too.

@pmer
Copy link
Collaborator

pmer commented Dec 21, 2021

I see that we are also using over 100kb on global variables, which is over 30% of our RAM and seems ludicrous.

Do you think that this could be a sign of static memory allocations (so malloc doesn't have to be used and memory allocation can't fail)?

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

No branches or pull requests

2 participants