ampproject / ampproject/amphtml

We might not need to cache parsed URLs at all

Open
#31,997 3 comments 2 reactions 0 assignees View on GitHub
Stale Type: Feature Request WG: performance
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

#31594 removes the parsed URL cache on `module` builds. This is because `URL()` without cache performs similarly to using `` with a result cache.

The cache implementation takes about `~250B` of a compressed build.

This explores whether we require a cache for `` as shipped previously on `nomodule` builds.

## Hit rate on real documents

Documents mostly hover on the 65%-75% range.

[**Methodology**](https://gist.github.com/alanorozco/3c6e65546cc0441c2b0e4771f7decc29) / [**Results**](https://docs.google.com/spreadsheets/d/1p8MaV660NS2SlN5xgY0mlGqqLUZfxNV7Jh7ntiWt8sA/edit?resourcekey=0-4EJx844chhDQCxqphjjKkw#gid=0)

![image](https://user-images.githubusercontent.com/254946/104755383-362d5a80-570f-11eb-8217-170ad6eed00d.png)

## Cache performance at different hit rates

[**Benchmark**](https://jsbench.me/06kis3hhcd/1) / [**Results**](https://docs.google.com/spreadsheets/d/1Bv952eeBvjmQNVzSn39SQHp1EYJNA985P53x_DcUoR4/edit?resourcekey=0-6b60xJzTOtUJqXxVVBSFkQ#gid=0)

- **The cache performs better only for hit rates over around `95%`**. On Firefox it barely performs better in this range.
- The cache performs worse in most cases (see "dip" in the middle.)

### Chrome

![image](https://user-images.githubusercontent.com/254946/104754426-0c276880-570e-11eb-84fa-68363b7b3d56.png)

### Safari

![image](https://user-images.githubusercontent.com/254946/104754499-25c8b000-570e-11eb-91d3-3f66128906d4.png)

### Firefox

![image](https://user-images.githubusercontent.com/254946/104754595-409b2480-570e-11eb-9783-25a73f85f895.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.