Page MenuHomePhabricator

In "qsprintf()", don't render the unmasked query string unless it will differ from the masked string
AbandonedPublic

Authored by epriestley on Mar 5 2019, 10:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 1:27 AM
Unknown Object (File)
Sat, Nov 16, 2:46 AM
Unknown Object (File)
Tue, Nov 12, 1:48 PM
Unknown Object (File)
Thu, Nov 7, 6:50 PM
Unknown Object (File)
Thu, Oct 31, 10:59 AM
Unknown Object (File)
Thu, Oct 31, 3:25 AM
Unknown Object (File)
Sat, Oct 26, 5:46 PM
Unknown Object (File)
Oct 14 2024, 9:35 PM
Subscribers
None

Details

Reviewers
amckinley
Summary

See D20249. Previously, see D20067. Currently, we render each query twice: one "masked" version (with passwords replaced with "****") and one "unmasked" version. In theory, we can improve performance here by only rendering once about 99% of the time, since very few queries have passwords/keys/session tokens / etc in them.

In practice, it's a bit tricky to figure out if the masked and unmasked versions will differ or not. This appears to be the most reasonable way to do it quickly. I set things up so that if we get it wrong we fail relatively safe (executing the masked query, which will have a syntax error and fail, instead of rendering the unmasked query).

Test Plan
  • Locally, XHProf shows 20ms -> 12ms in PhutilQueryString::__construct() on a random revision page.
  • Call count for xsprintf_query() falls from ~3,800 to ~2,000.

I'll try to gather a bit more evidence for this since I'm not totally confident in XHProf for this kind of micro-optimization, as it tends to overestimate the cost of function calls.

Diff Detail

Repository
rPHU libphutil
Branch
cache2
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 22190
Build 30333: Run Core Tests
Build 30332: arc lint + arc unit

Event Timeline

I can't get anything remotely convincing out of ab. This or some similar change might still be a good idea, but I'll wait until I have a clearer case for it.