robin.ge
2020-3-29 19:16:12

Hey I am new here, I was wondering if anyone could help me out. I have a very simple GUI app which plots the temperature from sensors exposed through /sys https://gist.github.com/robinedwards/e9b51f04ca4efca541266a6a3bd81fea Compiling this using raco exe and running it uses 494MB RES on 7.6 CS and about 300MB RES on 7.4 BC . This seems like an lot for a simple gui app is there some way of improving this?


samth
2020-3-29 19:19:32

@robin.ge most likely, you would need to require fewer things. Are you depending on a lot of libraries?


robin.ge
2020-3-29 19:20:38

Just:

#lang racket/base (require plot) (require racket/gui)


samth
2020-3-29 19:20:59

almost certainly the issue is plot


samth
2020-3-29 19:21:27

> (current-memory-use) 58072856 > (require plot) > (current-memory-use) 128852564


samth
2020-3-29 19:21:48

which probably means there’s not much you can do


spdegabrielle
2020-3-29 19:25:07

I know plot makes things easy but if you only need a simple graph maybe just use racket/draw


samth
2020-3-29 19:29:44

cool app, btw. Also, you might want to set an initial width and height for the frame — otherwise I wasn’t able to see the window


robin.ge
2020-3-29 19:32:10

Ah it maybe because i have a tiling window manager that it worked by accident for me


samth
2020-3-29 19:33:23

I put a print out of (current-memory-use) in the update handler, and I got results like this: 149129872 158044968 159378736 152955160 153565336 145944472 146641016 147399968 148211808 140501456 165773184 158280312


samth
2020-3-29 19:33:33

htop tells me about 228MB RES


samth
2020-3-29 19:33:37

that’s with Racket BC


robin.ge
2020-3-29 19:33:54

Ah yea it was better on BC cool, I really like plot


robin.ge
2020-3-29 19:34:07

i will suck up the memory usage rams cheap any how :slightly_smiling_face:


samth
2020-3-29 19:34:21

for current-memory-use, I saw numbers not that much larger than that for just (require plot), so you are unlikely to do much better


samth
2020-3-29 19:34:34

plot is kinda heavyweight


robin.ge
2020-3-29 19:37:13

I guess because of the dynamic nature of the language its hard for the compiler to know which parts of plot to include in the binary


samth
2020-3-29 19:39:45

@robin.ge yes, that’s definitely true — it’s including the whole thing both in the binary and loading it at runtime


robin.ge
2020-3-29 20:31:15

Hmm just noticed i don’t seem to get ‘full’ syntax highlighting until i hit the ‘check syntax’ button in DrRacket then when i make a change i need to ‘check syntax’ again. Is there some setting I am missing? (Seems to occur in 7.4 and 7.6)


samth
2020-3-29 20:32:54

That’s the standard behavior


jestarray
2020-3-29 21:27:55

so i have a list of numbers (list 1 2 3) and i want to turn it into a string , “123” . (list->string) only takes in chars, so is there a way to convert a number into a char? because (integer->char) returns the ascii mapping.. which is not what i want


jestarray
2020-3-29 21:31:59
ohhh nvm, need to prefix with #

ruyvalle
2020-3-29 21:54:06

what you’re doing there is turning a list of characters into a string. #\1 is the character 1. if you’re starting with an actual list of numbers you could use (string-join (map number->string lst) ""), where lst is your list


jestarray
2020-3-29 22:45:17

i used (apply string-append (list ))


jestarray
2020-3-29 22:45:24

also


jestarray
2020-3-29 22:45:58

is the guy who maintains the arch linux repo of racket here?


jestarray
2020-3-29 22:46:09

if so https://www.archlinux.org/packages/community/x86_64/racket/ , please update it… its been a month since 7.6


alexharsanyi
2020-3-30 04:21:09

It seems to me that Racket has a large initial overhead, meaning that small applications still use a lot of memory, but this memory usage does not grow much as the application grows in complexity.

For example, my application has about 40k lines of code, has lots of plots with data sets of 3000+ data points and it still uses only 470Mb using Racket 7.5 BC.


jestarray
2020-3-30 05:18:06

is there a way i can get the binary representation of numbers?


yanyingwang1
2020-3-30 05:31:31

@yanyingwang1 has joined the channel


jestarray
2020-3-30 05:43:07

unsure how to paramaterize a number over #b


jestarray
2020-3-30 05:46:37

ohhh nevermind, its a string


jestarray
2020-3-30 05:56:10

nevermind… (~r num :base 2)


laurent.orseau
2020-3-30 06:53:09

Also (apply ~a '(1 2 3))