Skip to content

Make logging an optional feature and disable it by default #2449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

akosthekiss
Copy link
Member

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]

@akosthekiss akosthekiss added the binary size Affects binary size label Aug 7, 2018
@akosthekiss
Copy link
Member Author

Results on binary size (and on RSS in consequence):

Benchmark RSS (bytes)
3d-cube.js 53248 -> 53248 : 0.000%
3d-raytrace.js 106496 -> 106496 : 0.000%
access-binary-trees.js 49152 -> 49152 : 0.000%
access-fannkuch.js 20480 -> 16384 : +20.000%
access-nbody.js 24576 -> 24576 : 0.000%
bitops-3bit-bits-in-byte.js 16384 -> 12288 : +25.000%
bitops-bits-in-byte.js 16384 -> 12288 : +25.000%
bitops-bitwise-and.js 12288 -> 12288 : 0.000%
bitops-nsieve-bits.js 110592 -> 110592 : 0.000%
controlflow-recursive.js 86016 -> 81920 : +4.762%
crypto-aes.js 65536 -> 61440 : +6.250%
crypto-md5.js 131072 -> 126976 : +3.125%
crypto-sha1.js 81920 -> 81920 : 0.000%
date-format-tofte.js 36864 -> 36864 : 0.000%
date-format-xparb.js 40960 -> 36864 : +10.000%
math-cordic.js 16384 -> 12288 : +25.000%
math-partial-sums.js 16384 -> 12288 : +25.000%
math-spectral-norm.js 20480 -> 20480 : 0.000%
string-base64.js 139264 -> 139264 : 0.000%
string-fasta.js 28672 -> 28672 : 0.000%
Geometric mean: +7.801%

Binary sizes (bytes)
1ac2903:132784
d60947a:130908

(~1.8k gain)

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good patch, but needs some improvements.

@@ -66,6 +67,12 @@ if(JERRY_CMDLINE_SNAPSHOT)
set(FEATURE_SNAPSHOT_SAVE_MESSAGE " (FORCED BY SNAPSHOT TOOL)")
endif()

if(FEATURE_DEBUGGER OR FEATURE_MEM_STATS OR FEATURE_PARSER_DUMP OR FEATURE_REGEXP_DUMP)
set(FEATURE_LOGGING ON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debugging should not force logging.

@@ -74,6 +76,7 @@ util_print_number (ecma_number_t num_p) /**< number to print */
lit_utf8_byte_t str_buf[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER];
lit_utf8_size_t str_size = ecma_number_to_utf8_string (num_p, str_buf, sizeof (str_buf));
str_buf[str_size] = 0;
JERRY_UNUSED (str_buf); // potentially
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will forget adding these macros. Just like asserts, logging should reference its arguments.

JERRY_DEBUG_MSG (is_constructor ? "\n--- Class constructor parsing end ---\n\n"
: "\n--- Function parsing end ---\n\n");
JERRY_DEBUG_MSG ("\n--- %s parsing end ---\n\n",
context_p->status_flags & PARSER_CLASS_CONSTRUCTOR ? "Class constructor"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brackets around context_p->status_flags & PARSER_CLASS_CONSTRUCTOR.

@akosthekiss
Copy link
Member Author

PR updated according to the reviews

Note 1: "Just like asserts, logging should reference its arguments." This needed some macro black magic as the classic JERRY_UNUSED doesn't work right with variadic arguments.

Note 2: As of late, the ESP target has been erroring. It makes all PRs red (including this one). Hope it's only some instability that goes away soon.

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akosthekiss
Copy link
Member Author

Commits squashed.

Copy link
Contributor

@yichoi yichoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary size Affects binary size
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants