Skip to content
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

record: make all info in text format #1435

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qpakzk
Copy link
Contributor

@qpakzk qpakzk commented May 29, 2022

All header info was written by binary format. But this commit changes all info to uftrace.data/info.txt in text format.

Fixed: #1408.

@honggyukim
Copy link
Collaborator

Hi @qpakzk, thanks very much for doing this. I will have a look when I come back from holiday.

@namhyung
Copy link
Owner

namhyung commented Jun 1, 2022

Thanks for looking into that. I've been thinking about the file format changes and I think we also need to change data formats for better parsing of arguments and longer than 48-bit address spaces.

@honggyukim
Copy link
Collaborator

@qpakzk Thanks for waiting. I have tested your patch and have a few comments.

First, we must support backward compatibility. This patch makes info file in text format, but it doesn't allow previously recorded data to be read. I think we can make text format info as info.txt, then uftrace reads info.txt first. If it doesn't exist, then it can read info binary file as a fall back.

Second, info file ends with broken data as follows.

$ cat uftrace.data/info
magic:Ftrace!
version:4
header_size:40
endian:1
elf_class:2
feat_mask:867
info_mask:15359
max_stack:1024
    ...
loadinfo:2.07 / 0.66 / 0.34
record_date:Mon Jun  6 16:06:35 2022
elapsed_time:0.011185541 sec
pattern_type:regex
uftrace_version:v0.11-87-g8d68 ( x86_64 dwarf python luajit tui perf sched dynamic )
�4�`[~��4p_~��[~��~����������\d���b�� @~7��h��0#���HO~��DO~��@Z~��0#����HE��$@�b��}BDO~��CsP~���      @P~��0�N�}~`Z~����b��P~��$@P~��P~��        ~���~���������ͷ��@B@B �gp_~��~��4���s pid=%d�ͷ~��.<�~��[~��4~����oc~������SXPF�
��
%%%%%%%%%%%%%%%%������`�����`Y~�� X~��=�/stat%*d %*s %cG��EX~�� X~��   �E`Y~��fq��E���������
��E

        �E4E0@Z~��Y~���M�M�M11185541G���MhZ~���M X~��潿`��P������M��M��M��M��M�M��M�M�������������`��`��P��G�p_~��p_~��4�[~���(0@Z~��Y~��G����G�TUUU Np_~��4�[~��+�֊r

@honggyukim
Copy link
Collaborator

I think we can make text format info as info.txt, then uftrace reads info.txt first. If it doesn't exist, then it can read info binary file as a fall back.

@namhyung What do you think about this approach?

@qpakzk qpakzk force-pushed the feature/info-text-format branch 3 times, most recently from b87d4e0 to b22ffb7 Compare June 14, 2022 23:44
@namhyung
Copy link
Owner

Sorry for the late reply. I agree that we should provide backward compatibility to the old data.

Copy link
Collaborator

@honggyukim honggyukim left a comment

Choose a reason for hiding this comment

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

Thanks for the update! It looks good and works fine in general cases, but I have left a few comments. I also see some strange failures in our tests. Especially WARN: creating directory failed: File exists looks not good.

$ cd tests
$ ./runtest.py -j1
Start 271 tests with 1 worker
Test case                 pg             finstrument-fu
------------------------: O0 O1 O2 O3 Os O0 O1 O2 O3 Os
001 basic               : OK OK OK OK OK OK OK OK OK OK
002 argument            : OK OK OK OK OK OK OK OK OK OK
003 thread              : OK OK OK OK OK OK OK OK OK OK
004 filter_F            : OK OK OK OK OK OK OK OK OK OK
005 filter_N            : OK OK OK OK OK OK OK OK OK OK
006 filter_FN           : OK OK OK OK OK OK OK OK OK OK
007 library             : OK OK OK OK OK OK OK OK OK OK
008 daemon              : OK OK OK OK OK OK OK OK OK OK
009 fork                : OK OK OK OK OK OK OK OK OK OK
010 forkexec            : OK OK OK OK OK OK OK OK OK OK
WARN: creating directory failed: File exists
WARN: creating directory failed: File exists
WARN: creating directory failed: File exists
WARN: creating directory failed: File exists
WARN: creating directory failed: File exists
011 vforkexec           : OK OK OK OK OK OK OK OK OK OK
WARN: creating directory failed: File exists
WARN: creating directory failed: File exists
WARN: creating directory failed: File exists
WARN: creating directory failed: File exists
012 demangle            : OK OK OK OK OK OK OK OK OK OK
    ...
100 dump_depth          : OK OK OK OK OK OK OK OK OK OK
101 dump_chrome         : NG NG NG NG NG NG NG NG NG NG
102 dump_flamegraph     : OK OK OK OK OK OK OK OK OK OK
103 dump_kernel         : SK SK SK SK SK SK SK SK SK SK
104 graph_kernel        : SK SK SK SK SK SK SK SK SK SK
105 replay_time         : OK OK OK OK OK OK OK OK OK OK
106 report_time         : OK OK OK OK OK OK OK OK OK OK
107 dump_time           : NG NG NG NG NG NG NG NG NG NG
108 graph_time          : OK OK OK OK OK OK OK OK OK OK
109 replay_time_A       : NG NG NG NG NG SK SK SK SK SK
110 replay_time_T       : OK OK OK OK OK OK OK OK OK OK
    ...

Please check the test failures. Some of them are known issues as I posted at #1436 (comment).

cmds/info.c Outdated Show resolved Hide resolved
utils/data-file.c Outdated Show resolved Hide resolved
cmds/info.c Outdated Show resolved Hide resolved
@qpakzk qpakzk force-pushed the feature/info-text-format branch from b22ffb7 to 70407f5 Compare June 19, 2022 17:05
@qpakzk
Copy link
Contributor Author

qpakzk commented Jun 19, 2022

@honggyukim Thanks for your feedback. I updated my commit, but I'll check test failures soon.

Copy link
Collaborator

@honggyukim honggyukim left a comment

Choose a reason for hiding this comment

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

Hi @qpakzk, thanks for the update.

I'll check test failures soon.

The failed test cases are as follows.

Test case                 pg             finstrument-fu
------------------------: O0 O1 O2 O3 Os O0 O1 O2 O3 Os
087 arg_variadic        : NZ OK OK NZ OK SK SK SK SK SK
101 dump_chrome         : NG NG NG NG NG NG NG NG NG NG
107 dump_time           : NG NG NG NG NG NG NG NG NG NG
109 replay_time_A       : OK NG OK NG NG SK SK SK SK SK
117 time_range          : OK OK OK NG OK OK OK OK NG OK
125 report_range        : OK OK OK OK OK OK OK OK NG OK
135 trigger_time2       : OK OK OK OK OK OK NG OK OK OK
141 recv_basic          : NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ
142 recv_multi          : NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ
150 recv_event          : NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ
151 recv_runcmd         : NG NG NG NG NG NG NG NG NG NG
162 pltbind_now_pie     : BI BI BI BI BI BI BI BI BI BI
166 dump_sched          : NG NG NG NG NG NG NG NG NG NG
167 recv_sched          : NZ NZ NZ NZ NZ NZ NZ NZ NZ NZ
179 arg_auto2           : OK NZ OK OK NZ OK OK NZ OK OK
182 thread_exit         : OK OK OK OK OK OK OK OK NG OK
196 chrome_taskname     : NG NG NG NG NG NG NG NG NG NG
202 arg_dwarf2          : NG NG NG NG NG SK SK SK SK SK
203 arg_dwarf3          : NG OK NG NG NG SK SK SK SK SK
204 arg_dwarf4          : OK OK NG NG OK SK SK SK SK SK
205 arg_auto4           : OK OK NZ OK OK SK SK SK SK SK
222 external_data       : OK OK OK OK OK NG OK OK OK OK
251 exception4          : NG NG NG NG NG NG NG NG NG NG

You can run a single test with a single option as follows. -vdp is for verbose, diff, pg and -O0 means optimization level. The last 101 is a string for matching with tests.

$ ./runtest.py -vdp -O0 101
      ...
t101_dump_chrome: diff result of -pg -O0
--- expect      2022-06-21 23:12:09.172745571 +0100
+++ result      2022-06-21 23:12:09.172745571 +0100
@@ -1,10 +1 @@
-M process_name t-abc
-M thread_name t-abc
-B main
-B a
-B b
-B c
-E c
-E b
-E a
-E main
+

101 dump_chrome         : NG

cmds/info.c Outdated Show resolved Hide resolved
cmds/info.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@honggyukim honggyukim left a comment

Choose a reason for hiding this comment

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

We have another missing change as follows.

diff --git a/cmds/dump.c b/cmds/dump.c
index 0c3b3bbc..04ed1947 100644
--- a/cmds/dump.c
+++ b/cmds/dump.c
@@ -1013,9 +1013,12 @@ static void dump_chrome_footer(struct uftrace_dump_ops *ops,
        struct uftrace_chrome_dump *chrome = container_of(ops, typeof(*chrome), ops);

        /* read recorded date and time */
-       snprintf(buf, sizeof(buf), "%s/info", opts->dirname);
-       if (stat(buf, &statbuf) < 0)
-               return;
+       snprintf(buf, sizeof(buf), "%s/info.txt", opts->dirname);
+       if (stat(buf, &statbuf) < 0) {
+               snprintf(buf, sizeof(buf), "%s/info", opts->dirname);
+               if (stat(buf, &statbuf) < 0)
+                       return;
+       }

        ctime_r(&statbuf.st_mtime, buf);
        buf[strlen(buf) - 1] = '\0';

cmds/record.c Outdated Show resolved Hide resolved
@namhyung
Copy link
Owner

I'd like to hold this for a while and make the change with other file format changes like I mentioned before.

@qpakzk qpakzk force-pushed the feature/info-text-format branch 2 times, most recently from a55013e to ab895eb Compare June 27, 2022 15:30
@honggyukim
Copy link
Collaborator

I've been thinking about the file format changes and I think we also need to change data formats for better parsing of arguments and longer than 48-bit address spaces.

I'd like to hold this for a while and make the change with other file format changes like I mentioned before.

@namhyung Could you please let us know when you have plan?

@qpakzk Anyway, this PR has a few problems. First, you shouldn't create a merge commit in the PR. Second, the travis result is broken because of the previously merged patch, but this is fixed in the current master.

To handle for both problems, you should rebase the branch properly and update the PR again.

@qpakzk qpakzk force-pushed the feature/info-text-format branch 2 times, most recently from a11a390 to 2c05369 Compare June 30, 2022 14:31
@qpakzk
Copy link
Contributor Author

qpakzk commented Jun 30, 2022

@honggyukim Thanks for your comment. I rebased it and updated my commit.

@namhyung
Copy link
Owner

@namhyung Could you please let us know when you have plan?

I don't have ETA but it's not an urgent issue so please expect it takes long

@qpakzk qpakzk force-pushed the feature/info-text-format branch from 2c05369 to c200d23 Compare July 3, 2022 02:45
@honggyukim
Copy link
Collaborator

For the same reason, we have applied clang-format globally so your change now shows horrible conflicts so I've rebased your change and put the patch at master...honggyukim:uftrace:clang-format/feature/info-text-format. Please pick it and update your PR again.

@qpakzk qpakzk force-pushed the feature/info-text-format branch from c200d23 to e3098b3 Compare July 9, 2022 15:12
All header info was written by binary format.
But this commit changes all info to uftrace.data/info.txt
in text format.

To support backward compatibility with previous versions,
if uftrace.data/info.txt doesn't exist, then find uftrace.data/info
written by binary format.

Fixed: namhyung#1408
Signed-off-by: Sangwon Hong <[email protected]>
@qpakzk qpakzk force-pushed the feature/info-text-format branch from e3098b3 to a49e65c Compare July 9, 2022 15:39
@qpakzk
Copy link
Contributor Author

qpakzk commented Jul 9, 2022

@honggyukim Thanks for rebasing my change. I updated my PR.

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

Successfully merging this pull request may close these issues.

Make uftrace.data/info as text format
3 participants