Why this should be an RC target

file_uri_scheme has been deprecated in D8, the rtbc patch 11 cleans up the deprecated calls and replaces them with the correct calls to use the new service class uriScheme()

Function usually doesn't run on a normal page load.
Cache flush:

file_stream_wrapper_uri_normalize()
Before:
Total Self: 151ms
Total Cumulative: 343ms
Calls: 21,872

After:
Total Self: 163ms
Total Cumulative: 193ms
Calls: 21,872

Total savings ~150ms.

Comments

mikeytown2’s picture

Status: Active » Needs review
Issue tags: +Performance
StatusFileSize
new532 bytes
marcingy’s picture

Version: 7.x-dev » 8.x-dev

Features need to go against d8

brianV’s picture

Status: Needs review » Needs work

Currently, 30 separate functions call file_uri_scheme(). For consistency's sake, I suspect we would need to inline *all* instances of this field rather than just one. I'm not sure that makes sense.

mikeytown2’s picture

I'll evaluate inlining the code in other places. But this is for performance reasons, not to get rid of the file_uri_scheme function. It's just that on a cache clear file_stream_wrapper_uri_normalize() gets called 20k+ times, thus inlining the code will improve performance. I'm not sure file_uri_scheme gets called 20k+ times in the other functions that call it.

Status: Needs review » Needs work
joseph.olstad’s picture

Version: 8.0.x-dev » 7.x-dev
Issue summary: View changes
Status: Needs work » Needs review

oops, triggered testbot on 8.x by accident. Meant to retest 7.x

then set issue to 8.x after test

joseph.olstad’s picture

Version: 7.x-dev » 8.0.x-dev
Status: Needs review » Needs work

Patch still passes 7.x dev, back to 8.0.x dev

joseph.olstad’s picture

Status: Needs work » Needs review
StatusFileSize
new2.3 KB

I'm feeling lucky.

joseph.olstad’s picture

function file_uri_scheme is deprecated in 8.x

Someone made a wrapper that calls \Drupal::service('file_system')->uriScheme instead

here's a patch to replace file_uri_scheme

joelpittet’s picture

Issue tags: +rc target triage

Since there is no API change here, it looks like just clean-up (if it passes testbot), I'm adding to the RC target triage.

joseph.olstad’s picture

ah ok, just looking over this, it looks like the inline file_uri_scheme is faster than the actual function call despite the fact that the code inside the function is exactly the same.

Looks like the reported performance gains comparably due to one less copy of the parameter going into the function. The gains are made by avoiding the parameter copy. This makes sense when having to process hundreds, or more likely thousands or tens of thousands of file uri variables typical of what we see in the files folder.

However in 8.x the file_url_schema function is supposed to be deprecated but has not yet been removed.

joelpittet’s picture

Category: Feature request » Task
Issue tags: +Needs issue summary update

This doesn't look like a feature, it looks like clean-up to me. May need a title and issue summary refactoring for what you are doing now.

joseph.olstad’s picture

Ok sounds good *EDIT*, maybe just create a new issue for the cleanup and set it as a related issue to this one, I was more focused on the performance issue for D7 just doing D8 work to push the issue along.
*EDIT*

xjm’s picture

Status: Needs review » Needs work

Thanks for tagging this for rc target triage! If you want committers to consider it for inclusion in RC, add a statement to the issue summary of why we need to make this change during RC, including what happens if we do not make the change and what any disruptions from it are. You can add a section <h3>Why this should be an RC target</h3> to the summary.

joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Issue summary: View changes
joseph.olstad’s picture

Status: Needs work » Reviewed & tested by the community
xjm’s picture

Thanks @joseph.olstad!

xjm’s picture

This seems like a good rc target to me based on that summary. I pinged other committers for a second opinion.

effulgentsia’s picture

Title: inline file_uri_scheme() in file_stream_wrapper_uri_normalize() » Inline file_uri_scheme() in file_stream_wrapper_uri_normalize() and other file.inc functions
Priority: Normal » Major
Issue tags: -rc target triage +rc eligible

In my opinion, removing calls to @deprecated wrappers qualifies as a non-disruptive change to comply with coding standards, so tagging "rc eligible" per https://www.drupal.org/core/d8-allowed-changes#rc.

#2470679: [meta] Identify necessary performance optimizations for common profiling scenarios lists "Over ~100ms or more savings with cold caches and would have to be deferred to a minor version" as a condition that could warrant an issue being Critical. This one wouldn't need to be deferred to a minor version, so not raising this to Critical, but I do think that kind of performance savings justifies raising it to Major.

xjm’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -rc eligible +rc target

In my opinion, removing calls to @deprecated wrappers qualifies as a non-disruptive change to comply with coding standards, so tagging "rc eligible"

Removing deprecated code is not really a coding standards change per se (IMO), because it's actually changing the behavior of the code (even if it's just removing one function call from the stack). So swapping this to RC target (for the performance improvements).

Note that there are 39 uses/references to the procedural function still remaining after the patch which can be done in 8.1.x unless there are similar performance improvements. The patch removes 5.

Committed and pushed to 8.0.x. Thanks for the fix and the profiling!

  • xjm committed 8770d0c on 8.0.x
    Issue #1443342 by joseph.olstad, mikeytown2, xjm, joelpittet, brianV,...
ndobromirov’s picture

Version: 8.0.x-dev » 7.x-dev
Status: Fixed » Needs review
Issue tags: -Performance, -rc target

Hi as this is already committed to D8, assigning back to D7 for re-test.

Status: Needs review » Needs work

  • xjm committed 8770d0c on 8.1.x
    Issue #1443342 by joseph.olstad, mikeytown2, xjm, joelpittet, brianV,...

  • xjm committed 8770d0c on 8.3.x
    Issue #1443342 by joseph.olstad, mikeytown2, xjm, joelpittet, brianV,...

  • xjm committed 8770d0c on 8.3.x
    Issue #1443342 by joseph.olstad, mikeytown2, xjm, joelpittet, brianV,...
joseph.olstad’s picture

Status: Needs work » Needs review

Triggering test bot for D7. The D8 patch was already committed.

joseph.olstad’s picture

Same patch as #1 @mikeytown , just re-uploading it as the testbot was updated after the first patch was uploaded so probably needs to be re-triggered this way.

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

Testbot success, set to rtbc and retest will be triggered again

stefan.r’s picture

Assigned: Unassigned » fabianx
Issue tags: +Performance

This seems to be a nice performance improvement -- maybe let's clarify the comment a bit?

Assigning to Fabianx for final review and commit

stefan.r’s picture

Assigned: fabianx » Unassigned
Issue tags: +Dublin2016, +Novice

Sitting at Dublin next to Fabian -- he reviewed and this is fine. Let's just clarify the comment to: "Inline file_uri_scheme() function call for performance reasons"

LauraRocks’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new571 bytes

I'm doing my first patch in Drupalcon Dublin with stefan.r

mac_weber’s picture

Seems the the easy patch asked by @stefan.r on #37 is done correctly.

Congrats @LauraRocks for your first patch ;)

stefan.r credited Fabianx.

stefan.r’s picture

Adding credit

stefan.r’s picture

Status: Needs review » Reviewed & tested by the community

RTBC!

webchick’s picture

  • webchick committed 5a6500d on 7.x
    Issue #1443342 by joseph.olstad, mikeytown2, LauraRocks, xjm, stefan.r,...
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed LIVE at DrupalCon Double-N! [sic] WOOOOOOOO!!!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.