web tcard - speed optimization

11
1 Web TCard – Speed optimization Eric Guo MES Business Systems Analyst 3/22/2015

Upload: eric-guo

Post on 16-Jul-2015

203 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Web TCard - Speed optimization

1

Web TCard – Speed optimization

Eric Guo

MES Business Systems Analyst

3/22/2015

Page 2: Web TCard - Speed optimization

2

Overview

Background & Objective

Experimental - Measure & Finding bottleneck

Result & Discussion

Conclusion

Learnt from it

Page 3: Web TCard - Speed optimization

3

Background & Objective

Speed

More data source.

Stable (0 downtime)

Agility

Built for mobile instead of paper.

Built for next 10 years.

Page 4: Web TCard - Speed optimization

4

Measure & Finding bottleneck in CR report

Using M1512ME9F3.02 and MT TCard as example.

http://cvpmesip04/TCardPrint/

– Total loading time 3.86s

• Including 16 sub report, time in ms

• 103+49+228+71+240+46+55+110+49+55+89+49+18+47=1209 MS

• All rest time is relative with render or running in Crystal Report internally.

Page 5: Web TCard - Speed optimization

5

Latency times every programmer should know

L1 cache reference 0.5 ns

Branch mispredict 5 ns

L2 cache reference 7 ns 14x L1 cache

Mutex lock/unlock 25 ns

Main memory reference 100 ns 4x mutex op, 20x L2 cache, 200x L1 cache

Compress 1K bytes with Zippy 3,000 ns

Send 2K bytes over 1 Gbps network 20,000 ns

Read 1 MB sequentially from memory 250,000 ns

Round trip within same datacenter 500,000 ns

Disk seek 10,000,000 ns 20x datacenter roundtrip

Read 1 MB sequentially from disk 20,000,000 ns 80x reading in seq from memory

Send packet CA->Netherlands->CA 150,000,000 ns

By Jeff Dean (http://research.google.com/people/jeff/):

Page 6: Web TCard - Speed optimization

6

Analysis and feasibility analyze

Sub-report slowdown the total processing

– But it’s needed and necessary because of biz requirement

Deep link table join will cause slowness

– But you need link those table to take data to be showing in T-Card latter.

Crystal Report takes 2.6+ seconds to do internal works

– But it’s almost can not make any change to affect it

Crystal Report will failed to loading report sometime

– No source code, no way to improve.

Page 7: Web TCard - Speed optimization

7

Days of future past – act like X-Men

Sub-report slowdown the total processing

– Stop using sub-report in new web t-card

Deep link table join will cause slowness

– Stop using any join when query DB table

Crystal Report takes 2.6+ seconds to do internal works

– No internal code, everything should can be changed

Crystal Report will failed to loading report sometime

– Stop using Crystal Report

Page 8: Web TCard - Speed optimization

8

Perception is Reality

Stop using sub-report in new web t-card

– Fetch data in one place

Stop using any join when query DB table

– One query per one table, in-memory calculation all T-Card info, do filter, join.

No internal code, everything should can be changed

– Know each line of time taken

Stop using Crystal Report

– Whole web T-Card built on the open source stack

Page 9: Web TCard - Speed optimization

9

Trace the SQL payload by line

Page 10: Web TCard - Speed optimization

10

Result & Discussion

M1512ME9F3.02 is now takes 0.68s to loading

5 times faster.

Page 11: Web TCard - Speed optimization

11

Conclusion & Learnt From It

Make things faster probably need re-think the whole design.

Except make things faster, many things also important.

Maintain cost

Support cost

Stability

Simplicity

The more you known, the more freedom you have to balanced contradiction requirement

– http://cvpscmip01/mv.git