ATFutures / geobench

A place to put data (in the releases) and code (in any language) to test performance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Benchmark python code for reading-in ac.geoson

Robinlovelace opened this issue · comments

As discussed with @cmcaine. I think @darribas will be interested also!

This sounds interesting! More info or details I can check?

Sure. The idea is to benchmark different ways of reading-in and eventually doing other things with a range of datasets. Just trying with Python (see below). What module would you recommend for fast geographic vector data I/O?

Comments/suggestions/PRs welcome to compare R with Python. By the looks of it rasterio is way faster than raster in the raster would so wondering how things stack-up for vector data operations.

peek 2018-09-24 21-45

Update: we have a result. Fiona seems to be faster than rgdal but slower than sf according to my benchmark. See the README for results.

Heads-up @darribas, let us know if you know of a quicker way.

We could use a standard environment for the comparison, for example the gds_env, which includes both the R and Python stack. For reading vector data in Python, I'd recommend geopandas, which uses fiona under the hood but it's a lot higher-level and more widespread.

I think largely the same?

screen shot 2018-09-25 at 16 51 51

Agreed, and many thanks for reproducing the benchmark. Note: I ran that previous benchmark using a Python2 version of the pkg. Will update with a Python 3 version now (been looking at this: https://rstudio.github.io/reticulate/articles/versions.html ). If you've any other optimisations to suggest let me know. Look forward to seeing the updated result from my computer (results will likely vary depending on hardware):

system("lscpu", intern = T)
#>  [1] "Architecture:        x86_64"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
#>  [2] "CPU op-mode(s):      32-bit, 64-bit"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
#>  [3] "Byte Order:          Little Endian"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
#>  [4] "CPU(s):              4"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#>  [5] "On-line CPU(s) list: 0-3"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
#>  [6] "Thread(s) per core:  2"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#>  [7] "Core(s) per socket:  2"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#>  [8] "Socket(s):           1"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#>  [9] "NUMA node(s):        1"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#> [10] "Vendor ID:           GenuineIntel"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
#> [11] "CPU family:          6"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#> [12] "Model:               142"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
#> [13] "Model name:          Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
#> [14] "Stepping:            9"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#> [15] "CPU MHz:             3483.138"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
#> [16] "CPU max MHz:         3500.0000"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
#> [17] "CPU min MHz:         400.0000"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
#> [18] "BogoMIPS:            5808.00"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
#> [19] "Virtualisation:      VT-x"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
#> [20] "L1d cache:           32K"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
#> [21] "L1i cache:           32K"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
#> [22] "L2 cache:            256K"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
#> [23] "L3 cache:            4096K"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
#> [24] "NUMA node0 CPU(s):   0-3"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
#> [25] "Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp"

Created on 2018-09-25 by the reprex package (v0.2.0).

Latest benchmark uses 100k instead of 10k points so the results are more stable. I get ~4s with sf vs ~6s with geopandas so I think switching to Python3 definitely reduced the gap. May be different on different set-ups, interested to hear if so.

Update @darribas in the just-push commit python comes out on top. It seems to be quite variable but agree there's very little difference (if any) now I've switched to Python 3.

I would expect the reading/writing to be largely similar as it's all OGR/GDAL under the hood in both cases. Although there is overhead to convert into R/Python data structures. Would be curious to see... I think if you build a R notebook with what you'd like to test, it wouldn't be hard to replicate in python and then run it on the Docker container, for example.

Would be interested to see if you get similar timings in your r notebook environment for sure. Yes they both use GDAL under the hood but that doesn't mean it's optimised. The geojsonsf R package, for example, seems to use a C++ backend that's faster than GDAL. And as the rgdal/sf comparison shows implementation can lead to big overheads. Hence the need for testing. If you come up with any other tests let me know. Closing for now as it's mission accomplished on this particular issue: we've tested Python read time in comparison with R in a reproducible manner (more to come).