Consider sticking to only snakecase or camelcase in `api`, or write explicit mappers for performance
albertyfwu opened this issue · 0 comments
albertyfwu commented
Right now, sometimes when there are a lot of list queries for contacts, accounts, etc. the nodejs event loop latency spikes. Something suspicious is that mapping 1000 contacts from camelcase to snakecase, for example, took around 100-150ms in testing.
Instead, an explicit mapper cut this time down to 1ms.
This may be the cause of our health checks occasionally failing the 1s timeout.
The snakecase-keys library seems to be very expensive. Maybe we can:
- Write explicit mappers (GPT can help with this, or we can have a script to generate the mappers ahead of time?) like
newContact = { foo_bar: contact.fooBar, bar_foo: contact.barFoo, ...}
, or - stick to camelcase/snakecase throughout our code