diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-EskilSteenberg-yes-you-should-use-malloc-sparingly-i-see-a-lot.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-EskilSteenberg-yes-you-should-use-malloc-sparingly-i-see-a-lot.md new file mode 100644 index 0000000..a0c0ad4 --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-EskilSteenberg-yes-you-should-use-malloc-sparingly-i-see-a-lot.md @@ -0,0 +1,39 @@ +--- +title: "Yes, you should use malloc sparingly." +type: archive +source: twitter +source_url: "https://x.com/EskilSteenberg/status/1738667314436816968" +author: "Eskil Steenberg" +handle: EskilSteenberg +post_id: "1738667314436816968" +date: 2023-12-23 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "Yes, you should use malloc sparingly." +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/EskilSteenberg/status/1738667314436816968 +- Author: Eskil Steenberg (@EskilSteenberg) +- Posted: 2023-12-23 21:06:05 + +## Branch + +**1/** **@EskilSteenberg** ^1738667314436816968 + +Yes, you should use malloc sparingly. I see a lot of people making multiple calls for multiple buffers, when they could be combined to one malloc. + +However, a big advantage of malloc, is that you can use realloc. realloc relies on being in control of the address space, and being able to remap memory pages in address space to avoid copying. This is not something you can do in userspace yourself. + +A lot of times you don't in advance know how much memory you will need for a task (say parsing a file), so you may be forced to either, break it up in lots of small allocations, or do a pass just to determine how much memory will be needed, so that you can allocate once and then do the computation. realloc enables you to speculatively guess how much memory will be needed, and then in case you need more, realloc on the fly. If you do a good job of guessing you will rarely need that realloc, but the ability to extend memory simplifies memory management significantly. + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-MattsPlayCorner-any-performance-minded-person-should-know-that.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-MattsPlayCorner-any-performance-minded-person-should-know-that.md new file mode 100644 index 0000000..37f2442 --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-MattsPlayCorner-any-performance-minded-person-should-know-that.md @@ -0,0 +1,38 @@ +--- +title: "@bmcnett Any performance minded person should know that any memory allocation is expensive." +type: archive +source: twitter +source_url: "https://x.com/MattsPlayCorner/status/1738624533169340573" +author: "MMaster" +handle: MattsPlayCorner +post_id: "1738624533169340573" +date: 2023-12-23 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett Any performance minded person should know that any memory allocation is expensive." +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/MattsPlayCorner/status/1738624533169340573 +- Author: MMaster (@MattsPlayCorner) +- Posted: 2023-12-23 18:16:05 + +## Branch + +**1/** **@MattsPlayCorner** ^1738624533169340573 + +**@bmcnett** + +Any performance minded person should know that any memory allocation is expensive. Malloc itself is just abstraction and its implementation depends from platform to platform.. +In many systems malloc is the cheapest way to get memory, which doesn't mean its cheap. + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-NOTimothyLottes-perf-enlightment-happens-when-you-no-longer-use.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-NOTimothyLottes-perf-enlightment-happens-when-you-no-longer-use.md new file mode 100644 index 0000000..f74d6ae --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-NOTimothyLottes-perf-enlightment-happens-when-you-no-longer-use.md @@ -0,0 +1,43 @@ +--- +title: "@bmcnett @SheriefFYI Perf enlightment happens when you no longer use dynamic memory allocation, and thus spend your time complaining about page table related bottlenecks at load time." +type: archive +source: twitter +source_url: "https://x.com/NOTimothyLottes/status/1738621380340371808" +author: "NOTimothyLottes" +handle: NOTimothyLottes +post_id: "1738621380340371808" +date: 2023-12-23 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett @SheriefFYI Perf enlightment happens when you no longer use dynamic memory allocation, and thus spend your time complaining about page table related bottlenecks at load time." +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/NOTimothyLottes/status/1738621380340371808 +- Author: NOTimothyLottes (@NOTimothyLottes) +- Posted: 2023-12-23 18:03:33 + +## Branch + +**1/** **@NOTimothyLottes** ^1738621380340371808 + +**@bmcnett** **@SheriefFYI** + +Perf enlightment happens when you no longer use dynamic memory allocation, and thus spend your time complaining about page table related bottlenecks at load time. + +**2/** **@sergei_am** ^1738634286066987120 + +**@NOTimothyLottes** **@bmcnett** **@SheriefFYI** + +IO based on memory mapping can have a similar effect. + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-SimonWagar-how-can-you-ban-that-at-link-time.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-SimonWagar-how-can-you-ban-that-at-link-time.md new file mode 100644 index 0000000..76c1c5e --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-SimonWagar-how-can-you-ban-that-at-link-time.md @@ -0,0 +1,43 @@ +--- +title: "@bmcnett How can you ban that at link time?" +type: archive +source: twitter +source_url: "https://x.com/SimonWagar/status/1738613045088133429" +author: "Simon Wagar 📯🇺🇦" +handle: SimonWagar +post_id: "1738613045088133429" +date: 2023-12-23 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett How can you ban that at link time?" +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/SimonWagar/status/1738613045088133429 +- Author: Simon Wagar 📯🇺🇦 (@SimonWagar) +- Posted: 2023-12-23 17:30:26 + +## Branch + +**1/** **@SimonWagar** ^1738613045088133429 + +**@bmcnett** + +How can you ban that at link time? + +**2/** **@bmcnett** ^1738614684755054845 + +**@SimonWagar** + +remove it from the table of symbols that are legal to link against + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-sergei_am-consoles-pc-people-or-current-gen-console-folks.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-sergei_am-consoles-pc-people-or-current-gen-console-folks.md new file mode 100644 index 0000000..909f13e --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-sergei_am-consoles-pc-people-or-current-gen-console-folks.md @@ -0,0 +1,37 @@ +--- +title: "@bmcnett Consoles." +type: archive +source: twitter +source_url: "https://x.com/sergei_am/status/1738633966226227236" +author: "Sergei" +handle: sergei_am +post_id: "1738633966226227236" +date: 2023-12-23 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett Consoles." +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/sergei_am/status/1738633966226227236 +- Author: Sergei (@sergei_am) +- Posted: 2023-12-23 18:53:34 + +## Branch + +**1/** **@sergei_am** ^1738633966226227236 + +**@bmcnett** + +Consoles. PC people or current gen console folks don’t have the experience where extensive allocation during load time or regular frame were a low hanging fruit for optimization. + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-tom_forsyth-right-at-the-start-of-a-project-add-a-few-million.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-tom_forsyth-right-at-the-start-of-a-project-add-a-few-million.md new file mode 100644 index 0000000..f44171c --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-tom_forsyth-right-at-the-start-of-a-project-add-a-few-million.md @@ -0,0 +1,37 @@ +--- +title: "@bmcnett Right at the start of a project, add a few million clocks of time slug to your malloc() and free() calls and never tell anybody else what you did." +type: archive +source: twitter +source_url: "https://x.com/tom_forsyth/status/1738660383773376517" +author: "Tom Forsyth (TODO: fix my heart or die)" +handle: tom_forsyth +post_id: "1738660383773376517" +date: 2023-12-23 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett Right at the start of a project, add a few million clocks of time slug to your malloc() and free() calls and never tell anybody else what you did." +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/tom_forsyth/status/1738660383773376517 +- Author: Tom Forsyth (TODO: fix my heart or die) (@tom_forsyth) +- Posted: 2023-12-23 20:38:32 + +## Branch + +**1/** **@tom_forsyth** ^1738660383773376517 + +**@bmcnett** + +Right at the start of a project, add a few million clocks of time slug to your malloc() and free() calls and never tell anybody else what you did. + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-24-jcoplien-btw-its-usually-not-malloc-that-kills-you-its-free.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-24-jcoplien-btw-its-usually-not-malloc-that-kills-you-its-free.md new file mode 100644 index 0000000..16e6632 --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-24-jcoplien-btw-its-usually-not-malloc-that-kills-you-its-free.md @@ -0,0 +1,37 @@ +--- +title: "@bmcnett BTW, it's usually not malloc that kills you." +type: archive +source: twitter +source_url: "https://x.com/jcoplien/status/1738900764632723528" +author: "James Coplien" +handle: jcoplien +post_id: "1738900764632723528" +date: 2023-12-24 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett BTW, it's usually not malloc that kills you." +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/jcoplien/status/1738900764632723528 +- Author: James Coplien (@jcoplien) +- Posted: 2023-12-24 12:33:44 + +## Branch + +**1/** **@jcoplien** ^1738900764632723528 + +**@bmcnett** + +BTW, it's usually not malloc that kills you. It's free. + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-24-joadnacer-writing-a-reasonably-performant-memory-allocator.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-24-joadnacer-writing-a-reasonably-performant-memory-allocator.md new file mode 100644 index 0000000..2b2e03b --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-24-joadnacer-writing-a-reasonably-performant-memory-allocator.md @@ -0,0 +1,37 @@ +--- +title: "@bmcnett writing a reasonably performant memory allocator is incredibly eye opening, the amount of work that can happen for 1 allocation is certainly not something you want in hot paths" +type: archive +source: twitter +source_url: "https://x.com/joadnacer/status/1739012763945431222" +author: "joad" +handle: joadnacer +post_id: "1739012763945431222" +date: 2023-12-24 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett writing a reasonably performant memory allocator is incredibly eye opening, the amount of work that can happen for 1 allocation is certainly not something you want in hot paths" +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/joadnacer/status/1739012763945431222 +- Author: joad (@joadnacer) +- Posted: 2023-12-24 19:58:46 + +## Branch + +**1/** **@joadnacer** ^1739012763945431222 + +**@bmcnett** + +writing a reasonably performant memory allocator is incredibly eye opening, the amount of work that can happen for 1 allocation is certainly not something you want in hot paths + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-25-lectem-malloc-actually-is-pretty-fast-on-most.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-25-lectem-malloc-actually-is-pretty-fast-on-most.md new file mode 100644 index 0000000..823784b --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-25-lectem-malloc-actually-is-pretty-fast-on-most.md @@ -0,0 +1,41 @@ +--- +title: "@bmcnett @forked_franz malloc() actually is pretty fast on most implementation." +type: archive +source: twitter +source_url: "https://x.com/lectem/status/1739179298383142915" +author: "Clément Grégoire" +handle: lectem +post_id: "1739179298383142915" +date: 2023-12-25 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett @forked_franz malloc() actually is pretty fast on most implementation." +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/lectem/status/1739179298383142915 +- Author: Clément Grégoire (@lectem) +- Posted: 2023-12-25 07:00:31 + +## Branch + +**1/** **@lectem** ^1739179298383142915 + +**@bmcnett** **@forked_franz** + +malloc() actually is pretty fast on most implementation. +free() on the other hand... Can be random. + +The main problem with mem allocations often is that it does allocations at all, when they could be skipped. +As always "it depends" of the context (OS, allocator, sizes,count, ...) + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-30-__malkia__-you-need-it-in-tools-its-impossible-to-produce.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-30-__malkia__-you-need-it-in-tools-its-impossible-to-produce.md new file mode 100644 index 0000000..38813e7 --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-30-__malkia__-you-need-it-in-tools-its-impossible-to-produce.md @@ -0,0 +1,37 @@ +--- +title: "@bmcnett You need it in tools, it's impossible to produce good enough tools on time without it (or new/delete)." +type: archive +source: twitter +source_url: "https://x.com/__malkia__/status/1740889315079757994" +author: "benderfeddenshten" +handle: __malkia__ +post_id: "1740889315079757994" +date: 2023-12-30 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "@bmcnett You need it in tools, it's impossible to produce good enough tools on time without it (or new/delete)." +in_reply_to: "" +parent_post_id: "1738591742541414523" +--- + +## Source + +- URL: https://x.com/__malkia__/status/1740889315079757994 +- Author: benderfeddenshten (@__malkia__) +- Posted: 2023-12-30 00:15:31 + +## Branch + +**1/** **@__malkia__** ^1740889315079757994 + +**@bmcnett** + +You need it in tools, it's impossible to produce good enough tools on time without it (or new/delete). Not yet at least. Hence using something like mimalloc, snmalloc, rpmalloc, jemalloc and the likes + +## Related + +- Spine: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] diff --git a/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/index.md b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/index.md new file mode 100644 index 0000000..d7f6434 --- /dev/null +++ b/archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/index.md @@ -0,0 +1,32 @@ +--- +title: "even among performance minded folks, there's a persistent myth that malloc is \"pretty fast\" when in fact it's so performance hostile that big game productions ban it at link time, to eliminate the damage it causes" +type: archive +source: twitter +source_url: "https://x.com/bmcnett/status/1738591742541414523" +author: "bmcnett" +handle: bmcnett +post_id: "1738591742541414523" +date: 2023-12-23 +archived: 2026-08-26 +draft: false +tags: + - archive + - twitter + - bmcnett +description: "even among performance minded folks, there's a persistent myth that malloc is \"pretty fast\" when in fact it's so performance hostile that big game productions ban it at link time, to eliminate the damage it causes" +in_reply_to: "" +--- + +## Source + +- URL: https://x.com/bmcnett/status/1738591742541414523 +- Author: bmcnett (@bmcnett) +- Posted: 2023-12-23 16:05:47 + +## Thread + +**1/** **@bmcnett** ^1738591742541414523 + +even among performance minded folks, there's a persistent myth that malloc is "pretty fast" when in fact it's so performance hostile that big game productions ban it at link time, to eliminate the damage it causes + +Branches: [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-SimonWagar-how-can-you-ban-that-at-link-time]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-NOTimothyLottes-perf-enlightment-happens-when-you-no-longer-use]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-MattsPlayCorner-any-performance-minded-person-should-know-that]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-sergei_am-consoles-pc-people-or-current-gen-console-folks]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-tom_forsyth-right-at-the-start-of-a-project-add-a-few-million]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-23-EskilSteenberg-yes-you-should-use-malloc-sparingly-i-see-a-lot]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-24-jcoplien-btw-its-usually-not-malloc-that-kills-you-its-free]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-24-joadnacer-writing-a-reasonably-performant-memory-allocator]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-25-lectem-malloc-actually-is-pretty-fast-on-most]], [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a/2023-12-30-__malkia__-you-need-it-in-tools-its-impossible-to-produce]] diff --git a/archive/threads/bmcnett/index.md b/archive/threads/bmcnett/index.md index ae0ce9c..27209ae 100644 --- a/archive/threads/bmcnett/index.md +++ b/archive/threads/bmcnett/index.md @@ -9,4 +9,5 @@ tags: - bmcnett --- +- [[archive/threads/bmcnett/2023-12-23-even-among-performance-minded-folks-theres-a]] - [[archive/threads/bmcnett/2024-12-30-the-simplest-multi-producer-multi-consumer-ring]]