print(xml_document) does not scale with large documents
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- r
- Área
- performance
Línea de trabajo
Start by reproducing the slow, non-interruptible print(cellosaurus_xml) case with the large XML example. Inspect R/xml_nodeset.R around line 73, especially show_nodes and its as.character call, and compare it with the individual-child printing shown in the issue. Done means the agreed print behavior scales appropriately for large XML documents and remains interruptible.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When loading a fairly large XML file (~500MB), if I print() the document it takes a long time, and it is not interruptible.
However printing the children nodes individually is fast.
I believe the reprex below eventually calls show_nodes which calls as.character here, that takes a long time and blocks the interpreter.
https://github.com/r-lib/xml2/blob/ab73051bca962d3cbcf8f4046eb2758be74a489c/R/xml_nodeset.R#L73
library(xml2)
# Download 490 MB:
if (!file.exists("cellosaurus.xml")) download.file("https://ftp.expasy.org/databases/cellosaurus/cellosaurus.xml", "cellosaurus.xml")
# Read XML:
cellosaurus_xml <- xml2::read_xml("cellosaurus.xml")
# My print (a fast version, closer to what I would expect)
cat(format(cellosaurus_xml))
#> <Cellosaurus>
children <- xml2:::xml_children(cellosaurus_xml)
for (child in children) {
cat(format(child), "\n")
xml2:::show_nodes(xml2:::xml_children(child))
}
#> <header>
#> [1] <terminology-name>Cellosaurus</terminology-name>
#> [2] <description>Cellosaurus: a controlled vocabulary of cell lines</descript ...
#> [3] <release version="48.0" updated="2024-01-30" nb-cell-lines="152231" nb-pu ...
#> [4] <terminology-list>\n <terminology name="NCBI-Taxonomy" source="National ...
#> <cell-line-list>
#> [1] <cell-line category="Hybridoma" created="2021-09-23" last-updated="2024- ...
#> [2] <cell-line category="Hybridoma" created="2021-09-23" last-updated="2024- ...
#> [3] <cell-line category="Transformed cell line" created="2012-10-22" last-up ...
#> [4] <cell-line category="Hybridoma" created="2017-08-22" last-updated="2023- ...
#> [5] <cell-line category="Cancer cell line" created="2017-05-15" last-updated ...
#> [6] <cell-line category="Hybridoma" created="2012-06-06" last-updated="2023- ...
#> [7] <cell-line category="Hybridoma" created="2014-07-17" last-updated="2023- ...
#> [8] <cell-line category="Hybridoma" created="2022-12-15" last-updated="2023- ...
#> [9] <cell-line category="Transformed cell line" created="2012-10-22" last-up ...
#> [10] <cell-line category="Hybridoma" created="2013-02-11" last-updated="2023- ...
#> [11] <cell-line category="Cancer cell line" created="2018-05-14" last-updated ...
#> [12] <cell-line category="Finite cell line" created="2012-04-04" last-updated ...
#> [13] <cell-line category="Finite cell line" created="2012-04-04" last-updated ...
#> [14] <cell-line category="Finite cell line" created="2013-11-05" last-updated ...
#> [15] <cell-line category="Finite cell line" created="2012-04-04" last-updated ...
#> [16] <cell-line category="Cancer cell line" created="2012-04-04" last-updated ...
#> [17] <cell-line category="Cancer cell line" created="2012-04-04" last-updated ...
#> [18] <cell-line category="Spontaneously immortalized cell line" created="2019 ...
#> [19] <cell-line category="Transformed cell line" created="2021-12-16" last-up ...
#> [20] <cell-line category="Cancer cell line" created="2024-01-30" last-updated ...
#> ...
#> <publication-list>
#> [1] <publication date="2005" type="article" journal-name="AAPS J." volume="7 ...
#> [2] <publication date="2011" type="article" journal-name="AAPS J." volume="1 ...
#> [3] <publication date="2011" type="article" journal-name="AAPS J." volume="1 ...
#> [4] <publication date="2016" type="article" journal-name="AAPS J." volume="1 ...
#> [5] <publication date="2000" type="article" journal-name="AAPS PharmSci" vol ...
#> [6] <publication date="2004" type="article" journal-name="AAPS PharmSci" vol ...
#> [7] <publication date="2008" type="article" journal-name="ACS Chem. Biol." v ...
#> [8] <publication date="2014" type="article" journal-name="ACS Chem. Biol." v ...
#> [9] <publication date="2018" type="article" journal-name="ACS Infect. Dis." ...
#> [10] <publication date="2023" type="article" journal-name="ACS Materials Au" ...
#> [11] <publication date="2022" type="article" journal-name="ACS Omega" volume= ...
#> [12] <publication date="2017" type="article" journal-name="ACS Synth. Biol." ...
#> [13] <publication date="2001" type="article" journal-name="Acta Astronaut." v ...
#> [14] <publication date="2013" type="article" journal-name="Acta Astronaut." v ...
#> [15] <publication date="2005" type="article" journal-name="Acta Biochim. Biop ...
#> [16] <publication date="2004" type="article" journal-name="Acta Biochim. Pol. ...
#> [17] <publication date="1988" type="article" journal-name="Acta Biol. Hung." ...
#> [18] <publication date="2015" type="article" journal-name="Acta Biol. Hung." ...
#> [19] <publication date="2016" type="article" journal-name="Acta Crystallogr. ...
#> [20] <publication date="2001" type="article" journal-name="Acta Cytol." volum ...
#> ...
#> <copyright>
# This is extremely slow, and non-interruptible:
# print(cellosaurus_xml)
Created on 2024-03-12 with reprex v2.1.0
Is this expected? Or should the print() function scale better with larger XML files?
- Lenguaje dominante
- R
- Estrellas
- 227
- Forks
- 86
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de r-lib/xml2
-
Export libxml2_version()Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 67/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Optimize xml_path() and xml_find_all() for large node setsPosiblemente ocupada @astruebi la tomó hace 182 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
Todos los issues de r-lib/xml2
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Bioconductor/BiocParallel#289 ·
-
automation
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
waldronlab/BugSigDBcuration#2224 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
merliseclyde/BAS#118 ·