-
Notifications
You must be signed in to change notification settings - Fork 165
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
Proposal to split MSL into single files #2975
Comments
I'm totally support the one file per model structure. I do this in all my other projects but would like to know if there are arguments to NOT do it this way. The released version could after all be shipped as a simple .mo file (since we still don't have a proper standardised archive format like for example OpenModelica offers). |
There are some reasons against it, but they are mainly Windows maximum path limitations (when using the standard C interface) and I think you might only hit these limitations if you also kept resources at the same location as the files (but we have them in Resources now, which should be fine). |
I remember a SimulationX benchmark, where loading the MSL with all records/functions/models as single files took twice as long as the current structure. In the end, it is about finding a good compromise on loading performance and PR convenience. |
That's interesting. In OpenModelica, it is always faster to load multiple files in parallel than a single file for the whole of MSL (using 2 threads is slower than using 1, but even using a single thread to load the full MSL in a single file is slower than loading multiple small files in series)... I compare the current structure to everything in a single file now though. |
To approach the root request here:
The bit of text you see at the start of a diff section is called a "hunk header". There are a couple of predefinied ones, but Modelica is not part of those. See here for some more info--it is possible to add a custom detection regex to obtain a more meaningful description (e.g. the class/model/function name) |
Note that by using a global attributes file in connection with the above, you should be able to implement this for all your modelica repos without any changes in the repos themselves, which would be convenient. I haven't tested this, though. |
Some minor comments:
|
On 2019-06-17, at 09:47, Hans Olsson ***@***.***> wrote:
Some minor comments:
The discussion about time to load and reading of files in parallel is important, but misses one aspect: as e.g. Dymola loads parts of MSL as needed. A more fine-grained storage should make that faster.
Any tools with functionality to search for classes in enabled libraries will need to know the contents of all libraries as soon as this search is used. Hence, without a caching scheme to support searching for classes without loading all enabled libraries, the loading time for entire libraries remains important.
Henrik
|
My summary from this discussion:
Some more thoughts:
So my personal conclusion is that splitting up the MSL into single files does make sense, as the benefits predominate. So far, are there any significant or even no-go objections? However, I think we can still leave this ticket open for discussion so that others who were not able to respond so far, have the opportunity to make comments as well. |
That's not really going to help. You can easily merge files if you both work on different parts of the file; usually this is even done automatically. |
My idea would be to find a good compromise, e.g., one file per package, instead of choosing one or another extreme, i.e., one class per file or one file for all classes, respectively. I also prefer if tool vendors distribute their MSL in the same file structure as the officially released MSL for the sake of comparison, though they are free to restructure for sure. Can one of the grammar experts (@HansOlsson @sjoelund @henrikt-ma) check how to add and apply the "hunk header" for easier PR overview? Thanks. |
You have to add that hunk header to your git config. As for as I could tell, GitHub will not use it which will not make it great for PR preview. |
I think the file structure of the MSL hosted on GitHub shall support the library officers and Modelica code developers and maintainers as tight as possible. To me this ticket is mainly about improving the workflow when developing and maintaining the MSL. @beutlich Why do you think that a compromise with one file per package is "better" than one file per class. I host all my other projects with one file per class. Another compromise could be that the tool vendors agree on re-structuring the MSL in a certain way when shipping it with their tool. I guess in the 21st century this can be performed straight forward without compromising the MSL. |
I tried to see if it were possible to construct "hunk header" and I believe the following handles most cases when using
But I haven't investigated how to turn it into a PR, or how it would work on GitHub. The second part is designed to handle Modelica.Media without tripping on local classes. |
I asked the GitHub support team for their support. Let's see. |
Here's their reply:
Does someone feel comfortable to contribute the Modelica hunk header definition to git? Thanks. |
I can take a look next week, if no-one else volunteers. |
Seems I was more busy than I thought, so it will be next week. |
One more argument in favor of the a one file per Modelica class approach: In each Modelica class it is possible to a revision history. For example, So the feature of using the revision history is basically not used, as it is way too much redundant work to log all changes performed through GitHub as HTML code. Instead it would make a lot more sense to use the history feature of GitHub itself to show all changes of a Modelica class. So a Modelica tool could easily provide a link to the revision history of each Modelica class once it knows the GitHub repository location. For example, https://github.com/modelica/ModelicaStandardLibrary/commits/master/Modelica/Electrical/Analog/Examples/Rectifier.mo shows the entire revision history of the simulation model |
I have now investigated three parts:
xfuncname:
Word-regex:
However, I haven't compiled this into git and I haven't made any test-cases yet. Is anyone familiar with whether such changes are likely to be accepted? The small number of language seem to indicate some exclusivity - but it could also be that it such a pain to make the proposal. |
To be honest, I think to search for a workaround to see to which file the comparsion (of PRs) belongs to is not an optimal solution. |
This is not intended to identify the file a certain diff hunk belongs to (this already exists now in the Github interface), but to identify the class it belongs to, which directly addresses the issue you reported, i.e.
|
@HansOlsson I think the first step would be to write to the mailing list:
There is a document about submitting patches. It seems there is an easy way to get automated tests/compilation going via Travis if you clone the git/git repo on Github - this probably would save you some hassle with setting up local compilation etc, when working on your changes. |
During the discussion it turned out more and more that this is not only an issue of pull requests (PRs). Getting information on what Modelica class the change of a PR refers to is finally only one aspect in this discussion. It is also a lot easier to track and to reproduce changes of any Modelica class of the MSL when splitting up the MSL into single files per class: I think this is a very important aspect when it comes to the quality check of the MSL. |
I am not in favour of splitting Modelica.Media.IdealGases.Common.SingleGasesData in 1241 files. This is an overkill. My proposal would be to first try one file per package and maybe one file per example model. |
I would go for a pragmatic solution: Split into single files, except when this is overkill or unfeasible which is probably the case with the 1241 gases.
I plan to split up the following as soon as open PRs are merged:
I think that will make life easier when merging maintenance PRs to those Libs. |
done:
Planned to do when open PRs are merged:
|
I also agreed with @christophclauss to switch
to single files. |
Alreay done (splitted to single files):
Still left to do:
|
@AHaumer Are you going to also proceed with Mechanics.MultiBody? Then I would wait with fixing of some issues concerning this package. |
@tobolar Since I'm not library officer for MultiBody, and I'm not a power user of MultiBody, I'd prefer to leave it up to you ... |
I will prepare PRs to split the following libraries:
@tobolar If you're still ready, I can prepare a PR so that @tobolar and @MartinOtter (and others) can review the changes |
Translational and Rotational have be done again since there was a conflict with a different PR (which is now merged. |
@christiankral For MultiBody, there are still two PR open: #3113 and #2501. |
@tobolar we won't touch MultiBody, only Rotational and Translational |
I believe most of the sub-libraries are done. |
Whenever I visually inspect a pull requests (PR) on GitHub I very much dislike that I have no orientation on what Modelica class the actual PR refers to. For example PR #2956 shows that lines 4058 to 4061 are affect. What models was the change made at? I have no idea at all. OK, I could extend the code region around the change,
but this is actually not what I am interested in. Instead I would only like to know what Modelica class the change refers to.
I were a lot easier if each Modelica class were a separate file. Possibly merge conflicts could be reduced that way as well -- someone else may know this.
I understand that there have been objections previously, that too many files increase the time to load the Modelica Standard Library. If that were still the case on a modern SSD disk, tool vendors could re-organize the MSL such that every main domain package is organized as one file, or similar. I guess this is manageable, if required.
Currently the file structure of the MSL is very heteregenous. Examples:
Modelica/package.mo
contains the UsersGuide -- why isn't there a separate directory used instead?Modelica/Electrical/Analog/
organizes every sub-package as a file exceptModelica/Electrical/Analog/Examples
which is organized in single filesModelica/Mechanics/Rotational.mo
is one package in one fileI propose to organize each Modelica class in one file.
The text was updated successfully, but these errors were encountered: