lightningd: always do incremental parsing of JSON inputs.

time lightning-cli -R --network=regtest --lightning-dir /tmp/ltests-k8jhvtty/test_pay_stress_1/lightning-1/ listpays > /dev/null

Before:
	real	0m42.741s
	user	0m0.149s
	sys	0m0.016s

After:
	real	0m13.674s
	user	0m0.131s
	sys	0m0.024s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: significant speedups for plugins which create large JSON replies (e.g. listpays on large nodes).
This commit is contained in:
Rusty Russell
2020-08-20 23:10:34 +09:30
parent 3ed03f9c8f
commit c284b5bbf4
3 changed files with 39 additions and 31 deletions

View File

@@ -56,6 +56,8 @@ struct plugin {
/* Stuff we read */
char *buffer;
size_t used, len_read;
jsmn_parser parser;
jsmntok_t *toks;
/* Our json_streams. Since multiple streams could start
* returning data at once, we always service these in order,