What is Nostr?
lnproxy
npub1ufd…zcue
2023-08-11 02:02:00

A boltdb backend for fiatjaf's relayer

@fiatjaf (nprofile…pawm) ’s relayer is a go library for making custom relays. I’ve been investigating its capabilities in the past few weeks and I like how customizable it is. I’m not a nostr expert, but I think that the ability to make relays tuned to specific purposes is important for nostr to succeed (e.g. I want a relay to allow people to run competitive lnproxy relays without needing to expose their clearnet IP addresses).

In testing, I’ve found the performance of the different storage backends available for relayer lacking, but I’ve been working on a speedier solution based on boltdb! With that in mind, last week I asked nostr:

nevent1q…ykj8

Unfortunately none of the suggestions were exactly what I needed but I was able to set up some benchmarks in go and the results are looking great:

BenchmarkSQLite3QueryEvents/IDs-8         	      30	  42339015 ns/op
BenchmarkSQLite3QueryEvents/Authors-8     	      36	  37080938 ns/op
BenchmarkSQLite3QueryEvents/Tags-8        	      31	  41998150 ns/op
BenchmarkSQLite3QueryEvents/Kinds-8       	      18	  69550451 ns/op
BenchmarkSQLite3QueryEvents/Authors,Kinds-8         	      48	  41373654 ns/op
BenchmarkSQLite3QueryEvents/Since-8                 	       9	 129129112 ns/op
BenchmarkSQLite3QueryEvents/Authors,Since-8         	      40	  47585709 ns/op
BenchmarkSQLite3QueryEvents/Authors,Kinds,Since-8   	      18	  64724085 ns/op
BenchmarkSQLite3QueryEvents/Tags,Kinds-8            	      36	  49993809 ns/op
BenchmarkSQLite3QueryEvents/Tags,Authors-8          	      34	  31319155 ns/op
BenchmarkBoltQueryEvents/IDs-8                      	    1591	    756493 ns/op
BenchmarkBoltQueryEvents/Authors-8                  	     255	   4652186 ns/op
BenchmarkBoltQueryEvents/Tags-8                     	     264	   4566247 ns/op
BenchmarkBoltQueryEvents/Kinds-8                    	     250	   4772767 ns/op
BenchmarkBoltQueryEvents/Authors,Kinds-8            	     170	   6893723 ns/op
BenchmarkBoltQueryEvents/Since-8                    	     277	   4473123 ns/op
BenchmarkBoltQueryEvents/Authors,Since-8            	     243	   4738151 ns/op
BenchmarkBoltQueryEvents/Authors,Kinds,Since-8      	     163	   7289618 ns/op
BenchmarkBoltQueryEvents/Tags,Kinds-8               	     190	   6502720 ns/op
BenchmarkBoltQueryEvents/Tags,Authors-8             	     705	   1755724 ns/op

I’ll try to release the code sometime this weekend, but I wanted to share that my boltdb solution is much faster than sqlite for simple queries and even beats sql on fairly complex queries.

Author Public Key
npub1ufdgkgz3qg4q37taye75hxwal3gq5zl7zjd97ec7gmmja84rdmyspmzcue