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

many improvements to the config facility and usage #519

Merged
merged 8 commits into from
Mar 21, 2021

Conversation

npitre
Copy link
Contributor

@npitre npitre commented Mar 20, 2021

Those are changes that are certainly going to improve performance
and make the code easier to understand.

This code was way too complicated and suboptimal.
Doing strlen() over and over is extremely unefficient.
The initial config can be greatly simplified and be made more compact.

Before this change:

   text    data     bss     dec     hex filename
   1530       0       0    1530     5fa conf.o

After this change:

   text    data     bss     dec     hex filename
   1036       0       0    1036     40c conf.o
This is not used anywhere. And there is no need to have a full
dictionary for that either. If necessary the original value could
still be retrieved from the default-config array.
This will allow for not doing atoi() over and over everywhere.
Now that we store both the string and the numeric value for every config
entries, let's grab those values directly. This should save quite some
processing cycles.

Those changes were performed with the following command:

sed -e 's/atoi(get_conf_value *(\([^)]*\)))/get_conf_int(\1)/g' -i *.c *.y
Those didn't match the sed formula.
Similar to the previous patch. Here we use get_int() directly.
@andmarti1424
Copy link
Owner

Thank you! Hope this wont break anything.
Question: why you decided to improve this, being improvements on other parts more needed?

@andmarti1424 andmarti1424 merged commit 4175e52 into andmarti1424:freeze Mar 21, 2021
@andmarti1424
Copy link
Owner

I got this warning btw:
conf.c: In function ‘store_default_config_values’:
conf.c:110:18: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
110 | char *line = default_config;
| ^~~~~~~~~~~~~~

@npitre
Copy link
Contributor Author

npitre commented Mar 21, 2021 via email

@npitre
Copy link
Contributor Author

npitre commented Mar 21, 2021 via email

@andmarti1424
Copy link
Owner

Well, the main bug is with circular references, some of them makes sc-im crash.

For instance if you set A0 to A0+A1 message "Circular reference shows up"
For instance if you set A0 to @sum(A0) it crashes..

Old SC used to evaluate the entire table on each change..doesnt matter if your change affect or not other cells. that was changed to a dependency graph.

Probably this validation should be handled in eval function of interp.c

@npitre
Copy link
Contributor Author

npitre commented Mar 21, 2021 via email

@andmarti1424
Copy link
Owner

@npitre Yes. There is a problem with parse_str of dictionary.c
:color type=HEADINGS fg=BLACK bg=YELLOW bold=1
command doesnt work anymore.

@andmarti1424
Copy link
Owner

@npitre I made an urgent commit to recover that. Please give it a look. The parsing was not working properly.
Thanks.

@npitre
Copy link
Contributor Author

npitre commented Mar 22, 2021 via email

@andmarti1424
Copy link
Owner

@npitre Latest changes seems to work ok but it seems memory alloc'ed by strdup in function 'put' of dictionary.c is not freed and makes some memory leaks
on Valgrind..
Please check this out:

==7095== 2 bytes in 1 blocks are still reachable in loss record 1 of 296
==7095== at 0x483E77F: malloc (vg_replace_malloc.c:307)
==7095== by 0x4C6B5BE: strdup (in /usr/lib/libc-2.33.so)
==7095== by 0x14AA34: put (dictionary.c:96)
==7095== by 0x123FD9: set_colors_param_dict (color.c:177)
==7095== by 0x1415E3: ui_start_screen (tui.c:137)
==7095== by 0x13B71F: main (main.c:233)
==7095==
==7095== 2 bytes in 1 blocks are still reachable in loss record 2 of 296
==7095== at 0x483E77F: malloc (vg_replace_malloc.c:307)
==7095== by 0x4C6B5BE: strdup (in /usr/lib/libc-2.33.so)
==7095== by 0x14AA34: put (dictionary.c:96)
==7095== by 0x124010: set_colors_param_dict (color.c:179)
==7095== by 0x1415E3: ui_start_screen (tui.c:137)
==7095== by 0x13B71F: main (main.c:233)

@andmarti1424
Copy link
Owner

@npitre forget about last message. I was seeing a log of what I am debugging... where I forced an exit and didnt free memory correctly

@npitre
Copy link
Contributor Author

npitre commented Mar 22, 2021 via email

@npitre npitre deleted the conf branch March 22, 2021 19:34
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.

None yet

2 participants