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

DBtiles.c: DBFreePaintPlane() remove the TiFree() deferred assumption #380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dlmiles
Copy link
Contributor

@dlmiles dlmiles commented Feb 18, 2025

No description provided.

This asks the compiler the check the assumptions that are currently
documented in the comments in this file.
The comment indicates the expectation that TiFree() is deferred-by-one,
which would be true if freeMalloc() was used but since the custom mmap()
allocator technically this is not true.

The TiFree() allocator is single-threaded and separate from libc so the
assumption is still kind of true but for different reasons
(single-threaded).

But since it doesn't really cost anything (other than a few lines of
code a human needs to read) the compiler would be expected to perform a
load (which it was going to do anyway) into a caller-saves register over
the function call.
Most of the other function state is invalidated anyway due to the heavy
linked-list navigation and low number of local variables, I would not
think there is much register allocation pressure.

TODO this code can be tested by confirming zero allocations are active
and by invalidating (poison) all fields inside TiFree().
@dlmiles
Copy link
Contributor Author

dlmiles commented Feb 20, 2025

The intention now is to add valgrind specific hints via #include <valgrind/memcheck.h> into the TiAlloc() custom allocator, to the memory checker can good the heavy lifting in validating (for finding the next problem). Also poisoning the data on TIFree().

Not sure if you want that (valgrind hints) as an additional commit with ifdef around ?

There is already K&R tiles/** ready here (just not on PR), so I may push that before releasing this.

Merge Status: merge on hold (pending valgrind style testing, review status in 2 months)
Quality: ready to merge
Risk: low-impact (this is rarely used deallocation function area)
Level of Testing: none (due to expecting to valgrind it)

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.

1 participant