Skip to content

Assume NativePerformance will be available if the Performance module is loaded #52671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rubennorte
Copy link
Contributor

Summary:
Changelog: [internal]

When setting up the global performance value, we check if the native module exists to decide what version to setup: the legacy "barebones" version or the modern version that's mostly spec compliant.

As we do that check and we shouldn't be requiring the module from anywhere else, it should be safe to always assume the module will be defined if we load the Performance class, so we can avoid checks in all methods.

NOTE: I've kept some checks for a few methods that are still not fully propagated (new methods like reportMark, reportMeasure and getMarkTime).

This improves performance slightly for performance methods:

  • Before
(index) Task name Latency average (ns) Latency median (ns) Throughput average (ops/s) Throughput median (ops/s) Samples
0 'mark (default)' '1803.32 ± 0.71%' '1763.00' '563849 ± 0.01%' '567215' 554908
1 'mark (with custom startTime)' '1762.39 ± 1.67%' '1692.00' '587832 ± 0.01%' '591017' 567414
2 'measure (default)' '1879.47 ± 1.44%' '1813.00' '548962 ± 0.01%' '551572' 532064
3 'measure (with start and end timestamps)' '1916.65 ± 0.84%' '1873.00' '531258 ± 0.01%' '533903' 521743
4 'measure (with mark names)' '2049.84 ± 0.44%' '2013.00' '492799 ± 0.01%' '496771' 487844
5 'clearMarks' '719.87 ± 0.04%' '711.00' '1403602 ± 0.01%' '1406470' 1389136
6 'clearMeasures' '710.04 ± 0.04%' '701.00' '1421610 ± 0.01%' '1426534' 1408373
7 'mark + clearMarks' '2256.56 ± 1.10%' '2143.00' '460721 ± 0.02%' '466636' 443152
8 'measure + clearMeasures (with start and end timestamps)' '2345.44 ± 1.11%' '2244.00' '442395 ± 0.02%' '445633' 426360
9 'measure + clearMeasures (with mark names)' '2349.55 ± 0.61%' '2283.00' '434370 ± 0.02%' '438020' 425613
  • After
(index) Task name Latency average (ns) Latency median (ns) Throughput average (ops/s) Throughput median (ops/s) Samples
0 'mark (default)' '1791.47 ± 1.08%' '1732.00' '573787 ± 0.01%' '577367' 558202
1 'mark (with custom startTime)' '1699.41 ± 1.27%' '1642.00' '605188 ± 0.01%' '609013' 588441
2 'measure (default)' '1820.92 ± 1.39%' '1763.00' '563437 ± 0.01%' '567215' 549173
3 'measure (with start and end timestamps)' '1923.57 ± 1.65%' '1852.00' '537112 ± 0.01%' '539957' 519867
4 'measure (with mark names)' '2036.09 ± 1.05%' '1983.00' '500406 ± 0.01%' '504286' 491139
5 'clearMarks' '657.49 ± 0.07%' '641.00' '1543793 ± 0.01%' '1560062' 1520939
6 'clearMeasures' '669.02 ± 0.09%' '651.00' '1520386 ± 0.01%' '1536098' 1494730
7 'mark + clearMarks' '2213.09 ± 1.53%' '2103.00' '470008 ± 0.02%' '475511' 451858
8 'measure + clearMeasures (with start and end timestamps)' '2353.15 ± 1.27%' '2214.00' '448563 ± 0.02%' '451671' 424962
9 'measure + clearMeasures (with mark names)' '2298.28 ± 0.62%' '2243.00' '441703 ± 0.02%' '445831' 435108

Reviewed By: hoxyq

Differential Revision: D78412931

…facebook#52668)

Summary:

Changelog: [internal]

These methods have been available for months so no need to consider backwards compatibility with older binaries.

Reviewed By: huntie

Differential Revision: D78412932
…is loaded

Summary:
Changelog: [internal]

When setting up the global `performance` value, we check if the native module exists to decide what version to setup: the legacy "barebones" version or the modern version that's mostly spec compliant.

As we do that check and we shouldn't be requiring the module from anywhere else, it should be safe to always assume the module will be defined if we load the `Performance` class, so we can avoid checks in all methods.

NOTE: I've kept some checks for a few methods that are still not fully propagated (new methods like `reportMark`, `reportMeasure` and `getMarkTime`).

This improves performance slightly for `performance` methods:

* Before

| (index) | Task name                                                 | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------- | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'mark (default)'                                          | '1803.32 ± 0.71%'    | '1763.00'           | '563849 ± 0.01%'           | '567215'                  | 554908  |
| 1       | 'mark (with custom startTime)'                            | '1762.39 ± 1.67%'    | '1692.00'           | '587832 ± 0.01%'           | '591017'                  | 567414  |
| 2       | 'measure (default)'                                       | '1879.47 ± 1.44%'    | '1813.00'           | '548962 ± 0.01%'           | '551572'                  | 532064  |
| 3       | 'measure (with start and end timestamps)'                 | '1916.65 ± 0.84%'    | '1873.00'           | '531258 ± 0.01%'           | '533903'                  | 521743  |
| 4       | 'measure (with mark names)'                               | '2049.84 ± 0.44%'    | '2013.00'           | '492799 ± 0.01%'           | '496771'                  | 487844  |
| 5       | 'clearMarks'                                              | '719.87 ± 0.04%'     | '711.00'            | '1403602 ± 0.01%'          | '1406470'                 | 1389136 |
| 6       | 'clearMeasures'                                           | '710.04 ± 0.04%'     | '701.00'            | '1421610 ± 0.01%'          | '1426534'                 | 1408373 |
| 7       | 'mark + clearMarks'                                       | '2256.56 ± 1.10%'    | '2143.00'           | '460721 ± 0.02%'           | '466636'                  | 443152  |
| 8       | 'measure + clearMeasures (with start and end timestamps)' | '2345.44 ± 1.11%'    | '2244.00'           | '442395 ± 0.02%'           | '445633'                  | 426360  |
| 9       | 'measure + clearMeasures (with mark names)'               | '2349.55 ± 0.61%'    | '2283.00'           | '434370 ± 0.02%'           | '438020'                  | 425613  |

* After

| (index) | Task name                                                 | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------- | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'mark (default)'                                          | '1791.47 ± 1.08%'    | '1732.00'           | '573787 ± 0.01%'           | '577367'                  | 558202  |
| 1       | 'mark (with custom startTime)'                            | '1699.41 ± 1.27%'    | '1642.00'           | '605188 ± 0.01%'           | '609013'                  | 588441  |
| 2       | 'measure (default)'                                       | '1820.92 ± 1.39%'    | '1763.00'           | '563437 ± 0.01%'           | '567215'                  | 549173  |
| 3       | 'measure (with start and end timestamps)'                 | '1923.57 ± 1.65%'    | '1852.00'           | '537112 ± 0.01%'           | '539957'                  | 519867  |
| 4       | 'measure (with mark names)'                               | '2036.09 ± 1.05%'    | '1983.00'           | '500406 ± 0.01%'           | '504286'                  | 491139  |
| 5       | 'clearMarks'                                              | '657.49 ± 0.07%'     | '641.00'            | '1543793 ± 0.01%'          | '1560062'                 | 1520939 |
| 6       | 'clearMeasures'                                           | '669.02 ± 0.09%'     | '651.00'            | '1520386 ± 0.01%'          | '1536098'                 | 1494730 |
| 7       | 'mark + clearMarks'                                       | '2213.09 ± 1.53%'    | '2103.00'           | '470008 ± 0.02%'           | '475511'                  | 451858  |
| 8       | 'measure + clearMeasures (with start and end timestamps)' | '2353.15 ± 1.27%'    | '2214.00'           | '448563 ± 0.02%'           | '451671'                  | 424962  |
| 9       | 'measure + clearMeasures (with mark names)'               | '2298.28 ± 0.62%'    | '2243.00'           | '441703 ± 0.02%'           | '445831'                  | 435108  |

Reviewed By: hoxyq

Differential Revision: D78412931
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 17, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78412931

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants