Unecessary string allocations #3

Open
opened 2026-01-18 23:35:34 +00:00 by 0x221E · 1 comment
Owner
  • Extensions and other "fixed" string literals should be designed in a manner that is not re-created each function run.

Example:

IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00168.
IBUILD Log (24:string_create): A string was created @ 0x7bed30a00160 with data: ".o"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00178.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00168 with data: "./main.c.o"
IBUILD Log (42:command_create_f_to_o): Command created, first 4 args: /usr/sbin/gcc -c ./main.c -o ./main.c.o | total args: 6
IBUILD Log (84:command_run): Command calling app /usr/sbin/gcc exited with status code 0 on child process PID 112031.
IBUILD Log (83:build_c_to_o): Compiling ./main.c
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed31000000, allocated 48 bytes of memory, arena last is now @ 0x7bed31000088.
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00180.
IBUILD Log (24:string_create): A string was created @ 0x7bed30a00178 with data: ".o"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00190.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00180 with data: "./test.c.o"
IBUILD Log (42:command_create_f_to_o): Command created, first 4 args: /usr/sbin/gcc -c ./test.c -o ./test.c.o | total args: 6
IBUILD Log (84:command_run): Command calling app /usr/sbin/gcc exited with status code 0 on child process PID 112034.
IBUILD Log (83:build_c_to_o): Compiling ./test.c
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed31000000, allocated 48 bytes of memory, arena last is now @ 0x7bed310000b8.
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00198.
IBUILD Log (24:string_create): A string was created @ 0x7bed30a00190 with data: ".o"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a001a0.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00198 with data: "./a.c.o"
IBUILD Log (42:command_create_f_to_o): Command created, first 4 args: /usr/sbin/gcc -c ./a.c -o ./a.c.o | total args: 6
IBUILD Log (84:command_run): Command calling app /usr/sbin/gcc exited with status code 0 on child process PID 112037.
IBUILD Log (83:build_c_to_o): Compiling ./a.c
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed31000000, allocated 40 bytes of memory, arena last is now @ 0x7bed310000e0.
IBUILD Log (84:command_run): Command calling app /usr/sbin/gcc exited with status code 0 on child process PID 112040.
IBUILD Log (53:link): Linking completed!

Conclusion:
".o" is created each time per file, located in command_create_f_to_o() in command.c. Potentially make the STR_LIT a static temporarily.

- [ ] Extensions and other "fixed" string literals should be designed in a manner that is not re-created each function run. Example: ``` IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00168. IBUILD Log (24:string_create): A string was created @ 0x7bed30a00160 with data: ".o" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00178. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00168 with data: "./main.c.o" IBUILD Log (42:command_create_f_to_o): Command created, first 4 args: /usr/sbin/gcc -c ./main.c -o ./main.c.o | total args: 6 IBUILD Log (84:command_run): Command calling app /usr/sbin/gcc exited with status code 0 on child process PID 112031. IBUILD Log (83:build_c_to_o): Compiling ./main.c IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed31000000, allocated 48 bytes of memory, arena last is now @ 0x7bed31000088. IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00180. IBUILD Log (24:string_create): A string was created @ 0x7bed30a00178 with data: ".o" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00190. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00180 with data: "./test.c.o" IBUILD Log (42:command_create_f_to_o): Command created, first 4 args: /usr/sbin/gcc -c ./test.c -o ./test.c.o | total args: 6 IBUILD Log (84:command_run): Command calling app /usr/sbin/gcc exited with status code 0 on child process PID 112034. IBUILD Log (83:build_c_to_o): Compiling ./test.c IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed31000000, allocated 48 bytes of memory, arena last is now @ 0x7bed310000b8. IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00198. IBUILD Log (24:string_create): A string was created @ 0x7bed30a00190 with data: ".o" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a001a0. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00198 with data: "./a.c.o" IBUILD Log (42:command_create_f_to_o): Command created, first 4 args: /usr/sbin/gcc -c ./a.c -o ./a.c.o | total args: 6 IBUILD Log (84:command_run): Command calling app /usr/sbin/gcc exited with status code 0 on child process PID 112037. IBUILD Log (83:build_c_to_o): Compiling ./a.c IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed31000000, allocated 40 bytes of memory, arena last is now @ 0x7bed310000e0. IBUILD Log (84:command_run): Command calling app /usr/sbin/gcc exited with status code 0 on child process PID 112040. IBUILD Log (53:link): Linking completed! ``` Conclusion: ".o" is created each time per file, located in command_create_f_to_o() in command.c. Potentially make the STR_LIT a static temporarily.
Author
Owner
  • Program allocates memory in string pool for repetitive base strings during path_concat_ss() implemented in io.c. The issue is located in discovery_discover().
IBUILD Log (24:string_create): A string was created @ 0x7bed30a00000 with data: "."
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00010.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00008 with data: "./"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00020.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00010 with data: "./main.c.d"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00018.
IBUILD Log (57:dir_get_recursive): Added entry: "./main.c.d" to memory location @ 0x7bed30b00000.
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00028.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00020 with data: "./"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00038.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00028 with data: "./main.c"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00030.
IBUILD Log (57:dir_get_recursive): Added entry: "./main.c" to memory location @ 0x7bed30b00018.
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00040.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00038 with data: "./"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00050.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00040 with data: "./main.c.o"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00048.
IBUILD Log (57:dir_get_recursive): Added entry: "./main.c.o" to memory location @ 0x7bed30b00030.
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00058.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00050 with data: "./"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00068.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00058 with data: "./test.c"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00060.
IBUILD Log (57:dir_get_recursive): Added entry: "./test.c" to memory location @ 0x7bed30b00048.
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00070.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00068 with data: "./"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00080.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00070 with data: "./ibuild"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00078.
IBUILD Log (57:dir_get_recursive): Added entry: "./ibuild" to memory location @ 0x7bed30b00060.
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00088.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00080 with data: "./"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00090.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00088 with data: "./a.c"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00090.
IBUILD Log (57:dir_get_recursive): Added entry: "./a.c" to memory location @ 0x7bed30b00078.
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00098.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00090 with data: "./"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a000a0.
IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00098 with data: "./a.out"
IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b000a8.
IBUILD Log (57:dir_get_recursive): Added entry: "./a.out" to memory location @ 0x7bed30b00090.
- [ ] Program allocates memory in string pool for repetitive base strings during path_concat_ss() implemented in io.c. The issue is located in discovery_discover(). ``` IBUILD Log (24:string_create): A string was created @ 0x7bed30a00000 with data: "." IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00010. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00008 with data: "./" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00020. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00010 with data: "./main.c.d" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00018. IBUILD Log (57:dir_get_recursive): Added entry: "./main.c.d" to memory location @ 0x7bed30b00000. IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00028. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00020 with data: "./" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00038. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00028 with data: "./main.c" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00030. IBUILD Log (57:dir_get_recursive): Added entry: "./main.c" to memory location @ 0x7bed30b00018. IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00040. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00038 with data: "./" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00050. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00040 with data: "./main.c.o" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00048. IBUILD Log (57:dir_get_recursive): Added entry: "./main.c.o" to memory location @ 0x7bed30b00030. IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00058. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00050 with data: "./" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00068. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00058 with data: "./test.c" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00060. IBUILD Log (57:dir_get_recursive): Added entry: "./test.c" to memory location @ 0x7bed30b00048. IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00070. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00068 with data: "./" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 16 bytes of memory, arena last is now @ 0x7bed30a00080. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00070 with data: "./ibuild" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00078. IBUILD Log (57:dir_get_recursive): Added entry: "./ibuild" to memory location @ 0x7bed30b00060. IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00088. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00080 with data: "./" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00090. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00088 with data: "./a.c" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b00090. IBUILD Log (57:dir_get_recursive): Added entry: "./a.c" to memory location @ 0x7bed30b00078. IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a00098. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00090 with data: "./" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30a00000, allocated 8 bytes of memory, arena last is now @ 0x7bed30a000a0. IBUILD Log (39:string_concat_ss): A string was created @ 0x7bed30a00098 with data: "./a.out" IBUILD Log (75:arena_alloc): Arena with block @ 0x7bed30b00000, allocated 24 bytes of memory, arena last is now @ 0x7bed30b000a8. IBUILD Log (57:dir_get_recursive): Added entry: "./a.out" to memory location @ 0x7bed30b00090. ```
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: 0x221E/ibuild#3