trinnguyen / bahndsl

BahnDSL: A Domain-Specific Language for Configuring and Modelling Model Railways
GNU General Public License v3.0
1 stars 0 forks source link

Use SQLite to optimise the interlocking table generator #47

Closed trinnguyen closed 1 year ago

trinnguyen commented 1 year ago

There is another issue even if we could resolve the performance issue #44, it is of the swtbahn-cli. With the size of the interlocking table file of about 14GB, it would be almost impossible to load the whole table into the memory on the server. Instead, the server should parse and load the routes on-demand that might requires a lot of I/O operations and optimisations.

There is another way to store and load the interlocking table, that might also help solving the BahnDSL performance issue, by writing the data into an embedded database such as SQLite. The whole database is just a binary file and support basic features of SQL for manipulating and querying data. It also provides a C library which is transactional, and self-contained. The JVM application can manage the database file via JDBC driver. The whole change could be:

Below a draft database diagram:

Screenshot 2023-02-25 at 21 30 29

@eyip002 What do you think about implementing this?

eyip002 commented 1 year ago

@trinnguyen thanks! We also thought about having a database of routes. As you have mentioned, parsing and loading 14GB of YAML data into memory is impractical. We are also thinking of other ways to reduce the size of the interlocking table:

trinnguyen commented 1 year ago

Close the issue as there is a solution described above.