Pandos

  • Living on the edge of Wedge
  • Posts: 635
Support for PECL Memcached
« on August 16th, 2011, 04:07 PM »
Is there a chance to integrate support for PECL memcached instead of "old" PECL memcache?
It's newer, faster and has much more features. Even fine for Session Support.

Regards

Sven

# dpkg-reconfigure brain
error: brain is not installed or configured

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Support for PECL Memcached
« Reply #1, on August 16th, 2011, 04:09 PM »
Not in the core, simply because most users aren't going to be running it. I see us adding it as a plugin of some description though.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Support for PECL Memcached
« Reply #2, on August 16th, 2011, 04:44 PM »
Isn't it only a few lines in get_cache or something in the Subs-Cache.php file...?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Support for PECL Memcached
« Reply #3, on August 16th, 2011, 04:47 PM »
No, it's not, it is a shade more complex in terms of how you set PECL up. The default 'old' extension is trivial to set up, the newer one less so, and most hosts that support memcache do not have the new one set up.

In fact, PECL generally is a pain in the arse to use.

Nao

  • Dadman with a boy
  • Posts: 16,079

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Support for PECL Memcached
« Reply #5, on August 16th, 2011, 04:50 PM »
Especially since for session support it requires other changes to how sessions are handled ;)

Though there's no real reason why we couldn't in those circumstances do something imaginative like pushing sessions into a MEMORY table in MySQL which has most of the same benefit (though doesn't shard it across multiple servers and is still going to be slower than memcache, but not nearly as slow as a normal table)

Pandos

  • Living on the edge of Wedge
  • Posts: 635
Re: Support for PECL Memcached
« Reply #6, on August 16th, 2011, 05:19 PM »
session support should be left on php.ini side.
there you can tell php to use memcached as session handler.

sessions in MySQL are not that performant e.g. for boards with lot of members online at the same time. now with 7000 and more users online there's no problem since we're using Memcached.

Ensiferous did it for SMF by only replacing a view lines in Load.php:

http://custom.simplemachines.org/mods/index.php?mod=2289

imho it's worth to be added.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Support for PECL Memcached
« Reply #7, on August 16th, 2011, 05:29 PM »
Quote
session support should be left on php.ini side.
No, it shouldn't, not for the vast majority of Wedge users. There are multiple very good reasons for leaving it how it is in the core, i.e. using MySQL.
Quote
sessions in MySQL are not that performant e.g. for boards with lot of members online at the same time. now with 7000 and more users online there's no problem since we're using Memcached.
Make it a memory table, then see how performant it is.
Quote
Ensiferous did it for SMF by only replacing a view lines in Load.php:
Yes, I know that. Except that doesn't actually push sessions over to memcache, you have to specifically reconfigure other things to do that. (I'm the one who approved the mod, which means I had to test it. Which means I had to actually configure it, hence my statement about it being a pain in the arse.)


Here's the crunch point: the time I spend on implementing that (which, if I use Ensi's code means I legally have to ask him about it, I can't just reuse it, or I spend time rewriting it from scratch), including debugging and configuration and so on, is time I'm not spending on things that more than 0.0001% users are ever going to see, and to be honest both Nao and I have more important things to do than cater to an utter minority of users.


So again, this is going to be something we tackle as a plugin rather than a core feature because I'm not building something in that affects a tiny group of users into the core, especially as it will encourage them to expect support for something that I'm not really qualified to provide support for.

Pandos

  • Living on the edge of Wedge
  • Posts: 635
Re: Support for PECL Memcached
« Reply #8, on August 16th, 2011, 05:36 PM »
THX for your statement.
I can understand it better now the way you explained it.

Feel free to ask if you need translations in German. Cant wait to get our "BigBoard" from SMF to Wedge :)

Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Support for PECL Memcached
« Reply #9, on October 29th, 2013, 03:30 PM »
Pandos, I don't remember where we talked about this, but since there's already a topic for that, I'll just reuse it... (You can see from the wedge.org stats that technically, I'm a 'topic re-use' guy, whereas Arantor was a 'new topic crazy' guy...)

So, I've been looking into memcached (for some obscure unrelated reason), and installed a server on my PC, and wasn't thrilled to see that it didn't work.
The reason was pretty stupid, actually. I'm even wondering if SMF has got it right, either...
- reloadSettings load $modSettings, which it does through the cache.
- cache checks $modSettings (which is empty), and determines memcached isn't available. Load from file? Doesn't have anything.
- it then rebuilds the settings from DB, and proceeds to save it to the cache...
- cache checks $modSettings (which is no longer empty), and then saves to memcached. As a result, that entry will never be loaded by reloadSettings, which will continuously rebuild the $modSettings cache. For nothing.

In Wedge, it was a similar codepath, except that $settings ($modSettings) was only checked once; because memcached wasn't available, it would then use the file cache, and effectively keep using it later. So, Wedge is less buggy in that area, although it's due to another bug...

I've fixed it locally, by saving the memcached server data to a Settings.php variable instead. Because it's already loaded by the time $settings reloads from cache, we can effectively reload from memcached. Works.
There are still 3 outstanding bugs, although minor:
- language files don't seem to be stored through memcached. They still use the file cache. I'm not exactly sure why it was done that way. I'm going to assume it was for a reason, so I'll leave it aside for now.
- An admin area issue that forces me to re-enter the memcached server every time I go to that page. No biggie, will fix.
- And related to your topic: there is no php_memcached.dll file for Windows, meaning I can't even begin to test Memcached in Wedge.
This is relatively important to me, because it shouldn't be a big deal to implement this, but I looked into the SMF 2.1 code and they just basically replace memcache_* calls with memcached_* calls, and I can't for the life of me, find any documentation on the procedural versions of Memcached methods. Do they even exist...?!
Re: Support for PECL Memcached
« Reply #10, on October 30th, 2013, 12:06 AM »
So, in my commit, I removed any reference to memcached_*, because... Well, I didn't see much of a point in making one more library available, when -- fun fact -- opcode caching may be great for performance, but key/value caching really doesn't matter. Wedge/SMF don't do enough cache requests to see a difference (at most a dozen on regular pages). At least on my setup...

Pandos

  • Living on the edge of Wedge
  • Posts: 635
Re: Support for PECL Memcached
« Reply #11, on October 31st, 2013, 03:47 PM »
OK, removing then makes sense.
Fun fact that SMF will approve all modifications? OK, no more words to say... :)

I'm using memcached in a wide range of things. Not only for SMF. So if Wedge/SMF never really make use of memcached, it doesn't matter to remove support for memcached entirely. View bytes less :)

Dunno if memcached is ported to windows. Don't think so.



Nao

  • Dadman with a boy
  • Posts: 16,079
Re: Support for PECL Memcached
« Reply #12, on October 31st, 2013, 06:51 PM »
Quote from Pandos on October 31st, 2013, 03:47 PM
OK, removing then makes sense.
I didn't technically remove it, as it wasn't in the codebase to begin with... ;)
It *is* in the SMF 2.1/ElkArte codebases (from a SMF 2.1 commit by Spuds), which is where I went to 'check' went I hit a bump during the caching rewrite. I was surprised that he'd do that even if no documentation existed for it.
So I figured, I'd probably better use the Memcached:: object, but then I tested memcached locally, and found it didn't really help performance (not as memcache vs no-cache, but as memcache vs file-based cache). So, it really wasn't worth much of my attention, in the end. I was even tempted to remove all caching except for the file cache. But keeping it all doesn't cost anything, so, whatever...

I noticed today, though, that SMF 2.1 also gives the ability to choose the cache library for use, so you can stick to file cache even if APC is present. Interesting.
Quote
Fun fact that SMF will approve all modifications? OK, no more words to say... :)
Sorry..?
Quote
Dunno if memcached is ported to windows. Don't think so.
memcached (the server) is, but php_memcached (the extension) isn't. php_memcache is, though, and it's what I've been using for my tests.