-
Notifications
You must be signed in to change notification settings - Fork 24
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
Small fixes from profiling PR #126
Small fixes from profiling PR #126
Conversation
0e88141
to
d8e7e15
Compare
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.
not sure about all of those, for the cobc change we should have a testcase after the commit
libcob/ChangeLog
Outdated
* common.c: (cob_expand_env_string): use "getpid" instead | ||
of "cob_sys_getpid" to use the correct PID in case of "fork" |
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.
Do you have an example where this is probematic? It isn't if you use CBL_GC_FORK
, of course. Note that (especially with 4.x) there are also other elements that need to be adjusted.
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.
No, except the use of fork()
in external C code.
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'm not sure if/how we should handle that. The scenario's I think of are:
- "external" -> COBOL (then back, then fork then to COBOL in both)
- COBOL -> "external with fork" -> to COBOL
In both cases the runtime needs to know about that, because it needs to reset some things. While this is only the cached PID in GC 3.1+3.2, we may need more entries. For example trunk has improved locking with BDB and this is done internally by a "locker id" - and this may not be used in more than a single thread (or even process). fbdb keeps its locker ids and resets them (later acquiring a new one) for a cbl_sys_fork'd process.
So... can we handle that outside of cob_sys_fork
? I currently see no option.
If there is no option, why should we support a specific case of fork
that may won't work otherwise?
It seems better to explicit document that after the COBOL runtime is initialized you may only run cob_sys_fork()
but not fork()
directly. We can of course come up with an API function which we call from within cob_sys_fork()
for childs and that external programs may use when they do a fork()
before getting to COBOL again.
Opinions?
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.
Indeed, the only solution I see (unless we can detect that a fork
happened at low cost) would be to provide a function cob_must_be_called_after_fork()
to reset the process-specific state. Indeed, in the meantime, it's probably worth keeping cob_sys_getpid()
(though there are still other places with getpid()
).
d8e7e15
to
ebc4024
Compare
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## gcos4gnucobol-3.x #126 +/- ##
=====================================================
+ Coverage 65.74% 65.76% +0.02%
=====================================================
Files 32 32
Lines 59092 59095 +3
Branches 15575 15577 +2
=====================================================
+ Hits 38849 38865 +16
+ Misses 14262 14251 -11
+ Partials 5981 5979 -2 ☔ View full report in Codecov by Sentry. |
590f970
to
36bf864
Compare
libcob/coblocal.h
Outdated
@@ -22,6 +22,8 @@ | |||
#ifndef COB_LOCAL_H | |||
#define COB_LOCAL_H | |||
|
|||
#include "config.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.
@GitMensch Any reason why config.h
is not included systematically in all other .h
files ?
Yes, because this generated file has no inclusion guard - it should be included only once - and should be included before any system header in any case. As tarstamp.h may be used in there (that was kind of common for environments without auto-configuration in the patchlevel, but we could drop support for that) it is included before config.h
|
Yes,
? |
In the current code that would be #ifndef COBCRUN_NAME
#ifndef COB_TAR_DATE
#include "tarstamp.h"
#endif
#include "config.h"
#endif in both cobc/cobc.h and libcob/coblocal.h I'd prefer the more easy one to just have /* may be used in config.h, e.g. for PATCH_LEVEL */
#include "tarstamp.h"
/* (generated) configuration for this build */
#include "config.h" in all source files as the first code line in the beginning. ... thinking of this again, tarstamp.h may only be used in config.h if it is manually created (like in build_windows/config.h.in), so we should just include it there and in the places using it (without checking: libcob/common.c, cobc/cobc.c, cobc/codegen.c); I'll do this change to the 3.x branch "soon". Further: actually config.h should only be used if |
I am not fond of such "informal convention", that may lead to bugs the next time somebody creates a new source file. Just during this PR, I had to debug weird behaviors twice, because of the position of Another idea: create a header file
and have it included from all other include files, and replace |
... but even then this cob-config.h must either be included everywhere or included in coblocal.h and cobc.h, no? In this case it would be better placed into those files directly. Note that 4.x has a new "private" compile-time header, we can include something like that there in any case. |
Do not move object files and preprocess files when they were specified as an explicit target on the command line (-E, -c) with -save-temps=DIR
36bf864
to
8f9c30a
Compare
I simplified this PR to only fix the For the I was also surprised that the configuration is not exported during installation, I would have expected Anyway, I propose to have this discussion in another PR, maybe for 4.x, when we start targetting it for next changes. By the way, is there a thread somewhere on how the switch between 3.x to 4.x is organized ? |
to match current PR
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.
that's fine now; and as my work on svn finally started (with a lot of delay) this should soon be able to actually be included upstream
Do not move object files if they were specified as an explicit target on the command line (typically
cobc -c --save-temps=DIR -o foo.o foo.cob
should keepfoo.o
in the current directory)