Partial-state-saving and component-tree-walk performance improvements#5778
Merged
Conversation
…pressed doPostAddProcessing/doPreRemoveProcessing ran the full publishAfterViewEvents/disconnectFromView walk even when FacesContext.isProcessingEvents() is false (e.g. during a partial-state-saving restore or view-metadata build). While suppressed, Application.publishEvent is a no-op, so that walk does nothing but pay its per-node cost -- pushing/popping the EL stack and re-checking child/facet counts at every node. Honor isProcessingEvents(): when it is false, take a lean updateInView walk that only maintains the in-view flag (and clears compositeParent on removal) -- the publishing walks' sole non-event side effects -- via a plain index loop, avoiding the getFacetsAndChildren() iterator allocation. Behaviour is unchanged: no event would fire while suppressed anyway. Mirrors MyFaces' _updateInView fast path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
addParentId allocated a fresh StringBuilder per component to build "parentId:childId"; in a deep NamingContainer tree that is one allocation per node per client-id resolution. Reuse a FacesContext-scoped StringBuilder instead (the parent id is already resolved to a String before this runs, and the builder is filled and toString()'d in one uninterrupted step, so the shared instance is never re-entered). Mirrors MyFaces' SharedStringBuilder. Cuts the per-component StringBuilder/char[] allocation in client-id building; no behaviour change (verified: component unit tests + a 3000-postback composite-heavy bench). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… delta FaceletPartialStateManagementStrategy.restoreView always ran a full visitTree over every component to apply saved per-component state, even for static or low-delta views whose saved state map carries nothing to restore. The traversal still paid getClientId + state lookup + EL push/pop at every node for no effect. Short-circuit it: when there are no saved dynamic actions and the state map holds no per-component delta (or only the view root's own), restore the view root in isolation and skip the traversal. Any component whose state actually changed carries a non-null delta that forces the full walk, so this is behaviour-neutral. Mirrors MyFaces' restoreViewRootOnlyFromMap. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ial state saving
A composite component's declared attribute expressions (e.g. cc:attribute value="#{...}") are re-applied from the Facelet on every (re)build via CompositeExpressionMetadata.applyMetadata -> setValueExpression. On a postback rebuild the tree is already initial-state-marked and IS_BUILDING_INITIAL_STATE is not set, so each expression was recorded as a per-component state delta -- one StateHolderSaver per composite, saved and restored on every postback even though buildView reconstructs it identically. The initial GET stores it as initial state, so the redundant delta only appears from the first postback on and then persists.
This is full-state-saving-era behaviour: under FSS the tree is restored purely from serialized state, so the expression must be saved; under PSS buildView re-derives it and saving it is pure redundancy. Regular components avoid this because their attributes are re-applied only when new to the tree; composites re-apply unconditionally.
Under partial state saving, write the composite attribute expression as initial state (clear/set/mark) so it stays out of the saved delta; guarded on PSS, since under FSS the component is never initial-state-marked and the branch is a no-op. On composite-heavy (500 composites) this drops 500 per-postback deltas, cutting RESTORE_VIEW and RENDER_RESPONSE (which runs saveView) ~18% each on Tomcat. All impl unit tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
initial-state walks markInitialState and markInitialStateIfNotMarked walk the whole component tree after every (re)build, iterating each node via getFacetsAndChildren() -- which allocates a Collections.unmodifiable view plus its iterator at every non-leaf node, purely for an immutable-iteration contract these internal walks don't need. Replace with direct index loops over getChildren() and getFacets().values(), matching the pattern the lifecycle process* walks and updateInView already use. markInitialStateIfNotMarked additionally did a reflective getAttributes().containsKey(DYNAMIC_COMPONENT) at every node to leave dynamically added components unmarked. When the view carries no dynamic actions -- the common case -- no component bears that marker, so thread the dynamic-action presence (known after reapplyDynamicActions ran) down the walk and skip the probe entirely then. Behaviour-neutral: both walks mark exactly the same components as before (impl unit tests pass). This is allocation/CPU hygiene, not a measurable speedup -- flat on the composite-heavy latency bench, where the per-node savings sit below the dominant state-helper and render costs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
BalusC
added a commit
that referenced
this pull request
Jun 8, 2026
BalusC
added a commit
that referenced
this pull request
Jun 8, 2026
pzygielo
pushed a commit
to pzygielo/mojarra
that referenced
this pull request
Jun 8, 2026
Omits eclipse-ee4j#5777's Cache get()-probe commit: 4.0's Cache.get() already probes with get() before putIfAbsent (it never switched to computeIfAbsent), so that change is a no-op on 4.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #5753 — partial-state-saving and component-tree-walk performance, all behaviour-neutral (impl unit tests + TCK pass):
cc.attrsexpressions as per-component state deltas under PSS —buildViewre-derives them on every postback. ~18% off both RESTORE_VIEW and RENDER_RESPONSE on composite-heavy views.restoreViewRootOnlyFromMap.publishEventis a no-op there anyway.getFacetsAndChildren()iterators, and skip the per-node dynamic-marker probe when the view has no dynamic actions.StringBuilderfor client-id construction.🤖 Generated with Claude Code