couchdb icon indicating copy to clipboard operation
couchdb copied to clipboard

Cache VDU functions so they are not called for each document

Open natcohen opened this issue 2 years ago • 1 comments

Summary

When adding 100 documents, CouchDB sends the VDU functions for each and every document (meaning that the VDU functions are sent 100 times). This leads to poor performances.

Desired Behaviour

A better implementation would be to cache the VDU functions so they are not sent as often to the JS engine

Possible Solution

Caching the functions or at least calling them only once per DB call.

Additional context

natcohen avatar May 22 '23 15:05 natcohen

note that the function strings are cached (by load_validation_funs in couch_doc), but we send them to couchjs on every doc update, so we don't get any benefit from JIT and we're bloating the message we send to validate_doc_update over stdio.

see if we can do better here.

related PR https://github.com/apache/couchdb/pull/1898 which proposes another way to do VDU's without javascript at all.

rnewson avatar May 22 '23 15:05 rnewson