Unowned references prevent retain cycles in Swift. They boost runtime performance, but you risk crashing if you get them wrong. How do they work? What exactly is this performance gain? Should we use them at all?
Jacob Bartlett’s Post
More Relevant Posts
-
Today I spent some times to try std::expected introduced in #c++23. In terms of reading the code the result is better, let's say. But like everything else, there is a hidden price to pay. it's an r-value, the compiler shall capture the value from the callee to the caller and requires a move constructor for every <T,E>. To achieve this, an unitialized expected object is created into the caller stack, transferred as hidden argument to the callee where the default move constructor for T or E will be called and a status flag for the operator bool () is set. Everything is transparent. amazing.. 24 bytes of returning value on x64 instead of 16 bytes or 8 for trivial return value. sometimes i wonder how much code i need versus how much code is needed to manage it all. Thoughts of an old man
To view or add a comment, sign in
-
Boost the performance of your Go services by 10-30% without touching a line of code! Profile-Guided Optimization (PGO) uses runtime profiles to enhance your application's latency & efficiency. https://lnkd.in/gb9jmsts
Unlocking Speed
gitar.co
To view or add a comment, sign in
-
Have you ever heard of the Go tool for identifying where memory allocations occur in your benchmark? This can be extremely useful for optimizing your code and reducing the impact on the Garbage Collector. With the following command, you can run all your benchmarks and generate a detailed file with information about memory allocations: go test -run none -bench . -memprofile p.out -gcflags -m=2 What each part of the command does: -run none Ensures that no tests are executed. Only the benchmarks will run. -bench . Runs all benchmarks. The . works as a filter that selects all benchmark functions (BenchmarkX) defined in your code. -memprofile p.out Generates a file called p.out with detailed information about memory allocations that occurred during the benchmarks. This file can later be analyzed with tools like pprof to visualize memory consumption. -gcflags -m=2 Activates a detailed level of compiler escape analysis, showing: Where each variable is allocated (on the stack or the heap). The reasons for the allocations. With this, you can closely monitor the behavior of the Garbage Collector and understand the compiler's decisions for each line of your code. Example of how a heap allocation appears:
To view or add a comment, sign in
-
Understanding Escape Analysis in Go https://lnkd.in/dxcX7DZj Go uses escape analysis to determine the dynamic scope of Go values. Typically, go tries to store all the Go values in the function stack frame. The go compiler can predetermine which memory needs to be freed and emits machine instructions to clean it up. This way it becomes easy to clean up memory without the intervention of the Go Garbage Collector. This way of allocating memory is typically called stack allocation. But when the compiler cannot determine the lifetime of a Go value it escapes to the heap. A value may also escape to the heap when the compiler does not know the size of the variable, or it’s too large to fit into the stack, or if the compiler cannot determine whether the variable is used after the function ends or the function stack frame is not used anymore.
To view or add a comment, sign in
-
Some bug fixes to make it more robust; big step is getting "-f" (take fingerprint) to output the full fingerprint: learned in the process, that the compiler takes it upon itself to free arrays declared, but leaves us to free malloc'ed mem (even though the array name by itself is treated as a pointer). Made the interface a bit more robust. Added in the freemem calls to clean up the show, avoid memory leaks. Now I would really like to figure out the thread_pool error message that seems to mean not all threads are finished running despite calling "get()" on each of them... Puzzle of the day: how many automorphisms of the "cube" (testgraph23.dat)
To view or add a comment, sign in
-
Async closures stabilized! https://lnkd.in/dtsR4Tjd
Stabilize async closures (RFC 3668) by compiler-errors · Pull Request #132706 · rust-lang/rust
github.com
To view or add a comment, sign in
-
Early vs. Late Binding in C#: Learn when to prioritize type safety and performance with early binding or use dynamic flexibility with late binding. @CodeMazeBlog explains both approaches https://lnkd.in/gUJ9eNxy
Early Binding and Late Binding in C# - Code Maze
https://code-maze.com
To view or add a comment, sign in
-
For the past four months, I've led the development of a fork of the Clang compiler that implements support for ISO C++ proposal P2996 ("Reflection for C++26" — https://wg21.link/p2996). Today, Bloomberg published that fork as an open source repository. You can check it out here: https://lnkd.in/eMytqT8f Or you can play with it right away on Compiler Explorer (thanks, 🖥️ Matt Godbolt, for making that happen). https://lnkd.in/ecJZV-Bj The project's primary goal is to explore the implementation feasibility of P2996 in a major open source compiler. Through this, we hope to also provide an environment for C++ enthusiasts to experiment with additional reflection features not already proposed by P2996. Finally, we aim to discover and raise awareness of possible concerns with bringing P2996 to Clang (i.e., proposed features that may not fit easily within the existing architecture). We're releasing just in time for the ISO C++ plenary in Tokyo next week, where P2996 will be seen for the first time by EWG and LEWG. This is now the second independent implementation of P2996, which we hope will give momentum to the paper as it makes its way through WG21. C++ users have literally been waiting decades for Reflection - here's hoping we can land it for '26!
GitHub - bloomberg/clang-p2996: Experimental clang support for WG21 P2996 (Reflection).
github.com
To view or add a comment, sign in
-
Leetcode problem of the day : Minimum Number of Operations to Make Array XOR Equal to K The problem that we are tackling for today is to find the minimum number of operations required to make the XOR of elements in a subarray equal to a given value `k`. Approach used : 1. XOR Computation: Initially, the code computes the XOR of all elements in the given array `nums`. 2. Bitwise Comparison: It iterates through each bit of both `k` and the XOR result. For each bit position, it compares whether the corresponding bits in `k` and the XOR result are different. 3. Counting Operations: If the bits at the same position are different, it increments the count of operations required. 4. Shifting Bits: It right shifts both `k` and the XOR result to process the next bit position. 5. Return: Finally, it returns the count of operations needed to make the XOR of elements in a subarray equal to `k`. Time Complexity : O(N) Space Complexity : O(1) Link : https://lnkd.in/eJ3fXueg Feel free to ask any questions or provide feedback! I'm always eager to learn and improve. 😊✨ #CodingSolution #DynamicProgramming #JavaProgramming #DSA #CodingJourney #CodingChallenge #DataStructuresAndAlgorithms #LeetcodeDailyChallenge #BitManipulation #CompetativeProgramming #Consistency 💪🏻❤
To view or add a comment, sign in
🍉 iOS SWE II @Yassir (YC W20) | ex-Instabug
5moAhmed Salah