Skip to content

Conversation

@firewave
Copy link
Collaborator

Currently the Settings objects in the tests are all mutable. This might cause some tests to modify the settings as they also contain run-time information which will be used by subsequent tests using the same object.

We should make sure that they are const if possible. Otherwise we need to make sure the tests will always be run on a a fixed configuration.

@firewave
Copy link
Collaborator Author

This is to gain initial feedback on the approach. I will adjust all test then. I also have other PRs which need to be merged first to avoid conflicts.

@firewave firewave force-pushed the settings branch 2 times, most recently from 6ca74d2 to ab0b8d0 Compare February 16, 2023 13:41
@firewave firewave changed the title reduce usage of mutable Settings objects in tests reduced usage of mutable Settings objects in tests Feb 16, 2023
@firewave firewave force-pushed the settings branch 2 times, most recently from 7555687 to 9575e90 Compare February 16, 2023 22:42
@firewave
Copy link
Collaborator Author

This needs many other PRs merge first and we also need to adapt #4785 as a const Settings object still appears to be mutable since a lot of tests fail when I make those static. I wouldn't rule out some const_cast occurrences either.

@firewave
Copy link
Collaborator Author

Turns out they are not mutable. I accidentally made objects static which should not.

@firewave firewave force-pushed the settings branch 4 times, most recently from 348cb67 to 24c5953 Compare February 19, 2023 14:04
@firewave firewave marked this pull request as ready for review February 19, 2023 14:53
@firewave firewave force-pushed the settings branch 2 times, most recently from ed69e1c to e7a8c98 Compare March 2, 2023 20:37
@firewave firewave force-pushed the settings branch 3 times, most recently from 761c51b to 28ad381 Compare March 7, 2023 12:21
@firewave firewave force-pushed the settings branch 3 times, most recently from 7bc59be to edb0174 Compare March 12, 2023 16:25
@danmar
Copy link
Owner

danmar commented Mar 13, 2023

you are making various Settings objects static. Why?

@firewave
Copy link
Collaborator Author

you are making various Settings objects static. Why?

So they are not instantiated on each test case but only once. Especially if library loading (or copying) is involved that is consuming unnecessary CPU.

@danmar
Copy link
Owner

danmar commented Mar 13, 2023

I would not make local objects static just to save a few cpu cycles. Can we please stop with all these micro optimisations that only saves a few cpu cycles. It's more important with readability.

Also these objects will then use some mutexes to make these objects threadsafe that has a penalty also.

@danmar
Copy link
Owner

danmar commented Apr 9, 2023

Could you show some stats. With static or without static. I wonder if you can test that:

time ./testrunner TestOther

@firewave
Copy link
Collaborator Author

Could you show some stats. With static or without static. I wonder if you can test that:

time ./testrunner TestOther

I will give it a spin. It is quite possible this PR is not showing the gains yet and is even showing a slight regression since I introduced several copies which weren't there before and won't be removed until I have applied all changes. I could add the follow-up changes to this PR as well but I would prefer not to make this even bigger than it already is.

There's also some general change to the way we provide the settings to the common check() wrapper which I haven't done yet which might also improve things and get rid of the need of inline/non-static configurations. It's quite incremental and at the end things will be much cleaner and more explicit.

@firewave
Copy link
Collaborator Author

Doing tests I am getting some inconsistent results which is strange. So I will drop the static for now so this can proceed and will do some profiling again after I am done with all changes.

@danmar
Copy link
Owner

danmar commented Apr 30, 2023

Doing tests I am getting some inconsistent results which is strange. So I will drop the static for now so this can proceed and will do some profiling again after I am done with all changes.

ok thanks as far as I remember that was my biggest concern. There is now some conflict..

@danmar danmar merged commit 2935c85 into danmar:main May 2, 2023
@firewave firewave deleted the settings branch May 2, 2023 09:55
pfultz2 added a commit to pfultz2/cppcheck that referenced this pull request May 15, 2023
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.

2 participants