namecoin / namecoin-legacy

Legacy client. New version here: https://github.com/namecoin/namecoin-core Note the release branch! - Official website:
https://namecoin.org
MIT License
448 stars 177 forks source link

Whom do I thank for 87% RAM usage improvement? #138

Closed taoeffect closed 10 years ago

taoeffect commented 10 years ago

WRT namecoind, this appears to have happened in the past few weeks (or months) in the namecoinq branch. Which commit did it? It went from >300MB to 90MB. Thank you to whomever did it!

taoeffect commented 10 years ago

@domob1812 ? @JeremyRand thinks it might be you:

8:42:55 PM Jeremy_Rand: sugarpuff / indolering : I think domob optimized the name index a bit, and a checkpoint was added; both probably reduce namecoind RAM usage

Maybe you could comment a bit if it was? Is this a "real fix" or just because of the checkpoint? (In other words, can I expect the RAM usage to start climbing back, and if so, how difficult is it to "really fix" it?)

JeremyRand commented 10 years ago

@taoeffect, domob did the name index optimization, I think phelix did the checkpoint. I don't know which of them had a larger effect. I can tell you that with libcoin, the checkpoint cut RAM usage during sync in half (compared against no checkpoints at all).

domob1812 commented 10 years ago

I think the RAM reduction was mostly due to my patch that removed the auxpow from CBlockIndex objects. Those (the "block headers") are kept in memory for each known block, and the auxpow is not really necessary for the function they have there - but it took up most of the space. So removing it cut down usage quite a lot. The total effect may be related to other improvements as well, though. There've been quite a few in recent times - and I'm working on more (although mostly related to disk) for Huntercoin, which will be ported back to Namecoin as well.

taoeffect commented 10 years ago

Cool, thanks for explanation @domob1812. I'm still not clear though on whether this is a "real fix" or not. Will ram usage just go back to the massive 300MB+ that it was the farther we get from the most recent checkpoint? Or is the memory management done more intelligently now to prevent that?

domob1812 commented 10 years ago

It has nothing to do with checkpoints. All known block headers are kept in memory, and of course, this amount will grow over time - although much more slowly now than before. I think that without the auxpow, a block header is only a couple of bytes (80?). So keeping in memory even 1,000,000 blocks in the far future shouldn't be a big problem. This is the same for Bitcoin, BTW.

taoeffect commented 10 years ago

Oh ok, thanks @domob1812 for the clarification, it's starting to make sense now, and it sounds like this is more of a "real fix" then.