-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: Add PerformanceApi to CozyClient #1574
Conversation
b3815e2
to
c41c4a6
Compare
c41c4a6
to
2ecef7a
Compare
We want to be able to measure CozyClient's performances in web apps but also in mobile apps To make this possible we introduce the PerformanceAPI This API should be injected in CozyClient's constructor, then CozyClient will be able to use it to measure performances This API is meant to wrap platforms' native APIs. On web browsers we wrap the well known Performance API, but on mobile app we may want to use the implementation from react-native-performances The CozyClient provides the web implementation, but other implementation should be implemented by consuming apps and then injected in the CozyClient's constructor If no implementation is injected in the constructor, then the `defaultPerformance` implementation is used. This implementation does nothing, so there is no impact on web apps by default Related link: https://developer.mozilla.org/en-US/docs/Web/API/Performance
95729c0
to
13bb965
Compare
Some remarks, but excellent work overall with great documentation 👏 |
markName: markName, | ||
measureName: `${markName} query or mutate`, | ||
category: 'CozyClientStore' | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are for actions that are not query nor mutate, so I think the measureName
is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here
I renamed it ${markName} no query nor mutate action
markName: markName, | ||
measureName: `${markName} default`, | ||
category: 'CozyClientStore' | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the correct measureName should be ${markName} queries
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here
I renamed it ${markName} queries
but I'm wondering if this is correct too? Those can be queries or mutation? Does "queries" implies this can be also mutation?
const response = action.response | ||
// Data can be null when we get a 404 not found | ||
// see Collection.get() | ||
// but we still need to update the fetchStatus. | ||
if (!response.data) { | ||
performanceApi.measure({ | ||
markName: markName, | ||
measureName: `${markName} with data`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${markName} with no data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also renamed the next one (line 209) with object
as there was also a !
operator I missed
markName: markName, | ||
measureName: `${markName} default`, | ||
category: 'CozyClientStore' | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it is really needed to have different measures here, i.e. if there is no data, if there is an array or not, etc.
I think only one measure is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my initial tests, this was to have an idea of the frequency of each return path. Not sure if this is still relevant.
docs/performances.md
Outdated
|
||
On initial implementation, we chose to measure some parts of the code that we estimated useful and with potential high impact on performances (i.e. queries, store management, pouch management etc.) | ||
|
||
We excpect to need more measurements in the future but we need to care to keep the balance beetween having useful measurements and to not visualy overload the measurement graphs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/excpect/expect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here
docs/performances.md
Outdated
|
||
We excpect to need more measurements in the future but we need to care to keep the balance beetween having useful measurements and to not visualy overload the measurement graphs | ||
|
||
The API is meant to be simple to use so measurements can be quickly added temporarily in development environements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/added temporarily/temporarily added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/environements/environments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here
docs/performances.md
Outdated
The API interface is described in the JSDoc | ||
|
||
Example of custom implementations: | ||
- Flagship App: [](TODO ADD LINK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we think of this? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure, the task is on the PR description's todo list, so I should not forget to do it (I won't merge this without adding the link).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/performances.md
Outdated
|
||
The consuming app is then responsible to inject an implementation or keep the default one that doesn't do any profiling, regarding if the app is built for development environments or for production | ||
|
||
PerformancesAPI seems to have an impact on performances light enough to be kept on production. However, we suggest to disable them in that environement if possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/environement/environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
light enough to be kept on production
Are we sure of this? I guess it's ok for a single measure, but I would assume a significative impact overall, since there can be a lot of measures during an app data lifecycle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that, because the API can measure durations as small as a few μs, on high level methods this should not be perceptible. But this may be different on some API for other platforms. Also I did not find any info about it so this is just a guess.
But that's why I suggested to disable it.
@@ -0,0 +1,169 @@ | |||
# Performances analysis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc is really great!
One small remark is that you seem to really dislike ending dots at the end of sentences 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an old habit from one of my first jobs where we avoided adding hard stops at the end of paragraphs on markdown documents.
But I almost have no memories of why this was on guidelines 🙃 (maybe it was something like the rendered that automatically added dot when double \n after a paragraph, but I'm not sure)
I have no opinion on this. I will add them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion here is to respect grammar as best as we can 😄
But it's true that we took the habit of missing the final dot in general. Dot.
13bb965
to
ee1b801
Compare
ee1b801
to
fabe643
Compare
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
fabe643
to
2d7973e
Compare
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
`cozy-client` and `cozy-pouch-link` has been upgraded to `51.7.0` in order to retrieve the new Performance API implementation Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
`cozy-client` and `cozy-pouch-link` has been upgraded to `51.7.0` in order to retrieve the new Performance API implementation Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
`cozy-client` and `cozy-pouch-link` has been upgraded to `51.7.0` in order to retrieve the new Performance API implementation Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
`cozy-client` and `cozy-pouch-link` has been upgraded to `51.7.0` in order to retrieve the new Performance API implementation Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
`cozy-client` and `cozy-pouch-link` has been upgraded to `51.7.0` in order to retrieve the new Performance API implementation Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
`cozy-client` and `cozy-pouch-link` has been upgraded to `51.7.0` in order to retrieve the new Performance API implementation Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
As we encounter some performances issues in the app startup, we want to add some metrics to understand where time is consumed All measurement are made through the `measure.ts` helper that wraps the `react-native-performance` library and fit the incoming CozyClient performance API Related PR: cozy/cozy-client#1574
`cozy-client` and `cozy-pouch-link` has been upgraded to `51.7.0` in order to retrieve the new Performance API implementation Related PR: cozy/cozy-client#1574
In cozy/cozy-client#1574 we implemented a new CozyClient API that allow to enable CozyClient's internal performances measurements This PR configure CozyClient and related links with a react-native compatible Performance API This will allow us to analyse performances issues on CozyClient when used in the Flagship App environment
We want to be able to measure CozyClient's performances in web apps but also in mobile apps
To make this possible we introduce the PerformancesAPI (full documentation available in the PR)
This API should be injected in CozyClient's constructor, then CozyClient will be able to use it to measure performances
This API is meant to wrap platforms' native APIs. On web browsers we wrap the well known Performance API, but on mobile app we may want to use the implementation from react-native-performances
The CozyClient provides the web implementation, but other implementation should be implemented by consuming apps and then injected in the CozyClient's constructor
If no implementation is injected in the constructor, then the
defaultPerformance
implementation is used. This implementation does nothing, so there is no impact on web apps by defaultHere is the result when using the browser's Performance devtools :
Related link:
https://developer.mozilla.org/en-US/docs/Web/API/Performance
TODO:
Other platforms
section of the documentation