WordPress.org

Make WordPress Mobile

Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • Jorge Bernal 12:26 pm on June 6, 2013 Permalink | Log in to leave a Comment  

    XML-RPC memory improvements 

    I’ve been looking into #21098 since yesterday, trying to figure out how to minimize out of memory errors on media uploads through XML-RPC. Results were a bit unexpected, but interesting nonetheless. Any ideas on how to reduce memory usage are more than welcome.

    I’m still not sure where all the memory goes, for instance a 1MB file upload takes 50M of memory, while a 10M file takes 153M. The base64 encoding represents just a 33% overhead, so that’s not it. Also, it seems that even if you disable $HTTP_RAW_POST_DATA, php keeps the whole POST body in memory, but still, that’s a lot of memory to account for.

    Fix #1: read from php://input directly

    After a lot of playing with xdebug, IXR_Message->parse() didn’t look too efficient, so I tried https://gist.github.com/koke/5720860.

    The current implementations relies a lot on substr, which works fine for smaller requests, but not so much on media upload. After some early testings, my solution seemed to require a bit more memory on small requests, but then performed much better as request size increased.

    How did I test

    I added this plugin (xmlrpc-test-upload.php), which adds a new wp.testUpload method: it replicates metaWeblog.newMediaObject, but it also returns peak memory usage. I had some problems with integer overflows so I ended up using the values output to the error log.

    Then did a quick client on test.php and created a bunch of blank videos with file sizes from 1 to 200 mb. For instance, to get a ~1MB video:

    
    ffmpeg -t 32 -s 1280x720 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero -y test-1M.mpg
    
    

    Memory results

    The memory reductions weren’t as good as I expected, but still worth a try

    Peak memory usage
    File size (MB) Baseline php://input Reduction
    1 50M 49M 2.09%
    2 61M 58M 4.31%
    5 94M 88M 6.96%
    10 153M 139M 9.08%
    50 649M 580M 10.63%
    100 1267M 1129M 10.87%
    200 2503M 2228M 10.99%

    xmlrpc-phpinput-memory

    Time results

    After some trial/error process while running the tests, I did notice the new version felt faster, so I tested for that as well. Results were more pleasing this time:

    Response time (s)
    File size (MB) Baseline php://input Reduction
    1 0.189 0.197 -4.30%
    2 0.228 0.202 11.41%
    5 0.330 0.282 14.34%
    10 0.620 0.414 33.34%
    50 5.48 1.26 76.92%
    100 18.93 2.34 87.66%
    200 93.23 5.39 94.22%

    xmlrpc-phpinput-time

    What’s next

    Even after this, I’m not sure yet where most of the memory goes. Running a xdebug trace on the new code, with a 200MB file upload:

    • When xmlrpc.php is called, xdebug already reports a memory usage of 786MB.
    • Once WordPress is initialized and IXR_Server->serve() is called, memory usage is 1083MB.
    • Just before IXR finishes parsing, it reaches peak memory usage at 1607MB.
    • At the end of execution memory usage is 1345MB.

    I’ve uploaded the xdebug trace (trace-200.txt) in case someone else can spot another improvements.

     
    • daniloercoli 12:52 pm on June 6, 2013 Permalink | Log in to Reply

      PHP always populates the variable $HTTP_RAW_POST_DATA on POST requests with “text/xml” content-type. Even if you set the directive always_populate_raw_post_data to Off, PHP populates that variable. The only exception are requests with content-type of “application/x-www-form-urlencoded” or “multipart/form-data”. I investigated more, and seems that there isn’t a simple way to get rid of $HTTP_RAW_POST_DATA without modifying the PHP src code and recompile it.

      I’ve also wrote a plugin that does the following:

      • Gets the php input stream (php://input)
      • Reads from the input stream, and parse the content by chunck (Get rid of $HTTP_RAW_POST_DATA).
      • Doesn’t store any partial values, or the final parsed value, in memory. It uses a tmp file in the tmp directory (Only for base64 data).
      • Changes the function mw_newMediaObject to use a path to the input file on disk rather accept the whole content as parameter.
      • Introduces a new function that copy the uploaded file to the right location.

      https://github.com/daniloercoli/WordPress-streaming-xml-rpc

      • Jorge Bernal 1:49 pm on June 6, 2013 Permalink | Log in to Reply

        I tried setting application/x-www-form-urlencoded as well, but even if $HTTP_RAW_POST_DATA was empty, memory usage was similar.

        I have the feeling that PHP stores the POST body in memory, unless it’s a “multipart/form-data” upload, so not sure if there’s really anything we can do there without switching to a different API.

        I’m trying to test your plugin, but I’m getting a problem opening the temp files

      • Jorge Bernal 2:11 pm on June 6, 2013 Permalink | Log in to Reply

        Tried with your plugin, and peaked at 1085MB (vs 1607MB) for a 200MB file. So that was a bit more efficient although a bit slower (9s vs 5s)

        But the interesting part is looking at the trace: when it starts, memory is already at 786MB, so it seems PHP is keeping everything in memory anyway.

      • Jorge Bernal 2:19 pm on June 6, 2013 Permalink | Log in to Reply

        More funny bits, if I set “Content-Type: multipart/form-data”:

        • Starting memory drops to 600KB
        • Peak memory drops to 36MB

        :o
        Cheating? I have to read more about the spec, but the file was uploaded successfully

    • Eric 1:13 pm on June 6, 2013 Permalink | Log in to Reply

      That is a huge improvement in response time! For large files anyway.

  • Eric 3:49 pm on June 5, 2013 Permalink | Log in to leave a Comment
    Tags: , , ,   

    Dev Chat summary for June 5, 2013 

    Chat log

    Agenda

    • WPiOS 3.6
    • WPiOS Reader status
    • WPAndroid beta
    • Windows Phone Upgrade

    WPiOS 3.6

    The latest release is going smoothly, and there have been no major issues thus far. Congrats to everyone who worked on the release and especially sendhil for all his effort coding up the NUX!

    We’ll plan on a 3.6.1 bug fix release to address some minor issues and other things unrelated to 3.6 specifically.

    WPiOS Reader status

    aerych and irbrad continue to make progress on the native reader – currently focused on reblogging and iPad improvements.  A beta this week was the goal but there is still a lot remaining and its looking like next week is more realistic.

    WPAndroid beta

    Welcome back mrroundhill :)
    A few bugs have been revealed during the beta period.   A release was planned for today but we’ll delay until Monday and squash the bugs instead.

    Windows Phone Upgrade

    Its time for a new iteration on the Windows Phone app. daniloercoli will be working on a small bug fix release addressing the top five bugs and also bring gallery support to self-hosted blogs.

    Next Week

    The next dev chat will be on June 12, 2013 at 15:00 UTC. Mark your calendar and join us in #wordpress-mobile on Freenode.

     
  • Isaac Keyet 3:41 pm on May 29, 2013 Permalink | Log in to leave a Comment
    Tags: , , , ,   

    Dev chat summary for May 29, 2013. Chat log

    Agenda

    • Android
    • iOS
    • Other Platforms
    • Mobile Handbook
    • GSoC Update

    Android

    The WPcom Notifications release is in Beta. Everybody with a Jetpack-enabled blog and/or a WordPress.com blog is encouraged to download it and help test it, as well as reporting any issues that arise.

    iOS

    NUX update has been submitted with a heap of languages at 100%! A lot of people have been involved in this release, most notably @sendhil, @hugobaeta, @koke, @karmatosed. It provides a much better first experience for all types of users, wether you have a blog already or you want to sign up. It’s also bringing the UI of the app up to par with the latest around the WP ecosystem, expect a lot of this to cross-pollinate to other parts of the app and other platforms as well.

    WPcom Native Reader update: last week we’ve focused on wrapping up the comment form, topics list, and a bunch of smaller functions. We’re hoping to release a basic Beta sometime next week but it may be pushed out a bit further.

    In other news a 3.6.1 is already being planned, and the work on better global Accounts for WPcom users will be merged as a part of the Native Reader update.

    Other Platforms

    Filing Windows Phone tickets for the next update, other than that not much going on on the other platforms we govern.

    Mobile Handbook

    I acknowledged the state of the Mobile Handbook in the chat, and let people know that our editor Rachel will be ready to review and edit content shortly. Everyone is urged to attend to the sections of he handbook that they’re assigned to. Eric mentioned that the state of the Android section in the handbook is looking pretty good, and that that may be a good place for Rachel to start looking at.

    The BlackBerry section is looking really good as well, and this may in fact be the best place to start.

    Mobile Handbook Todo.

    GSoC Update

    The selection process is over, and there will be two mobile Google Summer of Code projects this year.

    Native WordPress app for BlackBerry OS 10

    Daniele Maio will create native WordPress app for BlackBerry’s exciting new OS 10 platform. @daniloercoli will be mentoring.

    More info.

    FirefoxOS WordPress for webOS port

    Sayak Sarkar will port the fabled WordPress for webOS app to the FirefoxOS platform. @aerych will be mentoring.

    More info.

    Congrats guys!

    Next Week

    The next dev chat will be on June 5, 2013 at 15:00 UTC. Mark your calendar and join us in #wordpress-mobile on Freenode. The next two weeks @aerych will lead these chats and post the summaries.

     
  • Jorge Bernal 2:24 pm on May 28, 2013 Permalink | Log in to leave a Comment
    Tags:   

    Getting ready to submit WordPress for iOS 3.6, just waiting for some translations to be approved.

    Here’s what’s new:

    • A completely redesigned new user experience
    • A faster way to post: added shortcut on sidebar
    • Fixed a problem with Tumblr imported blogs
    • Emoticons now appear correctly on notifications
    • Performance improvements for notifications

    Did I miss something?

     
  • Isaac Keyet 8:56 pm on May 26, 2013 Permalink | Log in to leave a Comment
    Tags: , ,   

    Here’s the belated dev chat summary from last Wednesday (sorry about the delay!)

    Chat log.

    Agenda

    • Android Beta & What’s Next
    • iOS NUX/Accounts

    Android Beta & What’s Next

    The beta was delayed a week since some parts of the apps were not done. New submit/announce date should be June 3.

    iOS NUX/Accounts

    iOS NUX is almost done (again!), translations are synced back up and most are complete. Looks like we’ll be able to submit soon. [editor's note: as of Friday the plan is to submit by EOD or Monday]

    iOS Accounts release will most likely be bundled with the new WordPress.com Reader update which should be the next one to be released after NUX.

    Next Week

    The next dev chat will be on May 29, 2013 at 1500 UTC. Mark your calendar and join us in #wordpress-mobile on Freenode.

     
  • Dan 10:35 pm on May 24, 2013 Permalink | Log in to leave a Comment
    Tags:   

    Android 2.4 Beta: Notifications 

    Screen Shot 2013-05-24 at 2.36.55 PM
    Looking for something to do this weekend? Version 2.4 of WordPress for Android is ready for testing. This release adds an all-new notifications view as well as integration with Google Cloud Messaging so that you can get notified as soon as something happens on your blog.

    We’re looking for a few brave folks to try this out. Keep in mind that it is beta software. To take advantage of the new notifications feature, you’ll need to have a site at WordPress.com or be running the Jetpack plugin on your self-hosted site. You can find the WordPress.com sign in on the Settings page of the app.

    We’ve also added some smaller new features as well:

    • Added new menu button that conforms to the new Holo guidelines for menu drawers announced at Google I/O last week.
    • Moved settings and sign out option to overflow menu

    After you install the update and are signed in to WordPress.com you should start receiving notifications when stuff happens on your site. You can leave an anonymous comment on your blog to test it out if you aren’t getting much traffic at the moment :)

    Please give it a try and comment here if you have any issues or suggestions!

    2.4 Beta APK: http://bit.ly/172QxOy

    Lastly, GLaDOS approves of this effort:
    Screen Shot 2013-05-24 at 2.36.27 PM

     
  • Eric 3:58 pm on May 15, 2013 Permalink | Log in to leave a Comment
    Tags: , , , git, ,   

    Dev Chat Summary for May 15, 2013 

    Several of the team were out at Google IO this week so we filled in the gaps as we were able. Chat log.

    Agenda

    • iOS
    • Android
    • WInPhone and BlackBerry
    • Git

    iOS

    • Accounts is nearly complete. Needs more testing but we’ll hold off until NUX is ready.
    • NUX is currently being tested and awaiting updated translations.
    • Progress continues on the native reader. Support for adding/replying to comments is underway and irbrad is joining the effort.

    Android

    The notifications release is currently in beta and very close to releasing. We haven’t decided what’s next but NUX is high on the list.

    WinP and BlackBerry

    BlackBerry is currently reviewing an update sent Monday, May 13th, and we expect it to be live in the store this week. This is basically version 2.3.3 of the Android app with some minor changes. The code is in the BlackBerry branch of the Android repository.

    A Windows Phone update was submitted Tuesday. This update addresses an issue with the sharing feature. We expect it to be live later today or tomorrow.

    Git

    We’ve been having some trouble with the git repository at ios.git.wordpress.org getting out of sync with our git checkouts and the mirror on github.com. The repositories have had trouble staying in sync and most recently the commit authors have been reset and no longer match. We suspect the culprit is the subgit software that manages syncing between the svn and git repositories hosted on wordpress.org.

    We discussed possible options:
    A) Give subgit one last try.
    B) Drop svn and make ios.git.wordpress.org the official repository, mirrored to github.
    C) Make the repository on github the official repo.

    We talked it over and decided the best course of action is to sunset the svn repo in favor of git. We will correct the repository at ios.git.wordpress.org and it will become the official repo for WPiOS with a two way mirror to github.

    Next week

    The next dev chat will be on May 22, 2013 at 1500 UTC. Mark your calendar and join us in #wordpress-mobile on Freenode.

     
  • Isaac Keyet 4:34 pm on May 8, 2013 Permalink | Log in to leave a Comment
    Tags: , , , ,   

    Dev chat summary for May 8, 2013 

    Chat log.

    Agenda

    • iOS projects update
    • Android projects update
    • Moving dev blog discussions to make/mobile (this blog)
    • Handbook reminder

    iOS projects update

    NUX (new welcome guide, improved WordPress.com sign up) is almost complete, need to look over copy and polish a few things, then should be ready to get it translated and tested.

    WordPress.com native reader project: picking up momentum again, currently working on threaded comments which is complicated.

    Accounts migration: need to write the actual core data migration but very close to completion. Should simplify the way WordPress.com accounts act under the hood in the iOS app.

    Android projects update

    A bug fix update is going out today that fixes a bug with featured images.

    The WordPress.com Notifications project is very close to beta, no word on when just yet but should be very soon.

    Moving dev blog discussions to make/mobile (this blog)

    We decided to close the dev blogs and (if possible) migrate their data to this blog instead and keep all discussions/announcements/etc in one place. The filtering on this p2 should make it easy to only see discussions about specific platforms if you only contribute to one. @mrroundhill took it on himself to investigate what’s needed for migrating the data. @isaackeyet (me) will look into a way to display sticky messages on the dev blogs once migrations are complete. The platform leads for each platform will also post a last post on each one of the dev blogs letting subscribed readers know that the blog has been merged with make/mobile (this would be @mrroundhill, @koke, and @daniloercoli for BlackBerry and Windows Phone).

    After the chat @nacin jumped in and let us know he will assist with the migrations as well.

    Handbook reminder

    @aerych reminded himself and all others that the Handbook is still in need of looking over and updating – please refer to the separate todo post for details on what’s left and who’s responsible for what.

    Other

    @daniloercoli let everybody know that there’s a new bug fix update live for Windows Phone. It has bug fixes as well as a small new feature that lets users share permalinks to other apps on the device (such as Email, Facebook, Twitter, etc).

    Next week

    The next dev chat will be on May 15, 2013 at 15:00 UTC. Mark your calendar and join us in #wordpress-mobile on Freenode.

     
  • Eric 4:02 pm on May 1, 2013 Permalink | Log in to leave a Comment
    Tags: , ,   

    Dev chat summary for May 1st 2013 

    We had a short chat this week as several of the team were out due to travel, etc. Chat log.

    Agenda

    • iOS : status
    • Android : status

    iOS : status

    Continuing to make progress on our main fronts but there is still lots to do before we’re ready to ship new features — at least a couple more weeks.

    • Accounts: working through some of the issues with self-hosted vs .com blogs.
    • NUX: currently working on the wizard.
    • Reader: improvements to the detail view and starting support for comments.

    Android : status

    Shipping version 2.3.2 today. Details.
    Continuing to make progress on Notifications. Pushing the beta out to next week as there is more work to do.

    Next week

    The next dev chat will be on May 8, 2013 at 1500 UTC. Mark your calendar and join us in #wordpress-mobile on Freenode.

     
  • Isaac Keyet 9:11 am on April 30, 2013 Permalink | Log in to leave a Comment
    Tags: , , ,   

    To make it even more inviting to contribute and kick-start great patches I added two buttons in the sidebar that are direct links to the GitHub repos for the iOS and Android projects. Hopefully this, with some updates to the mobile handbook should make it a lot less intimidating to actually start contributing.

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel