Parsing OSM XML iD OSMCha To-Fix Frontend Developer kepta - - PowerPoint PPT Presentation

parsing osm xml id osmcha to fix
SMART_READER_LITE
LIVE PREVIEW

Parsing OSM XML iD OSMCha To-Fix Frontend Developer kepta - - PowerPoint PPT Presentation

Parsing OSM XML iD OSMCha To-Fix Frontend Developer kepta kushan2020 Breaking down iD Breaking down iD 15% Rendering Painting 21% Javascript 64% HTML A sample of what iD is doing behind the scenes Breaking down JS 13% Draw Vector


slide-1
SLIDE 1

Parsing OSM XML

slide-2
SLIDE 2

Frontend Developer

iD OSMCha To-Fix

kepta kushan2020

slide-3
SLIDE 3

Breaking down iD

slide-4
SLIDE 4

Breaking down iD

64% 21% 15%

Rendering Painting Javascript HTML

A sample of what iD is doing behind the scenes

slide-5
SLIDE 5

Breaking down JS

13% 27% 11%8% 42%

Draw Vector GC DOM Selector Parse XML Others

slide-6
SLIDE 6

Parsing XML eats up 25% of CPU Time

slide-7
SLIDE 7

Solutions?

  • Stop parsing XML ?
slide-8
SLIDE 8

Solutions?

  • Stop parsing XML ?
slide-9
SLIDE 9

Solutions?

  • Stop parsing XML ?
  • Use clever techniques to defer the parsing of XML
slide-10
SLIDE 10

Solutions?

  • Stop parsing XML ?
  • Use clever techniques to defer the parsing of XML
slide-11
SLIDE 11

Solutions?

  • Stop parsing XML ?
  • Use clever techniques to defer the parsing of XML
  • Exploit the multi-core architecture of CPUs
slide-12
SLIDE 12

Solutions?

  • Stop parsing XML ?
  • Use clever techniques to defer the parsing of XML
  • Exploit the multi-core architecture of CPUs
slide-13
SLIDE 13

The Multi-threading Solution

  • Even the cheapest smartphone has at least two core for

processing

  • Unlike UI, parsing can be easily offloaded to a

separate thread.

  • This will improve the response time and alleviate some
  • f the pressure on main thread.
slide-14
SLIDE 14

Browsers and Threads

  • Browser threads a.k.a web-workers do not 


support DOM/XML

slide-15
SLIDE 15

Browsers and Threads

  • Browser threads a.k.a web-workers do not 


support DOM/XML

  • iD wasn’t written to be executed in a multi-threaded

environment

slide-16
SLIDE 16

Osm-Bizli

  • To circumvent the problem of not having DOM, I created a

new library called Osm-Bizli.

  • It relies on string parsing of XML line by line.
  • It only understands the particular XML returned by the

bbox API.

  • With these focused features, it is able to deliver

impressive performance.

slide-17
SLIDE 17
slide-18
SLIDE 18

How does it work?

We parse the XML line by line.

slide-19
SLIDE 19

How does it work?

For each Entity we create a corresponding blank object.

slide-20
SLIDE 20

How does it work?

The attributes are populated.

slide-21
SLIDE 21

How does it work?

slide-22
SLIDE 22

How does it work?

We then move to next line

slide-23
SLIDE 23

How does it work?

If the line starts with <nd or <tag we fill our way object with it

slide-24
SLIDE 24

How does it work?

Whenever we encounter a closing tag, we save the object and start fresh with new line.

slide-25
SLIDE 25

Takeaways

slide-26
SLIDE 26

Takeaways

  • Multi-threading would improve the performance of iD
  • Osm-bizli uses string parsing of OSM-xml to overcome

the limitations of web-workers.

  • Opens future possibility of offloading more tasks to web-

worker.

slide-27
SLIDE 27

Thanks