kiterunner icon indicating copy to clipboard operation
kiterunner copied to clipboard

High memory consumption when loading `routes-large.kite`

Open minight opened this issue 4 years ago • 4 comments

running routes-large.kite consumes an inordinate amount of memory, causing the program to start thrashing on machines with limited ram

The route compilation should be optimised to avoid this if possible

minight avatar Apr 11 '21 10:04 minight

Profiling taken by curl localhost:6060/debug/pprof/heap > heap.pprof2 upon program startup with ./kr scan -w ~/routes-large.kite -A=apiroutes-210328:20000 -x 20 -j 1 --fail-status-codes 400,401,404,403,501,502,426,411 https://target.com seems to indicate that unmarshalling the kite file is consuming a substantial amount of memory.

I suspect using proto.Unmarshal is less optimal than using the inbuilt proute.ProtoAPI.Unmarshal function generated by gogoproto.

heap.pprof2.zip

image

minight avatar Apr 11 '21 10:04 minight

Later profiling indicates that converting to proto routes and then to http routes is causing 3x the memory usage necessary. image

It may warrant rethinking how we load the dataset into memory and whether a non-copy version is possible

heap.pprof7.zip

minight avatar Apr 11 '21 10:04 minight

I have the same problem here.

0xCGonzalo avatar Apr 13 '21 05:04 0xCGonzalo

0xCGonzalo avatar Apr 13 '21 05:04 0xCGonzalo