Are your XPages applications performing like a Florida senior citizen driving in the left lane at 55 mph? A key to speeding up your XPages applications is knowledge of the:
-JSF lifecycle
-partial refresh
-and partial execution.
In this webinar, TLCC's Howard Greenberg covers these concepts and then applies them to optimizing an XPages application. Learn how to dramatically increase your XPages performance and make your users happy.
3. Who We Are
• Manage, modernize, and mobilize your business
applications with software and solutions from
Teamstudio.
o Easy-to-use tools for developers and administrators
o Modernization Services to help you mobilize your
applications
o Mobilization platform for those who want to mobilize using
their own internal resources
• 1600+ active customers, 53 countries
• Offices in US, UK, and Japan
4. Teamstudio Unplugged
• Your mobile Domino server:
take your IBM Notes apps with you!
• End-users access Notes applications from mobile
devices whether online or offline
• Leverages the powerful technology of XPages
5. Unplugged Templates
• Continuity
Mobile offline access to BCM programs
• OneView Approvals
Expense approvals; anywhere, anytime
• CustomerView
Lightweight CRM framework for field sales and
field service teams
• Contacts – customer information database
• Activities – customer activity log
• Media – mobile offline file storage and access
6. • Set of controls for IBM Domino developers
working on XPages apps and on Notes app
modernization projects
• Re-write of the Teamstudio Unplugged
Controls project, but adds full support for
PC browser-based user interfaces as well as
mobile interfaces
• Enables XPages developers to create
controls that are responsive
• Learn more:
teamstudio.com/solutions/xfoundations/xc
ontrols
XControls
7. Teamstudio Services
• Professional services for modernization, Web
enablement, project management, development,
and administration
o Modernization Services
o Developer Assistance Program
o Application Upgrade Analysis
o Application Complexity Analysis
o Application Usage Auditing
• http://www.teamstudio.com/solutions/services/
8. • XControls Business Edition promotion:
o Be entered to win an Apple iPad mini when you sign up to demo XControls Business
Edition before Oct. 31, 2015.
• XControls webinar: Nov. 3
9. Move your XPages Applications to the Fast Lane
1
Are your XPages Apps are like this???
10. Your Presenter Today – Howard Greenberg
• Certified Lotus Instructor since R3
• Co-founded TLCC in 1987
• IBM Champion
• Prior to that 12 years at IBM in the PC group
• Also…
– Certified Public Accountant
– Certified Information Systems Auditor (CISA)
– Certified Flight Instructor
2
11. How can TLCC Help YOU!
3
• Private classes at
your location or
virtual
•XPages Development
•Support Existing Apps
•Administration
• Let us help you
become an expert
XPages developer!
• Delivered via Notes
• XPages
• Development
• Admin
• User
Self-
Paced
Courses
Mentoring
Instructor-
Led
Classes
Application
Development
and
Consulting
Free
Demo
Courses!
12. 4
• Save hundreds and even Thousands of Dollars
on the most popular courses and packages:
XPages Development
Notes and Domino Development
Domino Administration
• Now extended through October 30th
http://www.tlcc.com/fallsale
13. Upcoming and Recorded Webinars
5
www.tlcc.com/xpages-webinar
View Previous Webinars
(use url above)
• Ask The XPages Experts
– November 17
14. IBM Champion Nominations are Open
• Nominations are open for the IBM Champion program
– Through October 31st
– Go here to complete the nomination form
• If you think someone has contributed to the ICS
community then nominate them!
– Speaks at conferences
– Helps out in forums and Stack Overflow, etc.
– Hosts videos, blogs, webinars
– More about the IBM Champion Program here
6
15. Asking Questions – Q and A at the end
7
Use the Orange Arrow button to
expand the GoToWebinar panel
Then ask your questions in the
Questions pane!
We will answer your questions
verbally at the end of the
webinar
16. Agenda
• What affects XPages Peformance
• XPages Lifecycle
• Partial Refresh vs. Partial Execution
• Tools to Analyze Peformance
• Case Studies
• Questions???
8
17. What affects XPages Performance?
9
Client:
Browser
OS
CPU
Hard drive
Memory
Network
Speed and
Latency Server:
Hardware
OS
Application (Domino)
18. What’s Involved on the Server...
• Server HW and OS pass network request to Domino
• Domino networking and HTTP Task
• XPages runtime engine
– Restore state (might read from disk)
– Java code builds HTML, etc. that gets sent to
browser
• Uses the JSF Lifecycle (more on this later)
• Calls Backend Domino objects if needed
• Domino passes response (HTML, CSS, JS, etc.) to OS
and via network to client
10
19. Server Performance Variables
• Hardware
– CPU, Network, Memory, and Hard Drive
• Operating System (Use 64 bit OS!)
• Domino:
– Memory Settings
• HTTPJVMMaxHeapSize
• Use HTTPJVMMaxHeapSizeSet=1 to prevent
changes
– Number of threads
• See this article from IBM
– Encryption (HTTPS)
11
20. Optimizing Memory Utilization
• xsp.persistence.mode - Set in XSP Properties file
– Defines the persistence mode for the JSF pages
• file: All the pages are persisted on disk
• fileex: All the pages are persisted on disk except the current one,
which stays in memory
• <else>: All the pages stay in memory (tree mode)
12
21. JavaScript/CSS Aggregation
• Groups many DOJO, CSS / JS files into a single file
– Less requests from the browser to the server
– Performance improvements on networks with high
latency
– Enhanced performance parsing CSS / JS
– Fewer connections to the server
13
On the Server: xsp.properties:
xsp.resources.aggregate=true
23. JSF Life Cycle - Post
15
Restore View
•Restore component tree
•Events:
•afterRestoreView
Apply Request
Values
•Copy data to Editable
controls
Process Validations
•Validations
•Converters
Update Model
Values
•Move values to data
source
Invoke Application
•Application logic
•Events:
•onClientLoad (XPage,
etc)
•on… events of button,
etc.
Render Response
•Convert to HTML, etc.
•Events:
•beforeRenderReponse
•afterRenderResponse
Request
Response
24. Lifecycle1 XPage – Initial Page Load
16
Render Response
•Rendered property for id: label1
•Label property for id: label1
•Rendered property for id: inputText1
•Default value property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•values property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Value property for id: computedField1
•Rendered property for id: computedField2
•Value property for id: computedField2
12 SSJS Calls
25. Lifecyle1 – Submit (Full Update)
Restore View Apply Request Values (8)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Process Validations (11)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Validation for inputText1
•Default value property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Update Model Values (8)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Invoke Application (1)
•OnClick event for id: button1
Render Response (11)
•Rendered property for id: label1
•Label property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•values property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Value property for id: computedField1
•Rendered property for id: computedField2
•Value property for id: computedField239 SSJS Calls
17
26. When to Execute - # vs $
• # is Compute dynamically
– Executed every time the page is
rendered
– Use for values that are likely to change
• $ is Compute on Page Load
– Executed when the page is first loaded
– Use for values that don't change
18
<xp:label id="label1">
<xp:this.value>
<![CDATA[#{javascript:return “My
Label”;}]]>
</xp:this.value>
</xp:label>
27. Lifecyle2 – Submit (Full Update) - On Page Load
19
Restore View Apply Request Values
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Process Validations (2)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Validation for inputText1
•Default value property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Update Model Values
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Invoke Application (1)
•OnClick event for id: button1
Render Response (3)
•Rendered property for id: label1
•Label property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•values property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Value property for id: computedField1
•Rendered property for id: computedField2
•Value property for id: computedField2
6 SSJS Calls, saved 33
Changed all Rendered and
Values (comboBox) to only
compute on Page Load
28. Options for dynamically computing the Rendered:
• Scoped variables
– Still get calculated but do the heavy lifting once and then
read the scoped variable in the Rendered property
• DataContexts
– Compute a value at the Xpage or Panel level once
– Refer to the value using EL (much faster than SSJS)
20
But I need dynamic Rendering!
29. DataContext - Pitfall
• Be careful binding data context variables dynamically
– They will be recomputed multiple times, even when in
partial execution mode and if they are not in use (six times!)
• Apply Request Values
• Process Validations
• Update Model Values
• Invoke Application
• Twice in Render Response!
• If computed on page load then only computed once on page load
• See Paul Withers blog entry to learn how to set a data context
value via code
21
30. Partial Refresh vs. Partial Execution?
• Partial Refresh (Update)
– Computes entire XPage, only sends back
what is in the partial refresh id (refreshId)
• Partial Execution
– Only calculates what is in the area
specified (execId)
22
31. Partial Refresh Demo - Results
23
Restore View Apply Request Values (8)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Process Validations (11)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Validation for inputText1
•Default value property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Update Model Values (8)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Invoke Application (1)
•OnClick event for id: button1
Render Response (2)
•Rendered property for id: label1
•Label property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•values property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Value property for id: computedField1
•Rendered property for id: computedField2
•Value property for id: computedField2
30 SSJS Calls, saved 9
Only Savings
were here!
32. Partial Refresh Pros and Cons
• Pros
– Reduced control processing in the render response phase
– Smaller response from server
• Means reduced network usage
– Better UI experience
• Rest of the page is still visible while waiting for a response
• Cons
– Controls like computed fields outside refresh area don’t refresh
– Be careful turning this on for a completed XPage (TEST!)
– Can only update one area (one id)
• Workaround from Tim Tripcony on XPages Wiki
24
33. Partial Execution Demo - Results
25
Restore View Apply Request Values (1)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Process Validations (1)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Validation for inputText1
•Default value property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Update Model Values (1)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Invoke Application (1)
•OnClick event for id: button1
Render Response (12)
•Rendered property for id: label1
•Label property for id: label1
•Rendered property for id: inputText1
•Default value property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•values property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Value property for id: computedField1
•Rendered property for id: computedField2
•Value property for id: computedField2
16 SSJS Calls
Saved 13
34. Partial Execution Pros and Cons
• Pros
– Reduced processing in the 3 data-processing phases
• Cons
– Control with onClick event has to be inside the execId area
– Editable values outside of the executed area do not get
submitted/updated (reset to default values)
– Existing XPages need analysis/testing before using this
• Current onclick events might refer to controls where the data
is not submitted
– ExecMode available in 8.5.1
– Have to use source to enter ExecId in 8.5 (9.0 has Designer UI)
26
35. Partial Refresh AND Execution Demo - Results
Restore View Apply Request Values (1)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Process Validations (1)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Validation for inputText1
•Default value property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Update Model Values (1)
•Rendered property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•Rendered property for id: comboBox1
•Rendered property for id: computedField1
•Rendered property for id: computedField2
Invoke Application (1)
•OnClick event for id: button1
Render Response (2)
•Rendered property for id: label1
•Label property for id: label1
•Rendered property for id: inputText1
•Rendered property for id: label2
•Rendered property for id: comboBox1
•values property for id: comboBox1
•values property for id: comboBox1
•Rendered property for id: computedField1
•Value property for id: computedField1
•Rendered property for id: computedField2
•Value property for id: computedField2
6 SSJS Calls,
saved 33
27
36. Using the loaded Property
• Loaded = true
– In component tree
• Loaded = false
– Control is not created
– Can never be rendered
or accessed
– Saves memory too
28
Loaded only computed once in the createView phase
37. Life Cycle Performance Suggestions
• Most properties, like CSS “style” are
only computed in the
RenderResponse phase
• Watch and minimize:
– Rendered property (when dynamic)
• Computed multiple times!
• Use dataContexts or scoped variables
when able
• Use both Partial Refresh (Update)
and Partial Execute when able
29
38. Tools to Test/Debug Performance Issues
• Print statements
– In rendered/visible computations to see how often executed
• print("panel2 evaluating rendered property");
– In the XPages events such as:
• before/afterPageLoad, afterRestoreView,
before/afterRenderResponse
– In the document data source events:
• queryNewDocument, postSaveDocument, etc.
– Or use the Debug Toolbar (don‘t have to view server
console)
• http://www.openntf.org/main.nsf/project.xsp?r=project/
XPage%20Debug%20Toolbar
30
39. More Tools
• Server OS tools to monitor CPU, memory and network
• Browser developer tools
– for watching network transactions, partial updates, response
times
– BROWSER: Firebug, Chrome, etc. developer tools
– XPiNC: FirebugLite from ExtLib
• Java / Javascript Debugging
– Degrades performance but can inspect objects
• Use the Eclipse Java debugger
31
40. XPages Toolbox
• XPages based Application
– Runs on the Domino server or the Notes client
– An NSF needs to be installed on the server/Notes client
– A profiler jar file is added to the JVM directory
– Modify the security policy file
– Notes.ini is modified (all in the documentation!)
• Measures CPU performance and memory allocation
• Available from OpenNTF.org
– Free open source project
– http://www.openntf.org/main.nsf/project.xsp?r=project/XPa
ges%20Toolbox
32
41. XPages Toolbox Functionality
• Measures CPU and Wall time
• Back end Domino object profiling
• Run time monitor (memory)
• Session dumps (XML file)
• Heap dump of the JVM running in the HTTP task
– Or from the Domino console (or from your code)
• tell http xsp heapdump (triggers com.ibm.jvm.Dump.HeapDump())
• tell http xsp javadump (triggers com.ibm.jvm.Dump.JavaDump())
– Analyze the heap dump using the Eclipse memory analyzer (need to also
install the IBM dump tool)
http://www.eclipse.org/mat/
http://www.ibm.com/developerworks/java/jdk/tools/dtfj.html
• Thread Monitoring
33
44. Watch Out for @DbLookup
• @DbLookup about 3-4 times slower than SSJS
– res = @DbLookup(db,"CustomersByNameView",names[i], "phone");
vs.
– doc = vw.getDocumentByKey(names[i], true);
res = doc.getItemValueString("phone");
• Five lookups repeated 100 times
– @DbLookup averaged about 1728ms
– getDocumentByKey averaged 510ms
• Other @Functions not tested
36
45. • Simple Repeat – what could be wrong?
– Configuration Lookups to get other nsf names
– Lookups to get “role” of user
– Opening Notes document to get values
– Computed view value
– Complicated rendered formula in repeat
Case Study 1 - Repeat
37
46. • Add Application Scope variables to store database
names
• Or (better yet) create an ApplicationBean in Java
Case Study 1 – First Step add scoped variable for Config (db names)
38
To retrieve:
47. Improvement – Repeat_Config
39
Xpage Calls Time CPU Time Calls(%)
BE
Time(%)
CPU
Time(%)
Start 3564 1547 1688
Cache Config 2499 733 1016 143% 211% 166%
48. • Add App Scope variable to store user roles
• No more @DbLookup in rendered
– Pulls value from memory - much faster!
Case Study 1 – Next add scoped variable for User Information
40
To retrieve:
49. Improvement – Repeat_User
41
All previous changes are cumulative....
Xpage Calls Time CPU Time Calls(%)
BE
Time(%)
CPU
Time(%)
Start 3564 1547 1688
Cache Config 2499 733 1016 143% 211% 166%
Cache User 1992 265 469 179% 584% 360%
50. • Avoid opening NotesDocument object to get values
not in the view
– Created a new view with missing columns
– Changed reference to use EL for all but two
columns that need to lookup in another DB
Case Study 1 – Next create a new view
42
51. Improvement – Repeat_BetterView
43
All previous changes are cumulative....
Xpage Calls Time CPU Time Calls(%)
BE
Time(%)
CPU
Time(%)
Start 3564 1547 1688
Cache Config 2499 733 1016 143% 211% 166%
Cache User 1992 265 469 179% 584% 360%
Better View 1656 283 375 215% 547% 450%
52. • Avoid doing the @Dblookup to get the sales person
based on the region
• Use a Bean to cache Region/Salesperson data
– HashMap: key is region name, value is salesperson
– Application scope (shared by all users)
Lookup the Sales Person from a Bean
44
53. Improvement – Repeat_CacheRegion
45
All previous changes are cumulative....
Xpage Calls Time CPU Time Calls(%)
BE
Time(%)
CPU
Time(%)
Start 3564 1547 1688
Cache Config 2499 733 1016 143% 211% 166%
Cache User 1992 265 469 179% 584% 360%
Better View 1656 283 375 215% 547% 450%
Cache Region 1614 93 250 221% 1663% 675%
54. • Store Sales Total by Customer in HashMap
– viewScope Managed Bean
• Caches sales total, key is customer name
• Also use ViewNavigator to get totals via
getNextCategory()
– Fast initialization of HashMap
Next Try: Use Java to Cache Sales Lookup
46
SSJS call to Bean
55. Improvement – Repeat_ComputeSalesJava
47
All previous changes are cumulative....
Xpage Calls Time CPU Time Calls(%)
BE
Time(%)
CPU
Time(%)
Start 3564 1547 1688
Cache Config 2499 733 1016 143% 211% 166%
Cache User 1992 265 469 179% 584% 360%
Better View 1656 283 375 215% 547% 450%
Cache Region 1614 93 250 221% 1663% 675%
Compute Sales - Java 816 16 172 437% 9669% 981%
56. • CustomerBean
– passes Collection of customer objects to Repeat
– The scope could be request, view, or application
• CacheBean
– Long lived information
– Config settings (database path and name)
– User profile (manager, sales rep or user)
– Region information (get Sales person for region)
– Application Scope
Do Everything in Java!
48
58. Improvement – Repeat_AllJava
50
Xpage Calls Time CPU Time Calls(%)
BE
Time(%)
CPU
Time(%)
Start 3564 1547 1688
Cache Config 2499 733 1016 143% 211% 166%
Cache User 1992 265 469 179% 584% 360%
Better View 1656 283 375 215% 547% 450%
Cache Region 1614 93 250 221% 1663% 675%
Compute Sales - Java 816 16 172 437% 9669% 981%
All Java (request scope) 401 47 141 889% 3291% 1197%
All Java (view scope) 6 0 109 59400% NA 1549%
59. Performance Improvement for Case Study 1
51
0
500
1000
1500
2000
2500
3000
3500
4000
AxisTitle
Calls Time CPU Time
60. Case Study 2: Partial Refresh and Execution
• Added a lookup to compute sales by region
– Full Update/Exec
– Partial Refresh
– Partial Exec
– Both
52
Xpage Calls Time CPU Time Calls (%)
BE
Time (%)
CPU
Time(%)
Start 1918 1109 1375
Refresh 516 672 781 691% 230% 216%
Exec 1414 610 688 252% 254% 245%
Both 12 31 78 29700% 4990% 2164%
0
500
1000
1500
2000
2500
Start Refresh Exec Both
Calls Time CPU Time
61. Recap
• Think about performance when designing
– JSF Lifecycle
• Avoiding computations in rendered
– Cache whenever possible
• Scoped variables
• Beans
• Measure performance
– Part of your testing processes
– Look for ways to improve
53
62. • TLCC Performance Webinar with Ulrich Krause and
myself from October, 2013
– YouTube and Slides
• Paul Withers blog (each link below is different)
– Part 1, Part 2, Part 3
• Tony McGuckin’s Video - XPages Master class
– 4 videos plus sample applications
• IBM article on JSF (non XPages)
54
Homework Time – Further References
63. Questions????
55
Use the Orange Arrow button to
expand the GoToWebinar panel
Then ask your questions in the
Questions panel!
Remember, we will answer your
questions verbally
64. #XPages
@TLCCLtd
@Teamstudio
@PaulDNUpcoming Events:
Swiss Notes User Group - Oct 28
Social Connections 9, Stuttgart, Germany – Nov. 5 – 6
SUTOL Conference, Prague, CZ – Nov. 11
Connect, Orlando – Jan. 31 to Feb. 3
Question and Answer Time!
56
Teamstudio Questions?
contactus@teamstudio.com
978-712-0924
TLCC Questions?
howardg@tlcc.com paul@tlcc.com
888-241-8522 or 561-953-0095
Howard
Greenberg Courtney
Carter
Keep in mind:
TLCC Fall Sale
IBM Champion Nominations are Open