Skip to content

Performance improvements#27

Merged
const-cloudinary merged 1 commit intomainfrom
fix/url-build-hot-path-perf
Apr 26, 2026
Merged

Performance improvements#27
const-cloudinary merged 1 commit intomainfrom
fix/url-build-hot-path-perf

Conversation

@const-cloudinary
Copy link
Copy Markdown
Member

@const-cloudinary const-cloudinary commented Apr 26, 2026

Memoize hot lookups and tighten array helpers used during transformation URL building:

  • StringUtils: cache snakeCaseToCamelCase / camelCaseToSnakeCase results keyed by input (and separator when non-default). Inputs are bounded by SDK property/config names, so the caches saturate immediately.
  • ClassUtils: cache the unfiltered ReflectionClass::getConstants() result per class name. Exclusions are applied after the cache lookup so the cache is not polluted by per-call filters.
  • ArrayUtils: replace array_values()-based isAssoc with array_is_list(); add fast paths in safeFilterFunc for null and string; refactor safeImplode into a single foreach that only touches float values.

These changes complement the cloudinary_php Configuration clone fast-path and together drop URL build cost from ~361 µs/op to ~28 µs/op on the profiling workload, with no measurable memory growth (caches saturate at ~7 KB total and never grow with workload).

Brief Summary of Changes

What does this PR address?

  • GitHub issue (Add reference - #XX)
  • Refactoring
  • New feature
  • Bug fix
  • Adds more tests

Are tests included?

  • Yes
  • No

Reviewer, please note:

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I ran the full test suite before pushing the changes and all the tests pass.

Memoize hot lookups and tighten array helpers used during transformation
URL building:

- StringUtils: cache snakeCaseToCamelCase / camelCaseToSnakeCase results
  keyed by input (and separator when non-default). Inputs are bounded by
  SDK property/config names, so the caches saturate immediately.
- ClassUtils: cache the unfiltered ReflectionClass::getConstants() result
  per class name. Exclusions are applied after the cache lookup so the
  cache is not polluted by per-call filters.
- ArrayUtils: replace array_values()-based isAssoc with array_is_list();
  add fast paths in safeFilterFunc for null and string; refactor
  safeImplode into a single foreach that only touches float values.

These changes complement the cloudinary_php Configuration clone fast-path
and together drop URL build cost from ~361 µs/op to ~28 µs/op on the
profiling workload, with no measurable memory growth (caches saturate at
~7 KB total and never grow with workload).
@const-cloudinary const-cloudinary merged commit 564e06d into main Apr 26, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant