Skip to content

Conversation

@dcpleung
Copy link
Member

@dcpleung dcpleung commented Dec 8, 2020

Dictionary-based logging, instead of human readable texts, outputs the log messages in binary format. This binary format encodes arguments to formatted strings in their native storage formats which can be more compact than their text equivalents. For statically defined strings (including the format strings and any string arguments), references to the ELF file are encoded
instead of the whole strings. A dictionary created at build time contains the mappings between these references and the actual strings. This allows the offline parser to obtain the strings from the dictionary to parse the log messages. This binary format allows a more compact representation of log messages in certain scenarios. However, this requires the use of an offline parser and is not as intuitive to use as text-based log messages.

@github-actions github-actions bot added area: API Changes to public APIs area: Documentation area: Logging area: NIOS2 NIOS2 Architecture area: Tests Issues related to a particular existing or missing test labels Dec 8, 2020
@dcpleung dcpleung force-pushed the dictionary_logging branch 2 times, most recently from d6dd92f to 80bd99a Compare December 9, 2020 00:25
@dcpleung dcpleung force-pushed the dictionary_logging branch 5 times, most recently from 9d4826b to 6e29a38 Compare December 10, 2020 18:42
@dcpleung dcpleung marked this pull request as ready for review December 10, 2020 21:20
@dcpleung dcpleung requested a review from andrewboie as a code owner December 10, 2020 21:20
@dcpleung dcpleung requested a review from a user December 10, 2020 21:20
@dcpleung
Copy link
Member Author

CI's failure to build documentation is not related to this PR.

@nordic-krch
Copy link
Contributor

@dcpleung please look at #30353. I started to work on logging subsystem overhaul to enable missing features which cannot be achieved with current design. The main change will be that log message will be self contained (string duplication will be inside the message). Messages will no longer be fragmented. This will significantly simplify dictionary based logging because dictionary backend will just transmit raw message as is.

To make that happen there is also an ongoing work in cbprintf to allow that (#30675) by introducing a concept of string package. A string package contains serialized arguments. Strings are treated specially, they can be stored by address or by value. There is 1 one header which indicates mode and address or content follows. Cbprintf will support formatting a string from a package in parallel to standard formatting from va_list.

@nashif
Copy link
Member

nashif commented Jan 21, 2021

@dcpleung please look at #30353. I started to work on logging subsystem overhaul to enable missing features which cannot be achieved with current design. The main change will be that log message will be self contained (string duplication will be inside the message). Messages will no longer be fragmented. This will significantly simplify dictionary based logging because dictionary backend will just transmit raw message as is.

@nordic-krch what are you suggesting here? Wait for the overhaul? What is the timeline?

@nordic-krch
Copy link
Contributor

@nashif i've opened draft PR #31535

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@dcpleung dcpleung force-pushed the dictionary_logging branch from ab55b47 to 5b6f2d6 Compare April 22, 2021 18:13
@github-actions

This comment has been minimized.

@dcpleung dcpleung force-pushed the dictionary_logging branch 2 times, most recently from bc493ab to 4210223 Compare April 22, 2021 19:33
@github-actions

This comment has been minimized.

@dcpleung

This comment has been minimized.

@dcpleung dcpleung added the Blocked Blocked by another PR or issue label Apr 26, 2021
One of the loop is using int as loop variable but it's being
compared against size_t. Some compiler configuration has
-Wsign-compare turned on by default which will complain about
"comparison of integer expressions of different signedness".
So fix it by changing the loop variable to be size_t also.

Signed-off-by: Daniel Leung <[email protected]>
This adds the _image_rodata_start and _image_rodata_end
symbols to NIOS2's linker script.

Signed-off-by: Daniel Leung <[email protected]>
This adds the _image_rodata_start and _image_rodata_end
symbols to SPARC's arch linker script.

Signed-off-by: Daniel Leung <[email protected]>
NIOS2, RISC-V and SPARC are using _image_rodata_start/_end in
their linker scripts to mark the boundaries of rodata. So
they no loner need special treatment.

Signed-off-by: Daniel Leung <[email protected]>
NIOS2 is using _image_rodata_start/_end in its linker script
to mark the boundaries of rodata. So they no loner need
special treatment.

Signed-off-by: Daniel Leung <[email protected]>
This adds dictionary based logging support. Dictionary based
logging is binary based where one big difference is that
static strings are stored as pointers instead of the whole
string. This results in reduced space requirements for
storing log messages in certain scenairos.

Signed-off-by: Daniel Leung <[email protected]>
@dcpleung dcpleung force-pushed the dictionary_logging branch from 4210223 to cfc5e36 Compare April 26, 2021 15:50
@dcpleung dcpleung removed the Blocked Blocked by another PR or issue label Apr 26, 2021
@nashif nashif requested a review from tejlmand April 26, 2021 17:49
@nashif nashif added this to the v2.6.0 milestone Apr 26, 2021
Copy link
Contributor

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

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

Looks very good. Thanks for the cleanup into a choice.

Two minor nits.

This adds a new UART backend for dictionary based logging,
where this can output binary data in both binary and
hexidecimal strings.

Signed-off-by: Daniel Leung <[email protected]>
This adds a sample application on dictionary-based logging.
The README file includes instruction on how to run the log parser
to generate human readable log messages.

Signed-off-by: Daniel Leung <[email protected]>
This adds new documentation for dictionary-based logging on
usage and low-level information.

Signed-off-by: Daniel Leung <[email protected]>
@dcpleung dcpleung force-pushed the dictionary_logging branch from cfc5e36 to d4163bf Compare April 27, 2021 15:54
@carlescufi carlescufi requested a review from tejlmand April 28, 2021 17:33
Copy link
Contributor

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

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

LGTM

@carlescufi carlescufi merged commit e1fc809 into zephyrproject-rtos:master Apr 28, 2021
@dcpleung dcpleung deleted the dictionary_logging branch April 28, 2021 20:30
@marc-hb
Copy link
Contributor

marc-hb commented May 29, 2021

Dictionary for printk() in the Linux kernel:
https://lwn.net/Articles/857148/
https://lwn.net/ml/linux-kernel/[email protected]/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: API Changes to public APIs area: Build System area: Documentation area: Logging area: NIOS2 NIOS2 Architecture area: Samples Samples area: SPARC SPARC Architecture area: Tests Issues related to a particular existing or missing test manifest manifest-sof

Projects

None yet

Development

Successfully merging this pull request may close these issues.