Looking for a Progress Window in MPS
Hello,
i have implemented a text-coding software in mps - very strange use case of mps capabilities, but very suitable! However, i have to sort some data in a mps model, which takes time 2-3 minutes.
Is there a possibility to display the progress bar window (same one while generating code?) Where can i find an example?
Dan
i have implemented a text-coding software in mps - very strange use case of mps capabilities, but very suitable! However, i have to sort some data in a mps model, which takes time 2-3 minutes.
Is there a possibility to display the progress bar window (same one while generating code?) Where can i find an example?
Dan
Please sign in to leave a comment.
You can do it using Idea platform API:
ProgressManager.getInstance().run(...)
Example can be found in ModelCheckerViewer class and in some other places.
Regards,
Mihail.
thanks for your answer. Btw - are you interested in using my language for profiling mps? I have some problems when deleting one of the rootnodes, containing my data nodes ...
But for know it works fine.. but could be an mps issue...
dan
The best variant is if you capture a performance snapshot using YourKit profiler and send it to me. You can also give me your language and an instructions on how to reproduce the lag - I'll make a snapshot by myself in this case.
Regards,
Mihail
i ll look for an ideal use case to make the point.
Regarding the ProgressManager.getInstance().run(...), where i passed a Task.Modal(), can i simply pass in the model also and edit around in the model (in the thread of the Task?) ?? Is that okay, or should i do that differently?
Dan
read action {
colName = columns.get(0).name;
}
indicator.setText("Processing words in column " + colName);
seems that read action also spans a thread ... when i remove the read action, everything is fine...
Dan
you are right about the read-action, but it is executed in the same thread, just under a lock.
but then - what could be my problem. no exception - nothing. Is the lock the problem? Or better ... is the read action a blocking statement ?
public void run(@NotNull() ProgressIndicator indicator) {
init(indicator);
int numColumns = columns.size;
setTotalSteps(indicator, numColumns);
for (int i = 0; i < columns.size; i++) {
string colName = "";
read action {
colName = columns.get(0).name;
}
indicator.setText("Processing words in column ");
indicator.setText2("" + i + "/" + numColumns + " ");
waitASecond();
oneMoreStep(indicator);
}
end(indicator);
}
If you are performing it in an action, set the action's "execute outside command" property to true. This could be the problem.
public void run(@NotNull() ProgressIndicator indicator) {
init(indicator);
int numColumns = columns.size;
setTotalSteps(indicator, numColumns);
// no problem until here - process and indicator have to be set up in some way..
// now start processing ... read something from the model, e.g. columname
// and expose this name to the indicator for user ...
for (int i = 0; i < columns.size; i++) {
string colName = "";
read action {
colName = columns.get(0).name;
}
indicator.setText("Processing words in column ");
// do time consuming operation here ...
waitASecond();
// done ....
oneMoreStep(indicator);
}
end(indicator);
}
Once again - if you are doing it in an action, just set "execute outside command" to true, and MPS will then let you manage read-write access by yourself (no write-action will be executed before starting the progress task). The code you wrote below should be left unchanged.
If you are performing this not in an action, then could you please provide a stacktrace for the moment when the ProgressManager.getInstance() is executed? I could then look at it and say whether it's a deadlock because of a write-access deadlock and what should you do in this case.
Regards,
Mihail
thanks for your patience. well im using it in a refactoring.
refactor(refectoringContext)->void {
sequence<node<Column>> columns = refactoringContext.node.getColumnOfThisProject();
CodeBookGuesser_WordList guesser = new CodeBookGuesser_WordList(refactoringContext.project, columns.toList);
ProgressManager.getInstance().run(guesser);
refactoringContext.node.model.add root(guesser.getCodebook());
}
I do not get a stacktrace - mps simply hangs up...
I've checked - refactoring is executed in a write-action always. The problem is that we don't have a progress indicator for refactorings. Filed: http://youtrack.jetbrains.com/issue/MPS-16040
Nevertheless, you can do the following:
Note that the line
is better to be moved to your guesser and to be executed in the same read/write action in which you perform model analysis. If you don't do so, you can get, for example, already-deleted model when you try to add a root (as you add root in another write-action and the model can be deleted between two write-actions).
Do not hesitate to ask further questions,
Mihail
OOM is not this case, imo. If you remember your case, please add some details.