ptpb / pb

pb is a formerly-lightweight pastebin and url shortener
Other
549 stars 52 forks source link

the fast master #116

Closed polyzen closed 9 years ago

polyzen commented 9 years ago

Currently it takes a few seconds to upload screencaps; any chance we can speed things up?

@buhman had linked the Python Profilers docs; I suppose I should try them out

EDIT: [nuked stupid 'sanic' image]

buhman commented 9 years ago

After no-op'ing all db calls, with a ~60MB request body:

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        3    1.338    0.446    1.338    0.446 {built-in method select}
  1257273    0.527    0.000    1.388    0.000 formparser.py:373(parse_lines)
        3    0.512    0.171    2.124    0.708 formparser.py:471(parse_parts)
   628644    0.511    0.000    0.698    0.000 wsgi.py:815(_iter_basic_lines)
  1257267    0.223    0.000    0.223    0.000 {method 'write' of '_io.BufferedRandom' objects}
   628644    0.163    0.000    0.861    0.000 wsgi.py:776(make_line_iter)
        2    0.072    0.036    0.072    0.036 {built-in method openssl_sha1}
     1169    0.068    0.000    0.068    0.000 {method 'splitlines' of 'bytes' objects}
     1171    0.057    0.000    0.057    0.000 {method 'recv_into' of '_socket.socket' objects}
   631374    0.051    0.000    0.051    0.000 {method 'append' of 'list' objects}
   628646    0.038    0.000    0.038    0.000 {method 'join' of 'bytes' objects}
        2    0.019    0.009    0.019    0.009 {method 'read' of '_io.BufferedRandom' objects}
     1170    0.004    0.000    0.028    0.000 wsgi.py:980(read)
        1    0.004    0.004    0.004    0.004 {method 'close' of '_io.BufferedRandom' objects}
     1170    0.003    0.000    0.022    0.000 {method 'read' of '_io.BufferedReader' objects}
     1170    0.001    0.000    0.029    0.000 wsgi.py:756(_make_chunk_iter)
     1171    0.001    0.000    0.060    0.000 socket.py:360(readinto)
        6    0.001    0.000    0.001    0.000 {built-in method loads}
     1186    0.001    0.000    0.030    0.000 {built-in method next}
    57/55    0.001    0.000    0.001    0.000 {built-in method __build_class__}
time curl -F c=@- -F p=1 http://localhost:10002/ < test > /dev/null
  0.04s user 0.05s system 3% cpu 2.295 total

Contrast to what I expected, doing multiple sha1()'s takes almost zero time. Most of the time in requests is actually spent in werkzeug's stupid form parser.

buhman commented 9 years ago
01:11:36 +buhman jpettit: can I rewrite pb in C?
01:11:44 +halosghost ooooh, doit!
01:11:51 +halosghost it needs to be faster!
01:12:36 +jpettit I thought that was the master plan
01:13:50 +buhman halosghost: sounds like a 'yes' to me
HalosGhost commented 9 years ago

:+1:

polyzen commented 9 years ago

Woops..? "buhman was unassigned by polyzen 2 days ago"

buhman commented 9 years ago

While I initially planned on fixing this in-place, it's going to be a completely separate project, bp.