I'd like to know why sometimes my build is much slower.
So I've decided to measure the time of long-running taks.
When running pure Scala code, it is quite easy to do so:
def myMethod() = {
val initTime = System.currentTimeMillis
...
val elapsedTime = System.currentTimeMillis-initTime
}
But for tasks like packageBin or compile, whose source code I cannot change, I don't know how to measure it, because I cannot control when someTask.value is run.
Any hint?
Related questions:
Profiling sbt builds
add -Dsbt.task.timings=true to your JAVA_OPTS when launching sbt
For a more complete analysis, you can also use jrudolph/sbt-optimizer/
sbt-optimizer is an experimental plugin that hooks into sbt's task execution engine and offers a graphical ASCII report once a tree of tasks has been run
Add the plugin to project/plugins.sbt:
addSbtPlugin("net.virtual-void" % "sbt-optimizer" % "0.1.2")
and enable it in a project with:
enablePlugins(net.virtualvoid.optimizer.SbtOptimizerPlugin)
Each output line corresponds to one task that has been executed.
The first time is the total time this task was running.
The second time displayed in green is the actual execution time.
The third time displayed in red is time the task wanted to run but was waiting for the global ivy lock.
The last time displayed in cyan is the time the task was blocked waiting for Ivy downloads.
Related
Alright, so I'm learning codesys in school and I'm using Function-Blocks. However they didn't seem to update when updating local variables, so I made a test, the one you can see below.
As you can see, in the FB below, "GVL.sw1" becomes True, but "a" doesen't. Why does it not become True? I tested a friends code and his worked just fine, but mine doesen't...
https://i.stack.imgur.com/IpPPZ.png
Comment from reddit
You are showing the source code for a program called "main". You have
a task running called "Main_Task". The program and task are not
directly related.
Is "main" being called anywhere.
So i added main to the "main task" and it worked. I have no idea why it didn't work in the real assignment but maybe I'll solve it now that i have gotten this far.
In your example you have 2 programs (PRG): main and PLC_PRG.
Creating a program doesn't mean that it will be executed/run. For that you need to add the program to a Task in the Task Configuration. Each Task will be, by default, executed on every cycle according to the priority they are configured with (you could also have them be executed on an event and etc. instead). When a Task is executed, each program added to that Task will be executed in the order they are placed (you can reorder them any time).
With that said, if you look at your Task Configuration, the MainTask only has the program PLC_PRG added, so only that program will run. The main program that you are inspecting is never even run.
I've been having this issue since I started using this Simulink model. No matter what I try, Simulink rebuilds the model every time I run it. I've taken a look at the checksums using the following procedure:
>> [cs1, cs1det] = Simulink.BlockDiagram.getChecksum(<model name>);
>> (Here I hit run on the model without changing anything)
>> [cs2, cs2det] = Simulink.BlockDiagram.getChecksum(<model name>);
>> cs1 == cs2
1
1
1
1
Why would Simulink rebuild the model if the checksums are the same? I did create another model with some simple logic in it and after compiling once I was able to run it multiple times without Simulink recompiling it.
Additionally, when I hit run when in Rapid Accelerator mode I notice that an asterisk pops up next to the model name in the title. Since this means that the model has unsaved changes, could running it cause any changes to be made? I've checked the callback methods and there's nothing being run when the sims starts (in fact there's nothing in any of the callback methods).
Is there some kind of basic compilation / initialization / build that Simulink runs through before it runs every time? I'm trying to run my model in Rapid Accelerator mode without having it recompile since it takes roughly 45 minutes to compile every time.
Have I overlooked some configuration parameter of the model? Is there some global MATLAB/Simulink variable I need to change?
Is it building or is it updating?
Typically, when you hit the Run button, MATLAB has to propagate signals, check your model for errors, initialize variables . . .
It may seem like building, but to actually confirm it is building, check to see of you have yourmodelname.c file in the folder.
Also check File Menu preferences, and go through the functions there and see if something is getting called.
Could you try to set Configuration Parameter -> Code Generation -> Interface -> Code replacement library to None (In case that your demand is not related to GNU library ...) on reference model?
By the way, it is working for me.
Anecdotally, our builds seem slower after enabling these options. I've searched online a bit and tried to do some comparisons but found nothing conclusive. Wondering if anyone knows offhand.
A great way to answer your own question is to try and measure it. For instance, I tried to compile with SBT (which gives the build time in seconds). I took a medium sized project (78 scala source files) that I tried to compile with and without the flags. I started by doing 3 clean/compile invocations to warm-up the disks (be sure that everything is cached properly by the controller and the OS). Then I measured 3 time the build time to get an average.
For both cases (with and without the flags), the build time was identical. However, it is interesting to note that the first warm-up build was really slow: almost 7x slower ! Therefore it is very difficult to rely on impressions, because the build time will be dominated by the way you access your source files.
Unless your desktop is a teletype with particularly slow electromechanical relay switches, you're safe - it does the same work either way, so if there were a difference it'd be in how long it takes to display the deprecation/unchecked warnings.
(reposted from here)
I'm trying to measure/log the running time of a task.
I've looked into "wrapping" a task by adding one task before and one task after but this would not work every time as sbt only guarantees a partial order.
A better wrapping would be something along these lines:
wrappedTask := {
startMeasuringTime()
somehowInvoke(myTaskKey in SomeContext)
endMeasuringTime()
}
What should this "somehowInvoke" be?
Measuring the time taken by a task needs support from the task executor.
As you imply, you cannot do this only by using task primitives.
I've pushed some sample code that I wrote a while back that shows the idea.
A complication that the sample code doesn't handle is that what the user conceptually thinks of as one task (compile, for example) may actually be implemented as several tasks and those timings would need to be combined. Also, a task like internalDependencyClasspath "calls" other tasks (flatMap) and so its execution time includes the execution time of the "called" tasks.
EDIT: This was implemented for 0.13.0 as an experimental feature in 602c1759a1885 and 1cc2f57e158389759. The ExecuteProgress interface provides sufficient information that the previously described issues are not a problem.
I am trying to run my hadoop map/reduce job inside eclipse (not a node and or cluster) to debug my map/reduce logic. I want to able to put a break point on the mapper and reducer and make eclipse to stop on these break points however this is not happening and the things mapper get stuck. I noticed that if I hit suspend and run a couple of times, it will eventually break on the mapper and reducer. I am very new to eclipse. What am doing wrong?
I am literally running the word count code at http://wiki.apache.org/hadoop/WordCount and have break points on lines 22, 35.
Maybe you have disabled break points? The break points will be displayed with a strike through icon if that is the case.
When not running locally it is possible that your break points will not be hit, because the tasks are run in new isolated JVMs. However that does not seem to be the case here, because suspend would not work either in that case.