-
Notifications
You must be signed in to change notification settings - Fork 0
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
[WIP] Add line by line perf (by Emilien) #3
base: gcos4gnucobol-3.x
Are you sure you want to change the base?
Conversation
731848a
to
4250dd7
Compare
libcob/cobperf.h
Outdated
|
||
typedef struct linedata linedata; | ||
|
||
typedef struct rundata rundata; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two types are not used in the interface, what is the point of making them public ?
libcob/cobperf.h
Outdated
along with GnuCOBOL. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef cobperf_h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the size of this file, I don't think it's worth having its own .h files (unless we start having .h files for every .c, which would actually be a good thing).
libcob/cobperf.h
Outdated
|
||
typedef struct rundata rundata; | ||
|
||
void cobperf_init(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be COB_EXPIMP void cob_perf_init (void);
:
- All prototypes in .h must have
COB_EXPIMP
- All extern functions of
libcob
should start withcob_
- Always add a space before
(
for function protos and calls
libcob/cobperf.h
Outdated
* @param section the section name | ||
* @param paragraph the paragraph name | ||
*/ | ||
void cobperf_runline(const char *filename, unsigned line_number, const char* section, const char* paragraph); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer cob_perf_run_line
libcob/cobperf.h
Outdated
/** | ||
* This function will save all the logs to the log file. | ||
*/ | ||
void cobperf_end(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
cobc/typeck.c
Outdated
@@ -13970,6 +13970,7 @@ cb_emit_start (cb_tree file, cb_tree op, cb_tree key, cb_tree keylen) | |||
void | |||
cb_emit_stop_run (cb_tree x) | |||
{ | |||
cb_emit (CB_BUILD_FUNCALL_0 ("cobperf_end")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above, it was output_line("cobperf_end();");
, why use a different style ?
libcob/cobperf.c
Outdated
void **old_data = arr->data; | ||
arr->capacity *= ARRAY_GROW_FACTOR; | ||
arr->data = (void**)calloc(arr->capacity, sizeof(void*)); | ||
for (size_t i = 0; i < arr->size; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use memcpy
libcob/cobperf.c
Outdated
run->count = 1; | ||
run->total_time = timediff; | ||
run->line_data = *data; | ||
array_push(arr, (void *)run); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It means that the array increases every time a line is executed ? It sounds quite expensive, no ?
I think the design/specification should be written first. Typically, I see two major flaws in this implementation:
- I am not sure of what we are measuring. It looks like the time spent between two lines, but I am not completely sure that we are not going to miss some changes in control flow, i.e. measuring time that was actually spent in another line ;
- We cannot have one record per executed line, it should be at most one record per source line: times should accumulated, i.e.
total_time
should be the sum of all executions for a line (and we would get the average by dividing bycount
)
libcob/cobperf.c
Outdated
FILE *f = (FILE*)file; | ||
rundata *rdata = (rundata*)data; | ||
|
||
fprintf(f, "%s, %s, %s, %u ,%u, %lld\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the spaces after the commas. File should be easy to parse, i.e. use either commas or spaces to separate items, not both.
libcob/cobperf.c
Outdated
rdata->line_data = *data; | ||
array_push(arr, (void *)rdata); | ||
|
||
FILE *f = fopen("prof.csv", "w"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A common habit is to use multiple runs to accumulate samples. So, instead of rewriting the file, we should always append.
In a final implementation, there should be two files: one generated at compile time with the locations, one generated at run time with the timings.
This could be renamed to |
All the comments will be taken into account, I need some time to further check how the codegen works to make it work better |
testsuite adjustment
libcob/version.h: bump to 3.3
e80f0af
to
3d522e3
Compare
a274a3e
to
f890dd6
Compare
@lefessan Could you review this PR, I'd also like to open it on the official repo, so that I can ask Simon if he's interested and how I could improve it |
A few improvements to do:
|
8206bcc
to
bbad458
Compare
configure.ac
Outdated
|
||
case "$USE_XLSX" in | ||
check) | ||
if test "$with_json" = yes; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xxx!
e5dace0
to
9ca841a
Compare
f09c48d
to
44c6e92
Compare
5c9480d
to
6201481
Compare
The --copy option can be used to include copybooks before parsing files, for example to perform replacements or include COBOL prototypes. The --include option can be used to include a HEADER in the generated C file, for example to perform verification of external calls combined with -fstatic-call.
libcob/fileio.c: * (indexed_keylen): signature change to directly take the keydesc * [WITH_ANY_ISAM]: refactored to ease access to keydesc and keypart * (indexed_open) [WITH_ANY_ISAM]: refactored
…(currently only for the BDB backend) cobc: * codegen.c (output_file_initialization): output the indexed file/keys collating sequence (were already present in the AST) * tree.c (validate_indexed_key_field): process postponed key collating sequences * parser.y (collating_sequence_clause, collating_sequence_clause_key): replace CB_PENDING by CB_UNFINISHED on file and key collating sequence * flag.def, tree.c, tree.h, cobc.c, parser.y: add and handle a new -fdefault-file-colseq flag to specify the default collating sequence to use for files without a collating sequence clause libcob: * fileio.c (bdb_setkeycol, bdb_bt_compare, indexed_open, ...): take the file collating sequence into account when comparing keys * common.c, coblocal.h: rename common_cmps to cob_cmps and make it available locally
presumingly fixing win32 tests
1062bc9
to
b0c82cd
Compare
* cobc/parser.y (screen_value_clause): replaced basic literals by literals
* cobc/parser.y: fix SEGFAULT when checking the BY VALUE arguments of a prototype with ANY LENGTH
63fed8a
to
67c02ad
Compare
89a3a6b
to
fe48125
Compare
Initial work by Emilien Lemaire <[email protected]> Additional features: * Do not check for enter/exit section: instead, sum time from paragraphs * Support for modules, CALL and ENTRY points * Support for recursive calls * Allocate virtual stack on demand instead of statically * Correct handling of EXIT PARAGRAPH code with 'goto' * Prevent CANCEL from dlclose a module during profiling * Customize CSV result file with COB_PROF_FORMAT * Customize CSV filename using $b/$f/$d/$t * Add some tests for RECURSIVE on PROGRAM-ID
* fix compile under WIN32 and systems without CLOCK_MONOTONIC / CLOCK_MONOTONIC_RAW * fix use of defined but unavailable CLOCK_MONOTONIC_RAW * minor refactoring
c7e5f3d
to
8f9868e
Compare
No description provided.