-
sech1
the whole project is built around async calls and libuv event loop, so I'm not so sure :)
-
proteeks[m]
Hi All, I was reading about Monero and mining and came across p2pool. The concept seems pretty good atleast with my limited understanding. One statement somewhere in their website stumped me. They support only primary addresses. Why does it matter, I mean an address is an address no?
-
hyc
no
-
proteeks[m]
Okay that was succinct 😀. Let me progress a little more on mastering monero and get back.
-
hyc
-
hyc
plenty of info on stackexchange
-
hyc
just search for subaddress
-
proteeks[m]
Thank you hyc
-
hyc
I wonder if it would be worthwhile to make calcpow a binary rpc instead of json. ideally it should be as low latency as possible.
-
sech1
rpc vs binary will make <0.01% difference, hash calculation is the slowest
-
sech1
btw I wrote the code for p2pool during breakfast, will be testing it today :D
-
sech1
and p2pool has good support for json rpc and nothing for binary
-
sech1
-
sech1
it will complain about calling uv_default_loop() from the wrong thread every time
-
sech1
I'll to fix it later because it's not thread safe
-
sech1
but you can test already
-
sech1
hyc
SChernykh/p2pool #78 should be good for testing now
-
hyc
nice I'll give it a whirl
-
DataHoarder
this might be quite neat for running many instances of p2pool indeed
-
sech1
yes, my second p2pool instance failed to allocate huge pages even though my server has 64 GB RAM. Memory fragmentation and I don't want to reboot it
-
DataHoarder
slightly higher latency probably
-
DataHoarder
also does it do the check via RPC on light mode?
-
DataHoarder
cause if I feed many p2pool instances to single monerod node, I'm afraid it might not keep up on light mode
-
sech1
monerod uses light mode by default
-
sech1
hyc said something about adding a command line or ENV var option to monerod to fix it
-
sech1
also this RPC API makes it possible to run p2pool+monerod on a 1 GB Raspberry Pi :D
-
hyc
hm. p2pool just hanging at startup
-
hyc
oh wait n/m
-
hyc
yeah something not moving
-
hyc
all the hasher threads waiting for rpc completion
-
hyc
cond_wait
-
sech1
hmm, there's more than one thread?
-
sech1
I might need more than 1 cond var :D
-
hyc
yes
-
hyc
doh
-
hyc
prob going to have to serialize the entire thing, I don't think monerod supports more than 1 outstanding rpc on a connection
-
sech1
each request creates a separate connection
-
hyc
ah
-
hyc
I don't see anything weird on the monerod side
-
hyc
but if each request uses its own resources then yes, each thread needs its own condvar
-
hyc
would be nice to avoid the overhead of creating/destroying mutex&condvar on each request
-
sech1
-
sech1
like this for now
-
sech1
overhead is little compared to RPC delay
-
sech1
and after initial sync, it will calculate PoW only when receiving new sidechain blocks (or Stratum shares with enough difficulty), so it's not so many calls
-
hyc
ok, running again now
-
hyc
still something stuck
-
hyc
no active pools, stop mining - so xmrig is not getting a reply from p2pool
-
hyc
2021-11-20 16:15:19.9117 Util background jobs running:
-
hyc
P2PServer::handle_incoming_block_async (3)
-
hyc
StratumServer::on_share_found (1)
-
hyc
still stuck in cond_wait. any chance the rpc on monerod side isn't returning a valid message?
-
hyc
guess I'll try tcpdumping a bit
-
sech1
p2pool would show something if JSON response was invalid
-
sech1
hyc I added logging of JSON requests/replies
-
sech1
you could also try to move "MutexLock lock(m_loopMutex);" to the very top of RandomX_Hasher_RPC::calculate() to serialize everything
-
sech1
it will be easier to debug
-
hyc
I don't see calc_pow in the packet trace at all
-
hyc
maybe the req isn't actually getting flushed to the network
-
hyc
and tcpdump on loopback interface should be seeing it all
-
sech1
if it's not even sent, probably event loop is not running. Check p2pool log for "RandomX_Hasher event loop started" and "RandomX_Hasher event loop stopped"
-
hyc
yeah, says it started
-
hyc
4 requests are logged
-
hyc
nothing else
-
hyc
4 connections established too. dunno why I don't see it in packet traces
-
sech1
ok, try to add some logging in JSONRPCRequest::on_connect(). Like LOGINFO(1, "JSONRPCRequest::on_connect");
-
hyc
is it possibly sending garbage? I'm seeing some stuff that doesn't look likvalid rpc traffic
-
hyc
maybe a cmd buffer goes away before it got sent?
-
sech1
it's copied in JSONRPCRequest constructor
-
sech1
it wouldn't work with other RPC requests if it wasn't copied
-
hyc
ok. well I see the other requests like get_version get_miner_data
-
sech1
Strange. It worked on Windows. I'll check Linux tomorrow
-
hyc
ok. I filtered on loopback interface, port 18081. calc_pow is not in the capture at all
-
hyc
I see get_info, get_version, get_miner_data, get_block_header_by_height, get_block_headers_range, no other requests
-
sech1
event loop doesn't work for some reason
-
sech1
-
sech1
it will fall back to the default loop then
-
hyc
ok
-
sech1
it's not thread-safe, but it should work
-
hyc
it complains
-
hyc
2021-11-20 17:04:44.7250 Util uv_default_loop() can only be used by the main thread. Fix the code!
-
sech1
as expected
-
sech1
but does it send requests?
-
hyc
still seems stuck. i didn't capture pkts, lemme try again
-
hyc
nope. not in packet trace
-
hyc
hm, it may be working now\
-
hyc
I'm seeing results, yes
-
hyc
massively delayed
-
sech1
delay before sending request or when waiting for response?
-
hyc
2 minutes btw first request and first response
-
hyc
I think it's delay before sending request
-
sech1
add log to JSONRPCRequest::on_connect in json_rpc_request.cpp. It should connect immediately, not after 2 minutes
-
sech1
LOGINFO(1, "JSONRPCRequest::on_connect"); should be enough to see it in log and figure out delays
-
hyc
it does connect immediately
-
hyc
it doesn't send request tho
-
sech1
maybe uv_tcp_nodelay doesn't really work
-
hyc
I see a connection open on port 47240 -> 18081 at 17:11:59
-
hyc
the request on port 47240 happens at 17:14:04
-
sech1
but do you have log in on_connect? It will show when p2pool actually gets notified about established connection
-
hyc
ok I'll add that
-
hyc
I see lots of on_connect logs
-
hyc
-
sech1
it looks like it only moves forward after receiving new miner data
-
sech1
and after that it works fine
-
hyc
still seems a long delay between logging the request and actually sending it
-
sech1
17:24:44.2795 request sent, 17:24:44.3041 response receive
-
sech1
not long
-
hyc
are you sure that is the response to that request?
-
sech1
no
-
sech1
ok, it's the previous one
-
sech1
monerod seems to not accept multiple connections
-
hyc
netstat shows 4 established
-
sech1
but it serializes them
-
hyc
I guess. that's still not the real problem tho
-
hyc
does this always use a new connection per RPC? can it reuse the same connection?
-
sech1
ohh I think I know what's happening. libuv loops are really not designed to work in more than 1 thread
-
sech1
the loop is just waiting on a set of handles, and m_loop is waiting on just 1 async handle (m_shutdownAsync)
-
sech1
and it stays asleep even if there's a pending connection request (uv_tcp_connect)
-
sech1
it'll start processing it only after it's woken up (by anything)
-
sech1
this is why it works with uv_default_loop, but with huge delay
-
sech1
new Monero block probably triggers uv_default_loop
-
sech1
fix coming soon
-
hyc
ok
-
hyc
need uv_async_send() ?
-
sech1
yes
-
sech1
hyc submitted the fix, try again
-
hyc
ok building
-
hyc
there it goes :)
-
hyc
you can use uv_async_init with a NULL callback
-
sech1
ok
-
hyc
overall doesn't seem to bad. job acceptance is about as fast as before but occasionally spikes if monerod was busy
-
hyc
share accept times reported by xmrig ...
-
sech1
The current code is still not thread-safe (RPC call adds more handles to loop's list and it can interfere with the loop processing TCP packets and traversing that same list)
-
sech1
I'll rewrite it to use async callback since async is there already
-
hyc
ok
-
hyc
freeing up 512MB of RAM on this rockpro64 is good ...
-
sech1
ahh, I just made it serialized
-
sech1
then I don't need to juggle with async calls
-
hyc
whatever works
-
sech1
this way when JSONRPCRequest::call modifies loop's handle list, the loop is guaranteed to not be doing anything
-
sech1
also I can use only 1 cond var again
-
hyc
cool
-
sech1
can you test again with latest?
-
hyc
ok lemme grab it
-
hyc
running. it's going
-
sech1
nice
-
hyc
yeah looks good