When looping through the roots registered by the LLVM shadow-stack, is it OK to free them? Or is the root list only a list of the roots that are alive? In which case I need a separate list of all mallocs, not only the ones in the roots.
Related
I'm looking to get a list of bugs that exist within one epic. It's okay if it's a bit noisy, or even in multiple queries, as for my purpose I can export it and clean it up. Now, I am able to do this with a tree of work items search but I only see bugs that are children of features, but no lower. The problem in this epic I am querying is that from feature-> user-story -> task there are bugs that are children at each layer, and I need to see them all.
When I try and do a flat of work items query, I can return all bugs but for the entire project but don't know how to filter it to just the ones in one epic hierarchy, without returning to my first problem of only getting bugs that a children of features, but no lower.
Azure DevOps does not support such queries... but.. as a workaround, you may match linked work items first and filter by ID on the parent level.... in this case, you receive all work items and the tree for your particular epic:
Additionally, it`s recommended to register bugs only on one level (user story or requirements level) and consider using the Area Path to have more useful filters.
I am designing a guest check-in system for a residency hall. Residents can check-in guests, but only if these two constraints are met.
1. A resident can only have 2 guests checked-in at once
2. A guest can only be checked in with one resident
The check-in process results in a Visit.
I'm having trouble figuring out where these rules should be implemented. I started with this
var visit = resident.checkin(guest);
But that means I am modifying (or creating) three aggregates in one action:
Resident (increment # of checked in guests)
Guest (set them as checked in)
Visit = created
I don't see a concept in the domain to model as aggregate to hold these rules. Residents and guests exist outside of visits (or across other visits), so can't be wrapped in another aggregate.
I thought about a Saga, but that ends up in steps that don't make sense in the domain (like checking in the student and guest separately to see if one fails).
I could use some guidance? Is my modelling just off?
Creating a new aggregate B as part of existing aggregate A's transaction is usually not a problem in terms of concurrent access and consistency (since no one knows B yet). Here you have an additional invariant on the number of Visits which could be an exception to that, but it's enforced in Resident and Resident is the only entry point to creating a Visit, so everything boils down to a modification of Resident which is safe concurrency wise.
Then you have a global constraint on how many visits a guest can be in at a time. The issue has been answered multiple times on SO, but I would first of all recommend getting back to your domain experts to discuss the rule and possible variations of it, because there's a world of possibilities (eventual consistency, manual intervention, etc.) between "the constraint must be enforced and immediately consistent" and "the rule is useless".
In my mind the checked in state of the Resident and Guest should be viewed as a part of a 3rd AR and the incremental field in the Resident should just be incremented when a Visit is confirmed.
Approach 1:
I don't see a concept in the domain to model as aggregate to hold these rules. Residents and guests exist outside of visits (or across other visits), so can't be wrapped in another aggregate.
This does not mean that your Visit cannot hold references to the Resident and Guest.
If this 3rd aggregate is the Visit and it has states (for e.g. pending, confirmed, etc.) you can validate the state in a synchronous way and go through the states as the rule commands.
Approach 2 - Use Events for this:
There many ways to integrate events architecturally. Event Sourcing and CQRS could be a good fit here as it will change the way that you think of ARs, Entities and especially state changes.
Short CQRS definition:
Capture all changes to an application state as a sequence of events
Whatever you choose between 1 and 2 you should think of the Visit validation as a separate thing. The Resident should not validate how many guests there are at once, the Guest should not validate if 'he' is at two places at once. Those are all Business Rules related to Visits.
Some links:
I've recently answered a DDD question in a similar domain
CQRS's "official site" by Greg Young
Docs on CQRS by Greg Young
Martin Fowler's notes on Event Sourcing
When to avoid CQRS?
Tons of videos and presentations on the subject
Residence Hall - Aggregate Root (AR)
Guest - entity
Resident - entity
Visits - Value Object (list of Visit)
Commands for AR:
CheckInGuestCmd(guest,resident)
CheckOutGuestCmd(guest)
First command will check visits and enforce invariants than add visit
Second command will remove existing visit if it exists
I've recently came across an article by Greg Kroah-Hartman on why the Linux Kernel has not a stable API and how the Kernel repository is organized as a monotree. When I discussed the article with a friend it became clear that we had a different understanding of what the term tree applied to:
tree refers to different sub-folders of a project.
It refers to the different forks of the git master branch.
In the first case contributors would not checkout the complete project, e.g. the Linux Kernel, but only a sub-folder. These could then be combined with e.g. git-subtree.
In the second case contributors would have to checkout the complete project and basically create fork of a monorepo.
So what does tree in monotree refer to and how can a project be organized as a monotree with git?
Let's make a few notes here:
The phrase monotree, or even the partial word mono, never appears in the referenced article.
The article has seven occurrences of the word tree.
In six of these seven occurrences, the entire phrase here is the main kernel tree. The one reference that does not use this full phrase just says the tree but clearly has the same intent as the other six.
You have tagged this with git linux monorepo (in case the tags change).
Your question amounts to either: What does the author mean by the phrase "the main kernel tree"? or What do people in general mean when they refer to a tree? These are valid questions but not particularly relevant to Git.
Tree in computer science tends to refer to the data structure, which is also pretty loosely defined; see the wikipedia entry. We have some collection of nodes and edges—mathematically, a graph G defined by its set of vertices V and edges E, where each vertex connects by edges to other vertices—and there are constraints on the graph so that it is minimally connected, or equivalently, maximally acyclic. (See https://en.wikiversity.org/wiki/Introduction_to_graph_theory/Proof_of_Theorem_4 and the answers to What's the difference between the data structure Tree and Graph?)
A tree object in Git specifically refers to the stored Git object of Git-type "tree" (one of four Git object types that are stored in the repository database—the other three are commit, blob, and annotated tag). Such an object stores <mode, name, hash-ID> triples, where the mode and hash-ID identify additional Git objects to associate with the name, which is an arbitrary1 string of bytes excluding NUL and slash (codes 0 and 0x2f or 47 respectively). A commit object stored in Git includes the hash ID of a single tree object. Reading the tree object and locating the sub-objects it lists, then recursively reading their own sub-objects if those objects are trees, results in constructing the minimally-connected graph that is a CS-style tree.
1There's a length limit due to the cache entry ce_namelen field, which has a 32-bit integer type. So no name component can exceed about 4 GB in length. Practically speaking, none should probably exceed 255 bytes, but tree objects in Git don't enforce any particular limit, as far as I know.
A file system tree in Linux is really just a string identifying an entity within the file system, though naming anything other than a directory results in a degenerate tree with just one node in it. By naming a directory, though, you can imply that anyone interpreting this string should read the directory's contents, which are names that (by being concatenated with the string identifying the directory itself) name another Linux file system tree, possibly a degenerate one with a single file or device node or whatever. This kind of recursive enumeration leads to building up a minimally-connected graph, just as with the Git tree object. (Perhaps unsurprisingly, the Linux directory objects have essentially the same constraints on names as the Git tree objects, though they usually have a much smaller maximum component name length, typically 255 bytes or fewer.)
Finally, the way the phrase the main kernel tree is used in the article refers to the Linux kernel repository—Linus Torvald's Git repository for the Linux kernel—and the entire ecosystem around it. There is a lot of room for arguments about the details. Here, I will just include a link to this particular InfoWorld article, which seems like a reasonable summary of the state of affairs as of the time it was written (August 2016).
I know how to implement union find in general, but I was thinking of whether there would be a way to utilize the set structure in python to achieve the same result.
For example, we can union sets pretty easily. But I'm not sure how to determine if two elements are in the same set using just sets.
So, I am wondering if there is a data structure in python that would support such operation, other than the usual implementation?
You could always solve this problem by visualizing it as a tree and its nodes connecting to each other via the root, and then looking up the tree if you want to know if two nodes are connected. If the two nodes you are comparing has the same root (they are in the same tree), than they are connected.
To connect two nodes, just go to the root of each tree they are in, and make one root become the parent of the other.
This video will give you a great intuition about it:
https://www.youtube.com/watch?v=YIFWCpquoS8&list=PLUX6FBiUa2g4YWs6HkkCpXL6ru02i7y3Q&index=1
The connection between the tree nodes can be made via pointers in a language which supports it, but if your language dont (python), than you can create your own pointers by storing positions and links via an array.
The array would be such that its positions would represent your nodes, and the values inside it represents the connection of the specific node to its root. On the beginning, the position in the array is filled with the node number because the nodes has initially no parent, but as you connect nodes, the roots changes, and the array has to represent this. Actually, the value stored there is the identificator of the root.
But try visualizing the problem visually first instead of thinking of arrays and too much mathematical artificats. Visually dealing with it makes the solution sound banal, and can be a good guidance while writing code.
I say this because I have watched the video from Robert Sedgewick I just posted, with a graphical simulation of the solution, and implemented myself without paying too much attention to the code on his book. The intuition the video gave me is much more valuable than any mathematics.
It will help you to encapsulate the nodes into a class, with the following methods:
climbTreeFromNodeUpToRoot
setNewParentToThisNodeAndUpdateHeights
The first method, as the name says, takes you from a node and goes up the tree until finding the root of it, which is then returned.
If you compare two nodes with this method (actually, the roots returned by it), you know easily if they are connected by just comparing their roots.
Once you want to connected them, you go up the trees of both nodes, and ask one root to take the other one as its parent.
The trees can grow very big in height (sorry I dont use the official nomeclature, but this is the one that makes sense to me), so this simple approach will get very slow when you have to climb the tree at a later time.
To prevent trees from becoming to high, dont just set one root as the parent to another without criterium, but attach the smallest tree (in terms of height, not quantity of elements) to the highest one.
For this, you need to know the heights of each tree, and this information you can store on their respective root (via an extra array in your case, or an extra pointer from each node in other languages). This information should be updated everytime another tree connects to it.
It is not possible for a tree to know that she just got a new tree attached to it, so its important that every tree attaching to a second one informs the second as to update its height.
This information can be sent to the root of the second tree, and later used to judge (as writen before) which tree is the smallest. Remember, attaching a small tree to a big one instead of the opposite will save you incredible amounts of time.
Do you want something like this?
myset = ...
all(elt in myset for elt in (a,b))
I'm working on an app with a lot of code that is black box to me. While debugging something else I noticed that if you switch back and forth between tabs the old tabs r
g
As you mentioned, anything on root scope won't be GC'd:
Mark-and-sweep algorithm
This algorithm reduces the definition of "an object is not needed anymore" to "an object is unreachable".
This algorithm assumes the knowledge of a set of objects called roots (In JavaScript,
the root is the global object). Periodically, the garbage-collector
will start from these roots, find all objects that are referenced from
these roots, then all objects referenced from these, etc. Starting
from the roots, the garbage collector will thus find all reachable
objects and collect all non-reachable objects.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management
In general a healthy heap will look exactly like the graph you posted. The concern would be if it did not return to (in a pragmatic world: near) the baseline after GC.