Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad performance: Many references #223

Open
mity opened this issue Apr 12, 2018 · 2 comments
Open

Bad performance: Many references #223

mity opened this issue Apr 12, 2018 · 2 comments

Comments

@mity
Copy link

mity commented Apr 12, 2018

Processing many reference definitions/references takes too much time. On my machine:

$ time python -c 'print ("".join(map(lambda x: ("[" + str(x) + "]: u\n"), range(1,10000 * 16))) + "[0] " * 10000)' | ./hoedown >/dev/null
real	0m8.778s
user	0m8.739s
sys	0m0.029s
@markand
Copy link

markand commented May 16, 2018

Are you really saying that 8 seconds is too big for 160000 links? And as a note, if you really have a document as big I'm not sure if I would read it 😁

@mity
Copy link
Author

mity commented May 16, 2018

Well, yes, it is slow. Maybe I should elaborate more.

Parsing few MB in seconds is slow on a modern computer.

Much worse, the time grows in much worse fashion (I guess quadratic) then linear here. On my quite fast machine I get these results, with this slightly more generalized example for different N:

$ time python -c 'N=16; print ("".join(map(lambda x: ("[" + str(x) + "]: u\n"), range(1,N*10000))) + "[0] " * N*10000)' | ./hoedown >/dev/null

And, for comparison, I added times it takes MD4C parser.

N input size hoedown md4c
8 1.2MB 5.859s 0.125s
16 2.5MB 23.531s 0.203s
24 3.8MB 55.000s 0.281s

And no, it's not about whether you read the document or not.

If an application can read the document from any (read: untrusted) source, this document can be used as a DOS attack, even if the application limits document size to e.g. something like 10MB, consuming CPU cycles of your server for long minutes per single request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants