general merchandisers sector analysis
TRANSCRIPT
![Page 1: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/1.jpg)
1
Improving the Performance of Your
NI LabVIEW Applications
Dan Hedges
Senior Software Engineer
LabVIEW Performance Group
![Page 2: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/2.jpg)
2
Agenda
• How to find performance problems
Benchmarking
Profiling
• Understanding LabVIEW under the hood
Memory usage
Execution system
![Page 3: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/3.jpg)
3
Optimization Cycle
Benchmark
• Evaluate Performance
• Identify Problem Areas
Optimize
• Improve efficiency
• Improve Speed
![Page 4: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/4.jpg)
4
Benchmarking Code Execution
“Timing Template (data dep)” – LabVIEW Shipping Example
![Page 5: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/5.jpg)
5
Benchmarking Code Execution
Calibration Code
Analysis
“Benchmark Project” – LabVIEW Real-Time Shipping Example
![Page 6: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/6.jpg)
6
Tools for Measuring Resource Usage
(Windows)
• Task Manager
• Perfmon
![Page 7: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/7.jpg)
7
Windows Task Manager •Gives user a rough idea of
whether memory or CPU is
the bottleneck
•Can be helpful in
identifying memory leaks
•View»Select Columns …
allows you to add additional
stats
![Page 8: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/8.jpg)
8
Perfmon •Allows you to monitor
•Processors
•Disk I/O
•Network Tx/Rx
•Memory/Paging
•Access by typing
“perfmon” into the
Windows Run dialog
![Page 9: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/9.jpg)
9
Why Should You Profile Your VIs?
• Performance improvements are most effective in
the 20 percent
• Guessing which 20 percent is difficult
• 80 percent of the execution time is spent in 20 percent of the code
The 80/20 rule of software performance
![Page 10: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/10.jpg)
10
VI Profiler
• Tools >> Profile >> Performance and Memory…
![Page 11: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/11.jpg)
11
Demo – VI Profiling
![Page 12: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/12.jpg)
12
LabVIEW Desktop Execution Trace
Toolkit
Threads, CPU
and Memory
VIs
Multiple
Sessions
• Detailed
execution
traces
• Thread and VI
information
• Measurement
of execution
time
![Page 13: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/13.jpg)
13
Profiling and Benchmarking Summary
To answer this question: Use these tools:
What is my current performance? Benchmark VIs
What are my limiting resources? Task Manager, Perfmon
How much time are each of my VIs taking? VI Profiler
In what order are events occurring? LabVIEW Desktop Execution Trace Toolkit
![Page 14: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/14.jpg)
14
Under LabVIEW’s Hood
Memory Management
Execution System
![Page 15: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/15.jpg)
15
What Is In Memory?
Panel Diagram
Compiled Code
Data
![Page 16: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/16.jpg)
16
VIs in Memory
• When a VI is loaded into memory
We always load the data
We load the code if it matches our platform
(x86 Windows, x86 Linux, x86 Mac, PowerPC Mac)
We load the panel and diagram only if we need to
(for instance, we need to recompile the VI)
![Page 17: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/17.jpg)
17
Panel and Diagram Data
• How many bytes of memory does this VI use?
• The answer depends on:
Is the panel in memory?
Is the environment multi-threaded?
![Page 18: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/18.jpg)
18
Execute, Operate and Transfer Data
• Populated by Code
4K Execute Data
• Copy for Indicator 4K Operate
Data
• Temporary Buffer
4K Transfer Data
![Page 19: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/19.jpg)
19
Avoid Loading Panels, Save Memory
![Page 20: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/20.jpg)
20
Wire Semantics • Every wire is a buffer
• Branches typically create copies
![Page 21: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/21.jpg)
21
Optimizations by LabVIEW
The theoretical 5 copies become 1 copy operation
Copy
Output is “in place” with input
![Page 22: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/22.jpg)
22
The “In Place” Algorithm
• Determines when a copy needs to be made
Weighs arrays and clusters higher than other types
• Algorithm runs during compilation, not execution
Does not know the size of an array or cluster
• Relies on the sequential aspects of the program
Branches may require copies
![Page 23: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/23.jpg)
23
Bottom Up
In-place information is propagated bottom up
Increments array in place
Copy because
of increment No copies required
Branched wire
![Page 24: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/24.jpg)
24
Showing Buffer Allocations
![Page 25: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/25.jpg)
25
The In-Place Element Structure
Allows you to explicitly modify data “in place”
![Page 26: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/26.jpg)
26
Example of In Place Optimization Operate on each element of an array of waveforms
![Page 27: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/27.jpg)
27
Make the First SubVI “In Place”
changes into…
![Page 28: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/28.jpg)
28
SubVI 2 Is Made “In Place”
Changes into …
![Page 29: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/29.jpg)
29
SubVI 3 Is Made “In Place”
Changes into …
![Page 30: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/30.jpg)
30
Final Result: Dots Are Hidden
![Page 31: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/31.jpg)
31
Building Arrays
There are a number of ways to build arrays and
some are better than others
Bad
•Reallocates array memory on
every loop iteration
•No compile time optimization
![Page 32: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/32.jpg)
32
Building Arrays
There are a number of ways to build arrays. Try to
minimize reallocations.
Best
•Memory preallocated
•Indexing tunnel eliminates
need for copies
![Page 33: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/33.jpg)
33
Demo – Effects of Memory
Optimization
![Page 34: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/34.jpg)
34
Under LabVIEW’s Hood
Memory Management
Execution System
![Page 35: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/35.jpg)
35
VIs Are Compiled 0011101001010
1010001000111
1110101010101
0001011100010
1100101100110
0011101001010
1010001000111
1110101010101
0001011100010
1100101100110
0011101001010
1010001000111
1110101010101
0001011100010
![Page 36: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/36.jpg)
36
VIs Are Compiled: “Clumps” Clump 1
Clump 2
Clump 0 Clump 0
![Page 37: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/37.jpg)
37
Clump 2 Sleeping
Clump 1 Sleeping
Clump 0 Sleeping
VIs Are Compiled: “Clumps”
Completion of diagram:
Divide nodes, display of
indicators, then VI exit
Start of diagram:
Reads controls, then
schedules Clumps 1
and 2
Then sleeps ... Bottom for loop
indicator is updated
Clump 0 Scheduled
Sleep ...
Top for loop
indicator is updated
Clump 0 Scheduled
Sleep ...
Clump 0 Clump 1
Clump 2
Clump 0
![Page 38: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/38.jpg)
38
Single-Threaded LabVIEW
CPU Thread
User Interface
Loop
Code
Execution
Coroutines
![Page 39: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/39.jpg)
39
Exec
Thread
Multithreaded LabVIEW
CPU
UI Loop
Thread
Exec
Thread
messages
Exec
Thread
Exec
Thread
![Page 40: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/40.jpg)
40
Exec
Thread
LabVIEW on a Multicore Machine
CPU1
UI Loop
Thread
Exec
Thread
Exec
Thread
Exec
Thread messages
CPU0
![Page 41: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/41.jpg)
41
Some Operations Require the UI
Thread
Call Library Nodes
Control/Indicator Property Nodes
Front Panel Control References
![Page 42: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/42.jpg)
42
Execution Properties
![Page 43: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/43.jpg)
43
Reentrant VIs
• Reentrancy allows one subVI to be called
simultaneously from different places
Requires extra memory for each instance
• Use reentrant VIs in two different cases
To allow a subVI to be called in parallel
To allow a subVI instance to maintain its own state
![Page 44: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/44.jpg)
44
LabVIEW 2010 Compiler
• Generates code that runs faster, ~30%
• Takes longer to run (~5x-7x)
SSE Instructions
SubVI Inliner Register
Candidates Dead Code Elimination
Loop Invariant Code Motion
Common Subexpression
Elimination And more
![Page 45: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/45.jpg)
45
Demo – Effects of Execution
Optimization
![Page 46: General Merchandisers Sector Analysis](https://reader031.vdocuments.site/reader031/viewer/2022020704/61fb6d902e268c58cd5e0cb3/html5/thumbnails/46.jpg)
46
Next Steps
• LabVIEW Help
In LabVIEW
• ni.com/multicore
• ni.com/devzone
On the Web