-
Notifications
You must be signed in to change notification settings - Fork 48
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
[FEATURE] onReadItem and onReadTile events #4
Comments
Hi, reading the map chunked is quite trivial I think but transforming inlcding writing is harder. I started on this branch: https://github.com/Inconcessus/OTBM2JSON/tree/add-stream-reader. See |
I made some more changes using a simple synchronous callback instead of using an event emitter. The problem I encountered is that the application uses a depth-first approach. We get the top level element last and have to write it to file first. So just piping it doesn't really work out. This transformation approach takes every If you want to give it a test just clone git repository and checkout the new branch.
|
Look for |
I tested this on a 25MB OTBM file and the memory usage went from 300MB to 50MB. Let me know what your findings are! |
Just tested with 120MB OTBM on [email protected] [all cores], 32 GB RAM, Samsung NVME SSD (read/write 1.5-3.5GB/s). 'time' command with RAM and CPU usage measurement:
Basic (for that version I had to increase default ~2GB node RAM limit: node --max_old_space_size=8000 big.js ): Stream: I added some 'global.gc()' for test, but it only increased time of execution. Almost zero RAM peak usage change. |
So there's a big improvement but not as much as I would expect. The streaming function handles one
Can you add in the transformation routine:
Then we can get an estimate of the size of a single tile area in JSON representation. |
If memory remains a huge problem we can always write the completed features to disk and compile them afterwards using |
There must be some memory leak in stream algorithm. It's not just 1 jump to 1.6GB. It starts from 130MB and grows slowly to 1.6GB. I ran Inspector and it showed that most of time app spent on copying FastBuffer and some FastBuffer 'buffer' is thing that grows to 1.6GB in RAM. |
Current version first read whole map into RAM (UP TO FEW GB RAM).
Then let me do some advanced operations on map.
Then I can save my modified map.
There are many functionalities for which I don't need whole map: read house tiles, find some item position
It would be nice, if I could run it with few MB RAM (remove 'tile' from memory just after it's loaded with items).
The text was updated successfully, but these errors were encountered: