GNU bug report logs -
#79361
minor jsonrpc optimisation suggestions
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Emacs's built-in JSON parser happily accepts encoded unibyte strings and buffers as input because JSON is specified at byte level. This means that any effort to decode the input to multibyte first is wasted. (This overhead is quite measurable in general.)
For jsonrpc this means that for good performance, make sure the process buffer is unibyte and set the process coding system to something like `binary`. The filter function will then be passed unibyte strings. (The `position-bytes` and `byte-to-position` calls become identity and can be eliminated.)
This should apply to both the old (libjansson) and new JSON parsers. The old json.el parser (json-read) doesn't cope well with unibyte input (unless it's all-ASCII, of course), so for the masochists you may want some compatibility code.
Here is a proof-of-concept patch, largely untested and untimed (well, it compiles and passes the tests).
[jsonrpc.diff (application/octet-stream, attachment)]
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.