Optimize user_view('compact') in template_preprocess_node()

Created on 28 November 2012, almost 13 years ago
Updated 3 September 2025, about 1 month ago

template_preprocess_node() does :

$variables['user_picture'] = user_view($node->account, 'compact');

(was introduced with #1292470: Convert user pictures to Image Field β†’ , that was a theme('user_picture') before that)

So on a listing page displayed with entity_view_multiple(), that's 10 independent entity_view() (sometimes on the same user), that all add up. From my benchmarks in #1852966: Rework entity display settings around EntityDisplay config entity β†’ , that's something like a -4% perf hit (I benchmarked the patch over there, though not HEAD)

We could probably mitigate a large part of this if those isolated user_view() calls could be grouped in one user_view_multiple().

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

user.module

Created by

πŸ‡«πŸ‡·France yched

Live updates comments and jobs are added and updated live.
  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • πŸ‡¬πŸ‡§United Kingdom catch

    This is still a problem.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    I'm not so sure. Render caching is still broken for view multiple, especially if prepared and split up like this, then I don't see the benefit. About the only thing I can see a benefit would be to load all users together if multiple comments are rendered.

  • πŸ‡¬πŸ‡§United Kingdom catch

    I didn't realise that both the node and comment user picture rendering is behind a setting - although I think themes have to individually implement that setting and the UI for it?. That might mean ✨ [META] Expose Title and other base fields in Manage Display Active covers the rest here. Back to needs more info for now.

    Agreed that trying to multiple render the users is no longer going to be useful with render caching.

Production build 0.71.5 2024