mleku on Nostr: hand-made json parser custom built for nostr makes a HUGE difference, i mean, it's ...
hand-made json parser custom built for nostr makes a HUGE difference, i mean, it's almost as fast as marshalling to binary, either wire JSON or canonical form, and unmarshaling is even faster because it is able to take so many shortcuts you can't do with a general JSON unmarshal, because you know what the data structure MUST be
that was why i ended up changing over the database storage to canonical form with the signature attached, it's probably on par with any binary codec for storing the events, and getting the binary codecs to behave was too hard, lol... i just enable ZSTD compression on the database and that is that
the real boost in measurable performance on nostr relays is all about json encoding
gah i been buried in this stuff so long, i will win me a prize from it!
Published at
2025-01-05 13:25:17Event JSON
{
"id": "8656bc276ba503e835a9925efeb4518ea8d00ce4fc3c96c367d1b720908c0eeb",
"pubkey": "4c800257a588a82849d049817c2bdaad984b25a45ad9f6dad66e47d3b47e3b2f",
"created_at": 1736083517,
"kind": 1,
"tags": [
[
"e",
"ddf86bef5aa6cfb37c9c33eb483ba5c15710a17db6a09bcff5a119834b8fc47b",
"wss://theforest.nostr1.com/",
"root",
"fd208ee8c8f283780a9552896e4823cc9dc6bfd442063889577106940fd927c1"
],
[
"e",
"56641fc0a6460bd4c976b43d7eefda2066e4c1284f6c97aba461bb9bda0af339",
"wss://relay.nostr.band/",
"reply",
"fd208ee8c8f283780a9552896e4823cc9dc6bfd442063889577106940fd927c1"
],
[
"p",
"fd208ee8c8f283780a9552896e4823cc9dc6bfd442063889577106940fd927c1",
"wss://theforest.nostr1.com/"
],
[
"p",
"4c800257a588a82849d049817c2bdaad984b25a45ad9f6dad66e47d3b47e3b2f"
],
[
"client",
"noStrudel",
"31990:266815e0c9210dfa324c6cba3573b14bee49da4209a9456f9484e5106cd408a5:1686066542546"
]
],
"content": "hand-made json parser custom built for nostr makes a HUGE difference, i mean, it's almost as fast as marshalling to binary, either wire JSON or canonical form, and unmarshaling is even faster because it is able to take so many shortcuts you can't do with a general JSON unmarshal, because you know what the data structure MUST be\n\nthat was why i ended up changing over the database storage to canonical form with the signature attached, it's probably on par with any binary codec for storing the events, and getting the binary codecs to behave was too hard, lol... i just enable ZSTD compression on the database and that is that\n\nthe real boost in measurable performance on nostr relays is all about json encoding\n\ngah i been buried in this stuff so long, i will win me a prize from it!",
"sig": "06b37831c928702ebe13f1306e9a55ca12675191cdceab4d88c6c35b7781602225b7e12263dee13f27bfa42abdcbcaeca446a816de56d01c0e147fd10d6c30a0"
}