react / react/react

Custom React-specific metadata format

Ouverte
#22,540 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Component: Developer Tools Size: Large Type: Discussion
Langage dominant
JavaScript
Étoiles
251k
Forks
51.4k
Merge moyen
2 j 4 h
PR mergées (30 j)
53

Description

The recent DevTools "named hooks" feature has been heavily optimized since its initial launch. There are some additional optimizations that we could consider (see the first comment below) but I believe the single biggest remaining bottleneck is downloading and parsing of large source map files.

Using Facebook as a case study, over 65% of the time spent parsing hook names is downloading the source-map files:
image

A significant portion of this time is spent on the generating the source map on the server:
image

Perhaps this could be optimized further, but at some point- we'll still have to download and parse a potentially large file.

Can we avoid relying on the source map entirely?

We aren't using source maps in the typical way. (We aren't displaying the original source code.) So the majority of the data contained in the source-map is useless to us. We've experimented with extending the source map so that we didn't have to parse the original code, but the biggest bottleneck (based on testing) is actually generating and downloading the source-map so this only helps a little.

What if we pre-computed hooks metadata (during compilation) and wrote it to a separate file that gets bundled along like a source map. We could generate this metadata for the compiled code, rather than the source code, so we wouldn't need to map anything at runtime. I don't have exact figures on how much faster this would be, but I estimate it would reduce the source-map file size by an order of magnitude which could have a pretty large impact on the overall performance.

If this custom metadata file is successful, we could also store some additional (lightweight) information in it such as component display names.

Adding additional metadata to this file/format should be done in a backwards-compatible way if at all possible. Still, the metadata format should be versioned in the event that a backwards breaking change occurred.

What if this metadata was unavailable?

This would be entirely opt-in. DevTools would fall back to loading and parsing the complete source-map if this custom metadata was unavailable.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par la fonctionnalité named hooks dans le changelog de React DevTools et par la discussion sur l’extension source-map dans issue #21782. Suivez la façon dont DevTools charge et analyse actuellement les source maps ; le travail sera considéré comme terminé lorsqu’il existera un format de métadonnées personnalisé, versionné et opt-in, avec une gestion rétrocompatible et un fallback source-map complet lorsque les métadonnées ne sont pas disponibles.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, react
Domaine
devtools, performance
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.