H2o: When is qrintf used?

Created on 21 Nov 2017  路  2Comments  路  Source: h2o/h2o

https://www.slideshare.net/kazuho/h2o-20141103pptx

The developer says that 'h2o server' is fast using qrintf as I see ppt.

sprintf parses at runtime,
qrintf parses at compile time.
So qrintf is fast.
Conceptually, I understand.
When do you use it?
Only when returning ip4 address as string?

Then I do not understand.
Is not the web server already run-time after compilation?

In other words, my question is
When is qrintf used?
And
Why is qrintf fast?

There are two.

Most helpful comment

Hi @voiddeveloper ,

I am looking at h2o for the first time, so take my reply with a grain of salt.

TL;DR: https://github.com/h2o/h2o/search?l=C&q=sprintf&type=&utf8=%E2%9C%93

As described in https://github.com/h2o/h2o/issues/796, qrintf is simply a compile-time optimization of sprintf-calls. Once specified as compiler option, it analyzes and replaces certain tags, such as:

%c
%s
%d (modifiers: h, l, ll)
%u,%x,%X (modifiers: h, l, ll, z)

Source: https://github.com/h2o/qrintf

From what I grasp of it, it basically analyzes the "format" part of the string at compile-time, so it'll be able to insert the parameters quicker on run-time (because it already "knows" where to put them).

All 2 comments

Hi @voiddeveloper ,

I am looking at h2o for the first time, so take my reply with a grain of salt.

TL;DR: https://github.com/h2o/h2o/search?l=C&q=sprintf&type=&utf8=%E2%9C%93

As described in https://github.com/h2o/h2o/issues/796, qrintf is simply a compile-time optimization of sprintf-calls. Once specified as compiler option, it analyzes and replaces certain tags, such as:

%c
%s
%d (modifiers: h, l, ll)
%u,%x,%X (modifiers: h, l, ll, z)

Source: https://github.com/h2o/qrintf

From what I grasp of it, it basically analyzes the "format" part of the string at compile-time, so it'll be able to insert the parameters quicker on run-time (because it already "knows" where to put them).

Thank you for kindly explaining. I understood why it was fast.
However, I do not know when this method is used.
Do you know anything about it?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wujunjenny picture wujunjenny  路  5Comments

Ys88 picture Ys88  路  5Comments

kazuho picture kazuho  路  7Comments

ndac-todoroki picture ndac-todoroki  路  5Comments

basbebe picture basbebe  路  3Comments