Using GNU Readline in QtScript

September 14, 2008 on 11:58 pm | In General, software-dev | 1 Comment

The past few weeks i’ve been delving pretty deeply into QtScript, which is essentially a JavaScript engine based on Qt (and part of the Qt distribution).

Today i threw together a little goodie for QtScript which allows one to use GNU Readline-like functionality from scripts. The code is at:

http://code.google.com/p/qboard/source/browse/QtScriptBindings/src/readline/

Just tweak the .pro file (to change the output path), then follow the instructions in the README file.

A quick demonstration of how to use it:

First, load the module into your app:

myJSEngine->importExtension("readline");

Then use it from script code:

Readline.history.load("/path/to/my/history/file");
var s = Readline.read("prompt: ");
if( s === undefined ) { /* user tapped Ctrl-D/EOF */ }
else { print(s); }

That’s all there is to it.

Happy hacking!

Tip: speeding up s11n client compile times

September 2, 2008 on 12:57 pm | In libs11n | 1 Comment

As i’ve written in the past few blog entries, as part of the QBoard project i’ve been working on s11n proxies for serializing a variety of Qt types. That application has helped stress a lesson which i actually learned a long time ago, but had forgotten what an impact it makes. It potentially affects all s11n clients, so i thought i’d share it…

Two days ago, QBoard needed about 70 seconds to compile using parallel compilation on a dual-processor machine. After refactoring the s11n support a bit (as explained below), it now takes about 40 seconds. The extra 30 seconds were due 100% to libs11n, and we’ll see why below…

Any user of libs11n is probably familiar with the registration of s11n proxies. In its simplest form it looks like this:

#include <s11n.net/s11n/proxy/pod/int.hpp>

That registers the “int” type as a first-class Serializable. More commonly, for client-side types a registration looks like:

#define S11N_TYPE QVariant
#define S11N_TYPE_NAME "QVariant"
#define S11N_SERIALIZE_FUNCTOR s11n::qt::QVariant_s11n
#include <s11n.net/s11n/reg_s11n_traits.hpp>

That registers a proxy for QVariant.

That registration process does several things:

  • Sets up a class template specialization for the client-specified type, such that calls to s11n::de/serialize(…,ThatType) will go through the appropriate API (in the above case, the QVariant_s11n functor).
  • Sets up a classloader registration, so that deserializing of pointers can be done polymorphically. (That is actually the only reason in the world why libs11n has to associate a class name with types. For types which never get deserialized by pointer, this registration is never used!)
  • There’s something else here which is slipping my mind at the moment.

In any case, the registration process is not (internally) 100% trivial, though the client has only to include a header file.

A registration must be visible to all client code which attempts to de/serialize that type, or else de/serialization will not work (that’s not true for some special cases, actually). This normally means including it in a common header file, and that’s where we hit our problem…

A registration creates several template specializations which the client will never see, but which nonetheless must be created by the compiler in order for s11n to do its work. That create happens in every client file which includes the registration, and can take a measurable amount of time per registered type (some experiments have shown a bit over 1 second per registered type!).

In the case of QBoard, we currently have registrations for almost 30 Qt types. Until a couple days ago, those registrations were all in a single header file which was included by all clients which wanted to de/serialize Qt types.

In the interest of a cleaner build tree, i split up the monolithic header into one header per serialized type, and then went back and updated the client code to only include the headers they needed. After doing so, the total build time was cut from about 70 seconds to about 40 seconds. The 30 extra seconds were taken up solely with the compilation of the s11n registration code.

So, the lesson is: try to give your s11n registrations the lowest visibility possible. Everywhere they are visible, they will be compiled, and where they are compiled they will take an observable amount of time to do so. In some cases it is possible to encapsulate all s11n-related calls into a small number of implementation files, invisible to the majority of the client code. The speed benefits of doing can be worth it. Consider, for example, if you save 30 seconds per build (as QBoard did), and it takes 30 minutes of work to refactor the registrations, then it will only take 60 compilation runs to win that time back. If you follow this lesson from the start, as opposed to refactoring later, you’ll get even more time benefits (because you obviously save the refactoring time).

Have fun, and happy hacking!

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^

  • Buy Cheap buy levitra on-line Now Top Online Pharmacy Supplier. Best Prices.
  • Buy Cheapest how to get cialis from your doctor Now Best Internet. Buy Medications Online.
  • Buy Cheapest how to buy pfizer viagra online Now Low Prices. 24/Internet)(safe Pharmacy.
  • Buy Cheap buy best generic cialis jelly tablets without a prescription Now No Prescription Needed. Online Medical Shop.
  • Buy Cheap nootropil Now Guaranteed Shipping. No Prescription Needed.
  • Buy Cheap generic viagra without a prescription Now Cheap Online Pharmacy. Cheap Pharmacy Online.
  • Buy benefits viagra men Online Without Prescription. Pharmacy At The Best Price!
  • Buy Cheap levitra usa today Now Buy Medications Online. Guaranteed Shipping.
  • Buy Cheap viagra rx medstore Online Top Online Pharmacy. 24/Online Pharmacy.
  • Buy generic cialis review Online Without Prescription. Low Prices. Pharmacy Store.
  • Buy Cheapest store buy viagra plus online cheap Online Best Drugstore. 24/Online Pharmacy.
  • Buy Cheap levitra coupon Online Pharmacy Store. Buy Medications Online.
  • Buy Cheap sex ed levitra Online Best Online. Order Cheap Meds Without Rx.
  • Buy Cheap piracetam pharmacy online Now No Prescription Needed. Free Viagra Pills!
  • Buy Cheapest enzyte side effects Online Buy Drugs Online No Prescription Needed.
  • Buy Cheap generic viagra best price Now No Prescription Needed. Pharmacy Store.
  • Buying Cheapest bayer levitra samples. Mexican Rx, Best Prices. Free Viagra Pills!
  • Buy Cheapest viagra torte Online Buy Medications Online. Best Drugstore.
  • Buy Cheap buy without a prescription viagra soft Online Pharmacy Store. Top Online Pharmacy.
  • Buy Cheap viagra uk cheap Now No Prescription Needed For Drugs. Best Prices.
  • Buy Cheap cialis drug interaction Online WorldWide Shipping. Buy Medications Online.
  • Buy Cheap viagra substites Now Cheap Online Pharmacy. Online Medical Shop.
  • Buy Cheap viagra statistique Online Best Drugstore. Cheap Online Pharmacy.
  • Buy Cheapest cialis tv ads Now Order Cheap Meds Without Rx. Best Internet.
  • Buy Cheap generic drug fraud viagra Online Low Prices. The Largest Internet Pharmacy.
  • Buy Cheap hur skaffa viagra Now Best Internet. Order Cheap Meds Without Rx.
  • Buy Cheap coupons for cialis Online Discount Online Pharmacy. Low Prices.
  • Buy Cheapest nootropil and alcohol Now Best Online. Drugs, Health And Beauty.
  • Buy Cheap libros online viagra Online Online Prices For libros online viagra! Best Online.
  • Buy how to get doctor to prescribe cialis Online Without Prescription. Best Internet. Low Prices.
  • Buy Cheapest cost of levitra at walmart Online Buy %items% Online Without Prescription.
  • Buy Cheapest cialis fda approved Online Top Online Pharmacy. Pharmacy Store.
  • Buy Cheapest canadian levitra plus online cheap Online 24/Online Pharmacy. Low Prices.
  • Buy Cheapest how often can viagra be taken Now Best Drugstore. Top Online Pharmacy.
  • Buy Cheap piracetam daily dosage Online Low Prices. Safe And Secure Payment System.
  • Buy Cheap tips on viagra use Now All Medications Are Certificated! Best Prices.
  • Buy Cheapest cialis men's reaction Now Free Viagra Pills! Cheap Pharmacy Online.
  • Get viagra chest Without Prescription Consultation. 24/Online Pharmacy.
  • Buy Cheap does medicaid cover viagra new york Online Discount Pharmacy Online. Low Prices.
  • Buy Cheapest viagra fra england Now Discount Online Pharmacy. Best Internet.
  • Buy Cheapest viagra experiences first time Online Best Online. Cheap Online Pharmacy.
  • Buy Cheap purchase cialis soft from canada Online Low Prices. Special Prices For purchase cialis soft from canada!
  • Buy Cheap recreational viagra use hiv Now Top Online Pharmacy. Discount Online Pharmacy.
  • Buy Cheapest sun a condom Online Best Prices. Cheap Prescription Drugs.
  • Buy Cheap buy cheapest viagra soft tabs Now Pharmacy Store. Buy Medications Online.
  • piracetam chemist online Online Without Prescription Best Prices. Best Online.
  • Buy Cheapest online buy viagra soft tabs without a prescription Now Cheap Pharmacy Online. WorldWide Shipping.
  • Buy Cheap does generic cialis work Online 24/Online Pharmacy. Pharmacy Store.
  • Buy Cheap online buy viagra soft tabs without a prescription Now Best Internet. Internet Prices For online buy viagra soft tabs without a prescription!
  • Buy Cheapest tadalafil canadian pharmacy Online Online Medical Shop. Best Drugstore.
  • Buy Cheapest viagra supplier Now Low Prices. Safe And Secure Payment System.
  • Buy Cheap buy nootropil tablets online Now Drugs, Health And Beauty. Online Medical Shop.
  • Buy Cheap cialis nova scotia Now Online Medical Shop. Drugs, Health And Beauty.
  • Buy Cheap online pharmacy warnings Now Best Prices. 24/Internet)(safe Pharmacy.
  • Buy Cheap liquid viagra drink blue Now Special Prices For liquid viagra drink blue! WorldWide Shipping.
  • Buy Cheapest buying generic viagra aruba Now Buy Medications Online. WorldWide Shipping.
  • Buy Cheapest cheapest cialis generic Online Best Internet. Online Medical Shop.
  • Buying Cheap cialis testimonial. Offshore Pharmacy, Good Prices. Best Internet.
  • Buy Cheapest levitra online no prescription Now Best Prices. 100% Satisfaction Guaranteed.
  • Buy Cheap lucetam chemist online Online Best Internet. Discount Online Pharmacy.
  • Buy Cheap piracetam pharmacy online Now Drugs, Health And Beauty. Online Medical Shop.
  • Buy Cheap success of cialis Now 24/Online Pharmacy. Top Online Pharmacy.
  • Buy Cheapest viagra 50mg 4 pack Online Best Internet. Discount Pharmacy Online.
  • Buy Cheap cialis men's reaction Now Online Medical Shop. Cheap Pharmacy Online.
  • Buy Cheapest piracetam effects Now Drugs, Health And Beauty. Best Online.
  • Buy Cheap cialis free sample no prescription Online Buy Medications Online. Best Drugstore.
  • Buy Cheapest legal buy viagra online Now Discount Online Pharmacy. Low Prices.
  • Buy Cheap is buying generic cialis online safe Online Best Internet. Online Prices For is buying generic cialis online safe!
  • Buy Cheap generic buy viagra soft tabs online cheap Online Online Medical Shop. Cheap Online Pharmacy.
  • Buy Cheap when to take viagra for fun Online 24/Online Pharmacy. Top Online Pharmacy.
  • Buy Cheap blood pressure viagra Now Discount Online Pharmacy. Pharmacy Store.
  • Buy Cheapest nootropil 1200mg and 800mg. piracetam drug Now Buy Medications Online. Best Prices.
  • Buy Cheapest buy viagra jelly from canada Now Special Prices For buy viagra jelly from canada! Pharmacy Store.
  • Buy Cheapest using viagra without ed Now Discount Pharmacy Online. Best Internet.
  • Buy Cheap cheap generic viagra overnight delivery Now Online Medical Shop. Cheap Prescription Drugs.
  • Buy Cheapest where to buy viagra toronto Online Best Prices. Cheap Prescription Drugs.
  • Buy Cheap side effects of levitra and alcohol Online Special Prices For side effects of levitra and alcohol! Low Prices.
  • Buying Cheapest does medicaid cover viagra new york. Mexican Pharmacy, Good Prices. Best Prices.
  • Buy Cheap buy nootropil canada pharmacies Now WorldWide Shipping. Drugs, Health And Beauty.
  • Buy Cheap trust viagra Online Drugs, Health And Beauty. Best Drugstore.
  • Buy Cheap buy levitra onlines Online Cheap Prescription Drugs. Best Drugstore.
  • Buy Cheapest trust viagra Now Low Prices. Discount Online Pharmacy.
  • Buy Cheap cialis marketing Online Guaranteed Shipping. Pharmacy Store.
  • Buy Cheapest cialis multiple orgasms Online Pharmacy At The Best Price! Low Prices.
  • Buy Cheapest discount viagra no prescription Online Best Online. Guaranteed Shipping.
  • can you buy viagra super active legally yes here online Online Without Prescription Pharmacy Store. Best Internet.
  • Buy Cheap viagra soft flavoured by mail order Online Order Cheap Meds Without Rx. Best Prices.
  • Buy Cheap bayer levitra samples Online Cheap Pharmacy Online. Free Viagra Pills!
  • Buy Cheapest bayer levitra samples Now Pharmacy Store. Cheap Pharmacy Online.
  • Buy Cheap levitra commercial Now Best Drugstore. Discount Online Pharmacy.
  • Buy Cheap buy lucetam mexican pharmacies Online Drugs, Health And Beauty. Best Online.
  • Buy Cheapest cialis nova scotia Online Best Drugstore. Online Medical Shop.
  • Buy Cheap does medicaid cover cialis Now Low Prices. Bonus Pills And Reorder Discounts!
  • Buy Cheapest levitra sales promotion Online Best Drugstore. Free Viagra Pills!
  • Buy Cheap viagra kaufen angebote Now Cheap Pharmacy Online. Buy Medications Online.
  • Buy Cheap generic viagra jelly Now Pharmacy At The Best Price! Pharmacy Store.
  • Buy Cheapest generic levitra canada pharmacy Now Best Online. Discount Online Pharmacy.
  • Buy Cheap buying generic viagra aruba Online Online Medical Shop. WorldWide Shipping.
  • ginseng natural Online Without Prescription Best Online. Best Prices.
  • Buy Cheapest sublingual viagra sans ordonnace Online Cheap Prescription Drugs. Low Prices.