Announcement

Collapse
No announcement yet.

"Guru" question about mvt:do

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    "Guru" question about mvt:do

    When a template executes an mvt:do into another script repeatedly, does the VM have to reload the script from disk every time?

    I'm looking at an application where I need to write a template with an mvt:call, and do some pretty complex processing on the received data. Instead of writing 90 lines of SMT code inside the mvt:call, I thought I might just put an mvt:do in the body of the mvt:call, and the complex processing can be done by a function in a module. But it occurred to me that that might be very slow, because the template would execute the mvt:do for every tag in an XML feed. What say ye, gurus?

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    I don't think it's clear what you're needing to do except for the MVT:DO portion. I think that function call probably won't be cached and will run from the FILE called. I think I agree with your assumption. Maybe the solution is to offload as much as possible into a module component and make those functions part of the module to avoid the MV:DO in that case. Might be more work but those XML Feed tag functions would probably have been already loaded with the module in memory.

    Scott
    What help do you need today!
    Interactive Design Solutions http://www.southbound.com
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    My T-shirt Collection is mostly MivaCon T-shirts!!
    Competitive Rates, Popular Modules, and Integrations:
    Product Copy | AutoBaskets | Waitlist Integration| Wholesale Integration

    Comment


      #3
      Miva Please correct me if I'm wrong.

      The mvt:do is called within the current VM session just like calls that are made within your external function that call other functions.
      Of course, if you use MvCALL to call an external function, then Yes another VM is loaded.

      I have done the same thing you're suggesting many times for the same reasons.
      To your original question about speed, there is a measurable boost but probably not overwhelming

      The compiled code from the template compiler is a subset of the full compiler and runs at, in my experience, very similar speeds.
      Using a template gives you access to all the items and modules, while using external functions gives you access to <MvCommands> unavailable to the template. The main downside to this approach is maintaining the code for years to come or you can provide the source to the client.

      As for creating an component, it's a very valid way to go, especially if you want to automate installation. If not, a seperate file of functions, is faster to impliment
      Depends in the budget and time available.
      Ray Yates
      "If I have seen further, it is by standing on the shoulders of giants."
      --- Sir Isaac Newton

      Comment


        #4
        Sorry, I didn't explain the project in enough detail. I have a client who wants to import product data from a bunch of different servers, using different formats for the requests and replies. Instead of hard-coding them all, I thought I might write a template-based module, where each feed would have one template to generate the request, and another to process the reply.

        There are a number of technical problems associated with this, which is why I may end up putting an mvt:call in the receiving template, instead of writing an MvCALL in the module itself. The body of the mvt:call will have the same code on every template, which is why I thought of writing that part into the module, and having the templates call it with mvt:do. It occurred to me that the overhead of executing an mvt:do for every XML tag might be very slow, not to mention stressing the hard drive with thousands of reads of the same file. But if the system has some sort of RAM cache for frequently-used files, then maybe this won't be a problem?

        Thanks --
        Kent Multer
        Magic Metal Productions
        http://TheMagicM.com
        * Web developer/designer
        * E-commerce and Miva
        * Author, The Official Miva Web Scripting Book -- available on-line:
        http://www.amazon.com/exec/obidos/IS...icmetalproducA

        Comment


          #5
          I now picture a cork poster board with push pins and different color thread connecting all the pins together. :)

          This won't be running real-time, would it? Seems like this process would be more suited to running as a cron or scheduled task and it stuffs the data your after into a container that can be loaded quickly when requested on the front side. We're starting to use this technique more and more to help with page speed.

          Scott
          What help do you need today!
          Interactive Design Solutions http://www.southbound.com
          MivaMerchant Business Partner | Certified MivaMerchant Web Developer
          My T-shirt Collection is mostly MivaCon T-shirts!!
          Competitive Rates, Popular Modules, and Integrations:
          Product Copy | AutoBaskets | Waitlist Integration| Wholesale Integration

          Comment


            #6
            I sometimes visualize my code as a factory, with data flowing in pipes from one storage tank to another, or packed in boxes and moving around on conveyor belts :^) .

            Yes, it's a complex setup, but I've used templates in this way before on other projects, so this is not a big stretch for me. I thought of using a cron job or Miva scheduled task, but the client says they will run it manually for now. The data being downloaded is basic stuff like product prices, descriptions, image URLs, etc, so it makes sense to just write it all into the appropriate fields as soon as it's downloaded.

            Thanks --
            Kent Multer
            Magic Metal Productions
            http://TheMagicM.com
            * Web developer/designer
            * E-commerce and Miva
            * Author, The Official Miva Web Scripting Book -- available on-line:
            http://www.amazon.com/exec/obidos/IS...icmetalproducA

            Comment


              #7
              Sorry I should not post after midnight:( I read, "does the VM have to reload" and failed to understand "the script from disk every time?" )

              I'm almost sure the operating system will cache the external .mvc file if it's being called repeatedly.

              I'd probably do as you say, place the MvCALL in the external function file.
              Ray Yates
              "If I have seen further, it is by standing on the shoulders of giants."
              --- Sir Isaac Newton

              Comment

              Working...
              X