Talk:Requests for comment/Magic expressions

About this board

MaxSem (talkcontribs)
Sandboxing
This extension does not strictly enforce execution time or memory consumption. Ersatz measures like loop length restriction can't control memory usage and you'll have to infinitely play cat'n'mouse with attackers WRT execution time.
Existng user base
Scribunto is widely used by Wikimedia and its reusers and has a shitload of existing code. Can't say that about your solution.
Performance
"10 times slower than PHP" is not good.
Modularity
Scribunto makes a special emphasis on reuse, forcing users to write modules. PhpTags just spills code in wikitext.
Reinventing the wheel
Scribunto uses an established language and its code base. PhpTags invents its own dialect of PHP.

Taking all of the above into consideration, I have to ask: what's the intended goal of this RFC? If the goal is to run it on WMF I don't need to be an architect to predict the obvious "no". If the goal is to use it somewhere, why submit an RFC here? Just do it:)

Pastakhov (talkcontribs)

Thank you very much for your reply.

Sorry, I misunderstood the purpose of RFC.

Performance
Magical expressions solve the problem of performance magic words. Scribunto doesn't. Scribunto shifts the problem from blame on others.
Modularity
I think that Scribunto pushes users to rewrite mediawiki for LUA, and PhpTags forcing developers to write the universal reusable extensions.
Reinventing the wheel
I did not invent. I found a cheap way to limit the movement of the wheel. I agree, the wheel on the rails looks weird. And this is also not my invention.

Maybe you'll answer again, I would be more thankful.

Can Mediawiki core strictly enforce execution time or memory consumption? In any case, can you provide a link to information for learning how MediaWiki prevents the DoS attacks?

Anomie (talkcontribs)

Your claims about "solving the problem of performance magic words" doesn't make much sense. How does your proposed extension not also "shift the problem from blame on others"?

As for actual performance, have you compared your extension with an equivalent Scribunto module using luasandbox? On my laptop (Thinkpad T430, core i5 2.60GHz, 4G RAM, PHP 5.5.9), pure PHP took about the same (0.034s) to run your "100000 loops" example while Scribunto took only 0.008s. I also increased it to 100000000 loops, and there pure PHP took 16.2 seconds compared to Scribunto's 5.8s.

MediaWiki core limits execution time and memory consumption by having a lot of smart people reviewing code before it's deployed, and by monitoring actual usage, and by not allowing random people to embed arbitrary code in wiki pages. Scribunto in luasandbox mode limits execution time and memory consumption by counting every malloc and checking the time used at each Lua instruction, and in luastandalone by setting ulimits on the external process.

I agree with MaxSem: If you're making this RFC to try to get this deployed on WMF sites, it seems unlikely to succeed. And if you're wanting to use it somewhere else, just do it.

Pastakhov (talkcontribs)

Thanks for the feedback, it is important for me.

Every medal has two sides. LUA runs loops faster PHP, it is excellent, but this does not mean that LUA faster and better PHP in everything.

The magic words are uncomfortable and very slow when they are expressions.

{{ #vardefine: r | 0 }}{{ #vardefine: i | 0 }}{{
  #while:
  | {{ #ifexpr: {{ #var: i }} < 100 | true }}
  | {{ #vardefine: i | {{ #expr: {{ #var: i }} + 1 }} }}
    {{ #vardefine: j | 0 }}
    {{
      #while:
      | {{ #ifexpr: {{ #var: j }} < 1000 | true }}
      | {{ #vardefine: j | {{ #expr: {{ #var: j }} + 1 }} }}
        {{ #vardefine: r | {{ #expr: ({{ #var: r }} + ( {{ #var: i }} * {{ #var: j }} ) % 100 ) % 47 }} }}
    }}
}}

I'm sure it will take more than 10 hours.

What is Scribunto? It is a way to replace the slow expressions of magic words to one new word in which the expressions are very fast. WMF sites has only a very slow expression of magic words or very fast expression in LUA.

Can WMF sites completely abandon expression of the magical words? If yes then magic expressions is not necessary.

What is magic expressions? It is a way to make expression of magic words faster. There is a huge gap between expressions of magic words and LUA, and magic expressions is compromise. Magic expressions can be easy and fast enough.

What is LUA? LUA is a fast hare, compared with the slow turtle magic expressions. Can Turtle beat the hare? Using brute force, does not. Using the mind it is perhaps. (*mind of PHP and MWF developers)

Do WMF sites need magical expression? I can not know. Maybe yes or maybe there is another solution except Scribunto. I know there are a lot smart people and they can make magic expressions better and faster than I can. so I do not want to waste my time.

For me PhpTags solves another problem, but I saw that it could be useful for WMF sites too. Perhaps this idea seems too stupid, probably because it is. We must never be absolutely sure in everything.

MaxSem (talkcontribs)

This discussion looks stale - so can you clarify what exactly are you seeking with this RFC?

Pastakhov (talkcontribs)

Thank you for continuing the discussion, otherwise it was like a monologue.

Initially I searched an opportunity to make more versatile MediaWiki extension that would make it possible to reuse the same code in different variations. I also wanted to get rid of complicated structure templates. I made a working model applications and then I was started optimize the performance. I have achieved to reduce the cost of operations to 0.000015 seconds. This is fast enough and allows it to compete even with LUA.

I understand that it is meaningless in terms of brute force. But the LUA is not intended for use in such a way that it is used here. LUA is designed for building structures made of blocks that are written on "C". In the same way my solution is designed for building structures made of blocks that are written on PHP (MediaWiki extensions).

Using this RFC, I would like to know if there are already similar solutions, are there any circumstances that make this solution meaningless. For example it was decided to rewrite the whole MediaWiki on "C" and use LUA as the top level.

Now I have a small benchmark performance of my solutions and LUA. With LUA was spent the CPU time more than doubled. Full details here.

Whym (talkcontribs)

Reusability of codes might not always be a good thing. It sounds against the ideas of loose coupling and encapsulation. In many situations, if you want to perform the same function in different places, I would expose it as an API in one central place and let others use it.

Pastakhov (talkcontribs)

Magic expression allow you to create loose coupling between extensions, it acts as a mediator. Extensions can be as libraries and can be used for solving various tasks, and will not have to write the same code in different extensions. I had this in mind.

Reply to "So what's the point?"
There are no older topics