HelloZeroNet / HelloZeroNet/ZeroNet

Slow start due to quadratic time algorithms

Abierto
#2,770 1 comentario 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
18.8k
Forks
2.3k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Step 1: Please describe your environment

* ZeroNet version: v0.7.2 (rev4555)
* Operating system: N/A
* Web browser: N/A
* Tor status: N/A
* Opened port: N/A
* Special configuration: N/A

### Step 2: Describe the problem:

ZeroNet takes about an hour to start with a few thousand sites downloaded.

The logs say:

```
[13:03:17] SiteManager Added new site: [address]
[13:03:17] Site:1A28C5..E1dw ContentDb init: 0.000s, found files: 0, sites: 8963
[13:03:17] Site:1A28C5..E1dw ContentDb not initialized, load files from filesystem...
[13:03:17] Site:1A28C5..E1dw Content.json not exist: ./data/[address]/content.json
[13:03:17] RateLimit Added to queue (2.75s left): Save sites.json
[13:03:17] SiteManager Updated merger sites in 0.601s
```
(repeat a few thousand times)

The 'Updated merger sites' seems to be the culprit. It's from `SiteManagerPlugin.updateMergerSites`, which scans all the downloaded sites, and is invoked every time a site is initialized. That takes quadratic time.

#### Steps to reproduce:

1. Create/download lots of sites
2. ???
3. PROFIT

#### Observed Results:

Quadratic time intiailization.

#### Expected Results:

Linear (ideally) time initialization.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Start at SiteManagerPlugin.updateMergerSites and trace where it is invoked during site initialization. Reproduce startup with a large collection of downloaded sites while reviewing the repeated “Updated merger sites” timings. Done means initialization no longer rescans all sites quadratically and startup time scales linearly or substantially better.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
backend, performance
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.